Skip to content

Commit 7caae1a

Browse files
committed
Fixed tests.
1 parent 8648c43 commit 7caae1a

4 files changed

Lines changed: 11 additions & 19 deletions

File tree

src/Agent/NewRelic/Agent/Core/OpenTelemetryBridge/Tracing/ActivityBridgeSegmentHelpers.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ private static void ProcessRpcClientTags(ISegment segment, IAgent agent, IErrorS
171171

172172
Log.Finest($"Created ExternalSegmentData for {activityLogPrefix}.");
173173

174-
segment.GetExperimentalApi().SetSegmentData(externalSegmentData);
174+
segment.GetExperimentalApi().SetSegmentData(externalSegmentData)
175+
.MakeLeaf();
175176

176177
// per spec, a non-zero status code must be recorded as an exception.
177178
// TODO: This behavior is supposed to be configurable by the customer but currently is not

src/Agent/NewRelic/Agent/Core/OpenTelemetryBridge/Tracing/NewRelicActivitySourceProxy.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,4 @@ public static void SetAndCreateRuntimeActivitySource(Type activitySourceType, Ty
3232
}
3333

3434
public INewRelicActivity TryCreateActivity(string activityName, ActivityKind kind) => _activitySource?.CreateActivity(activityName, kind);
35-
36-
/// <summary>
37-
/// FOR TESTING ONLY: Resets the static state to allow re-initialization in tests.
38-
/// </summary>
39-
public static void ResetStaticState()
40-
{
41-
var oldSource = Interlocked.Exchange(ref _activitySource, null) as IDisposable;
42-
oldSource?.Dispose();
43-
Interlocked.Exchange(ref _usingRuntimeActivitySource, 0);
44-
}
4535
}

tests/Agent/IntegrationTests/IntegrationTests/Grpc/GrpcTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public void Metrics_ExternalCallIsCaptured()
6363
// The gRPC spec calls for host and port, but we don't include that in the metric name for any external so skipping that for now.
6464
var expectedMetrics = new List<Assertions.ExpectedMetric>
6565
{
66-
new() { metricName = @"External/all", CallCountAllHarvests = 1 },
67-
new() { metricName = @"External/allOther", CallCountAllHarvests = 1 },
66+
new() { metricName = @"External/all", CallCountAllHarvests = 2 },
67+
new() { metricName = @"External/allOther", CallCountAllHarvests = 2 },
6868
new() { metricName = @"External/unknown/all", CallCountAllHarvests = 1 },
6969
new() { metricName = @"External/unknown/gRPC/greet.Greeter/SayHello", CallCountAllHarvests = 1 },
7070
new() { metricName = @"External/unknown/gRPC/greet.Greeter/SayHello", metricScope = "OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.Grpc.GrpcExerciser/MakeGrpcClientCall", CallCountAllHarvests = 1 },

tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/Grpc/GrpcExerciser.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Net.Http;
99
using System.Net.Sockets;
1010
using System.Runtime.CompilerServices;
11+
using System.Threading.Tasks;
1112
using GrpcGreet;
1213
using Grpc.Net.Client;
1314
using Microsoft.AspNetCore.Builder;
@@ -24,7 +25,7 @@ public class GrpcExerciser
2425
{
2526
[LibraryMethod]
2627
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
27-
public void SayHello(string port)
28+
public async Task SayHello(string port)
2829
{
2930
var actualPort = port == "0" ? GetAvailablePort() : int.Parse(port);
3031

@@ -41,21 +42,21 @@ public void SayHello(string port)
4142
var app = builder.Build();
4243
app.MapGrpcService<GreeterService>();
4344

44-
app.StartAsync().GetAwaiter().GetResult();
45+
await app.StartAsync();
4546

4647
try
4748
{
48-
MakeGrpcClientCall(actualPort);
49+
await MakeGrpcClientCall(actualPort);
4950
}
5051
finally
5152
{
52-
app.StopAsync().GetAwaiter().GetResult();
53+
await app.StopAsync();
5354
}
5455
}
5556

5657
[Transaction]
5758
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
58-
private static void MakeGrpcClientCall(int port)
59+
private static async Task MakeGrpcClientCall(int port)
5960
{
6061
using var channel = GrpcChannel.ForAddress($"http://localhost:{port}", new GrpcChannelOptions
6162
{
@@ -66,7 +67,7 @@ private static void MakeGrpcClientCall(int port)
6667
});
6768

6869
var client = new Greeter.GreeterClient(channel);
69-
var reply = client.SayHello(new HelloRequest { Name = "TestGrpc" });
70+
var reply = await client.SayHelloAsync(new HelloRequest { Name = "TestGrpc" });
7071

7172
Console.WriteLine($"[GrpcExerciser] Reply: {reply.Message}");
7273
}

0 commit comments

Comments
 (0)