[Fusion] Add OpenTelemetry instrumentation#8909
Open
tobias-tengler wants to merge 6 commits intomainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds OpenTelemetry-based activity instrumentation for HotChocolate Fusion (vnext), including a new diagnostics package and a dedicated test suite to validate emitted activities via snapshots.
Changes:
- Introduces
HotChocolate.Fusion.Diagnosticswith activity sources, enrichers, scopes, and diagnostic listeners for Fusion execution and ASP.NET request lifecycle. - Adds
Fusion.Diagnostics.Testswith snapshot-based assertions for activity names/tags/status across common request scenarios (success, validation errors, document capture, display-name formatting). - Wires required pooling/services and updates solution files to include the new projects.
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolate.Fusion.Diagnostics.csproj | New Fusion diagnostics package project (OpenTelemetry API dependency). |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolateFusionActivitySource.cs | Defines Fusion ActivitySource name/version. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs | Adds Fusion instrumentation configuration options. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityScopes.cs | Defines selectable Fusion activity scopes. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/RequestDetails.cs | Flags enum for request-detail inclusion. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/ContextKeys.cs | Context keys for storing activities. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs | Adds tags/events/display-name logic for Fusion spans. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs | Emits activities for Fusion execution pipeline stages. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityServerDiagnosticListener.cs | Emits activities for HTTP request pipeline stages. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/RequestScopeBase.cs | Common scope disposal/enrichment base. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteRequestScope.cs | ExecuteRequest scope enrichment/status logic. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ParseDocumentScope.cs | ParseDocument scope enrichment/status logic. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ValidateDocumentScope.cs | ValidateDocument scope enrichment/status logic. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/CoerceVariablesScope.cs | CoerceVariables scope enrichment/status logic. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/PlanOperationScope.cs | PlanOperation scope enrichment/status logic. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationScope.cs | ExecuteOperation scope enrichment/status logic. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs | Adds AddInstrumentation to Fusion gateway builder. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/TracerProviderBuilderExtensions.cs | Adds Fusion activity source to OTel TracerProviderBuilder. |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/HotChocolate.Fusion.Diagnostics.Tests.csproj | New test project for Fusion diagnostics. |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs | Captures and serializes activities for snapshot tests. |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs | New snapshot-based instrumentation tests. |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap | New snapshot baseline (default scopes). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap | New snapshot baseline (all scopes). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap | New snapshot baseline (operation-name behavior). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap | New snapshot baseline (document body tagging). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap | New snapshot baseline (validation error status/event). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap | New snapshot baseline (display-name formatting). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap | New snapshot baseline (display-name + op name). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap | New snapshot baseline (3-field formatting). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap | New snapshot baseline (4-field elision). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap | New snapshot baseline (execution error status). |
| src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/snapshots/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap | New snapshot baseline (nested error surface). |
| src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/FusionRequestExecutorManager.cs | Adds ObjectPoolProvider/StringBuilder pool registrations needed by instrumentation. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Execution/DependencyInjection/HotChocolateFusionServiceCollectionExtensions.cs | Adds core DI registrations (options + object pools) for Fusion gateway. |
| src/HotChocolate/Fusion-vnext/HotChocolate.Fusion-vnext.slnx | Includes new Fusion diagnostics projects in Fusion-vnext solution. |
| src/All.slnx | Includes new Fusion diagnostics projects in global solution list. |
| src/HotChocolate/Diagnostics/src/Diagnostics/Extensions/DiagnosticsRequestExecutorBuilderExtensions.cs | Minor refactor to primary-constructor style for internal enricher. |
| src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs | Adjusts how request variables are serialized into tags (and changes protected virtual signatures). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs
Show resolved
Hide resolved
Contributor
Fusion Gateway Performance ResultsSimple Composite Query
Response Times & Query
query TestQuery {
topProducts(first: 5) {
inStock
name
price
shippingEstimate
upc
weight
reviews {
id
body
author {
id
username
name
}
}
}
}Deep Recursion Query
Response Times & Query
query TestQuery {
users {
id
username
name
reviews {
id
body
product {
inStock
name
price
shippingEstimate
upc
weight
reviews {
id
body
author {
id
username
name
reviews {
id
body
product {
inStock
name
price
shippingEstimate
upc
weight
}
}
}
}
}
}
}
topProducts(first: 5) {
inStock
name
price
shippingEstimate
upc
weight
reviews {
id
body
author {
id
username
name
reviews {
id
body
product {
inStock
name
price
shippingEstimate
upc
weight
}
}
}
}
}
}Variable Batching Throughput
Response Times & Query
query TestQuery($upc: ID!, $price: Long!, $weight: Long!) {
productByUpc(upc: $upc) {
inStock
shippingEstimate(weight: $weight, price: $price)
}
}Variables (5 sets batched per request) [
{ "upc": "1", "price": 899, "weight": 100 },
{ "upc": "2", "price": 1299, "weight": 1000 },
{ "upc": "3", "price": 15, "weight": 20 },
{ "upc": "4", "price": 499, "weight": 100 },
{ "upc": "5", "price": 1299, "weight": 1000 }
]Run 22324683115 • Commit 69e907a • Mon, 23 Feb 2026 21:22:48 GMT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.