Skip to content

Commit 386b6dd

Browse files
committed
Add GraphQL Open Telemetry Support
1 parent c478790 commit 386b6dd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Source/GraphQLTemplate/Source/GraphQLTemplate/CustomServiceCollectionExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,11 @@ static string GetHttpFlavour(string protocol)
176176
}
177177
};
178178
options.RecordException = true;
179-
});
179+
})
180180
#if Redis
181-
builder.AddRedisInstrumentation();
181+
.AddRedisInstrumentation()
182182
#endif
183+
.AddHotChocolateInstrumentation();
183184

184185
if (webHostEnvironment.IsDevelopment())
185186
{
@@ -217,6 +218,9 @@ public static IServiceCollection AddCustomGraphQL(
217218
var graphQLOptions = configuration.GetRequiredSection(nameof(ApplicationOptions.GraphQL)).Get<GraphQLOptions>();
218219
return services
219220
.AddGraphQLServer()
221+
#if OpenTelemetry
222+
.AddInstrumentation()
223+
#endif
220224
.InitializeOnStartup()
221225
.AddFiltering()
222226
.AddSorting()

Source/GraphQLTemplate/Source/GraphQLTemplate/GraphQLTemplate.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<PackageReference Include="HotChocolate.AspNetCore" Version="12.5.0" />
5959
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="12.5.0" Condition="'$(Authorization)' == 'true'" />
6060
<PackageReference Include="HotChocolate.Data" Version="12.5.0" />
61+
<PackageReference Include="HotChocolate.Diagnostics" Version="12.5.0" Condition="'$(OpenTelemetry)' == 'true'" />
6162
<PackageReference Include="HotChocolate.PersistedQueries.InMemory" Version="12.5.0" Condition="'$(PersistedQueries)' == 'true'" />
6263
<PackageReference Include="HotChocolate.PersistedQueries.Redis" Version="12.5.0" Condition="'$(PersistedQueries)' == 'true'" />
6364
<PackageReference Include="HotChocolate.Subscriptions.Redis" Version="12.5.0" Condition="'$(Subscriptions)' == 'true'" />

0 commit comments

Comments
 (0)