Skip to content

Commit

Permalink
Udated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla committed Mar 12, 2021
1 parent 69ec569 commit 5495bde
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Microsoft.AspNetCore.Http;
using Moq;
using OpenTelemetry.Instrumentation.GrpcNetClient;
using OpenTelemetry.Instrumentation.GrpcNetClient.Implementation;
using OpenTelemetry.Trace;
using Xunit;

Expand Down Expand Up @@ -143,6 +144,7 @@ public void GrpcAndHttpClientInstrumentationIsInvoked(bool shouldEnrich)

ValidateGrpcActivity(grpcSpan);
Assert.Equal($"greet.Greeter/SayHello", grpcSpan.DisplayName);
Assert.Equal(0, grpcSpan.GetTagValue(SemanticConventions.AttributeRpcGrpcStatusCode));
Assert.Equal($"HTTP POST", httpSpan.DisplayName);
Assert.Equal(grpcSpan.SpanId, httpSpan.ParentSpanId);
}
Expand Down Expand Up @@ -274,6 +276,7 @@ public void GrpcPropagatesContextWithSuppressInstrumentation()
Assert.Equal($"greet.Greeter/SayHello", serverActivity.DisplayName);
Assert.Equal(clientActivity.TraceId, serverActivity.TraceId);
Assert.Equal(clientActivity.SpanId, serverActivity.ParentSpanId);
Assert.Equal(0, clientActivity.GetTagValue(SemanticConventions.AttributeRpcGrpcStatusCode));
Assert.Contains("item1=value1", serverActivity.GetCustomProperty("BaggageString") as string);
}

Expand All @@ -286,11 +289,14 @@ public void Grpc_BadArgs()

private static void ValidateGrpcActivity(Activity activityToValidate)
{
Assert.Equal(GrpcClientDiagnosticListener.ActivitySourceName, activityToValidate.Source.Name);
Assert.Equal(GrpcClientDiagnosticListener.Version.ToString(), activityToValidate.Source.Version);
Assert.Equal(ActivityKind.Client, activityToValidate.Kind);
}

private static void ActivityEnrichment(Activity activity, string method, object obj)
{
Assert.True(activity.IsAllDataRequested);
switch (method)
{
case "OnStartActivity":
Expand Down

0 comments on commit 5495bde

Please sign in to comment.