Not seeing any GraphQL telemetry with UseTelemetry
Closed this issue · 3 comments
jeffw-wherethebitsroam commented
Summary
I am probably missing something simple here, but I can't get telemetry working with graphql.
Relevant information
Service configuration:
services
.AddOpenTelemetry()
.ConfigureResource(resource => resource.AddService("API"))
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddSqlClientInstrumentation()
.AddConsoleExporter());
// later
services.AddSingleton<IGraphQLExceptionHandler, ExceptionHandler>();
services.AddGraphQL(builder => builder
.AddSchema<MySchema>()
.ConfigureExecutionOptions(options =>
{
var requestServices = options.RequestServices ?? throw new Exception("Missing RequestServices");
var handler = requestServices.GetRequiredService<IGraphQLExceptionHandler>();
options.UnhandledExceptionDelegate = ctx => handler.HandleException(ctx);
})
.AddSystemTextJson()
.AddDataLoader()
.AddGraphTypes(typeof(MySchema).Assembly)
.UseTelemetry()
);
I see http and sql traces, but nothing graphql. I'm not sure where to start debugging this!
Environment (if relevant)
dotnet 8.0
gao-artur commented
Do you see the AspNetCore span? What's the Activity.Current
value when you access it in the field resolver? If not null
, what are the values of the DisplayName
, IsAllDataRequested
, and ActivityTraceFlags
properties?
gao-artur commented
Oh, I see now. You need to register the activity source name
services
.AddOpenTelemetry()
.ConfigureResource(resource => resource.AddService("API"))
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddSqlClientInstrumentation()
.AddSource(GraphQLTelemetryProvider.SourceName) // <= this line!
.AddConsoleExporter());
jeffw-wherethebitsroam commented
Thanks! That fixed it. But I couldn't find documentation for this anywhere!