-
Notifications
You must be signed in to change notification settings - Fork 820
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Solution
Move ActivityStartData and ActivityStopData from GrpcCall.cs to GrpcCall.NonGeneric.cs
Reason
GrpcClientDiagnosticListener use PropertyFetcher read Request property. PropertyFetcher use TypedPropertyFetch to improve performance, but in different methods, ActivityStartData and ActivityStopData are not of the same type. so, obj is TDeclaredObject o is false after the first call.
Sample
var services = new ServiceCollection();
services.AddGrpcClient<Greeter.GreeterClient>(options => options.Address = new Uri("http://localhost"))
.ConfigurePrimaryHttpMessageHandler(_ => new TestHandler());
using var _ = Sdk.CreateTracerProviderBuilder()
.AddGrpcClientInstrumentation(options => options.SuppressDownstreamInstrumentation = true)
.SetSampler(new AlwaysOnSampler())
.Build();
await using var root = services.BuildServiceProvider();
await using var scope = root.CreateAsyncScope();
var client = scope.ServiceProvider.GetRequiredService<Greeter.GreeterClient>();
try
{
await client.SayHelloAsync(new HelloRequest());
}
catch (RpcException ex) when (ex.Status.StatusCode == StatusCode.OK) { }
try
{
await client.SayHello2Async(new HelloRequest2());
}
catch (RpcException ex) when (ex.Status.StatusCode == StatusCode.OK) { }
class TestHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.Headers.Contains("traceparent")) //Should never false
throw new RpcException(Status.DefaultSuccess);
throw new UnauthorizedAccessException();
}
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working