Skip to content

Comments

[Fusion] Add OpenTelemetry instrumentation#8909

Merged
tobias-tengler merged 12 commits intomainfrom
tte/fusion-opentelemetry
Feb 25, 2026
Merged

[Fusion] Add OpenTelemetry instrumentation#8909
tobias-tengler merged 12 commits intomainfrom
tte/fusion-opentelemetry

Conversation

@tobias-tengler
Copy link
Member

No description provided.

@tobias-tengler tobias-tengler marked this pull request as ready for review February 23, 2026 21:01
Copilot AI review requested due to automatic review settings February 23, 2026 21:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Diagnostics with activity sources, enrichers, scopes, and diagnostic listeners for Fusion execution and ASP.NET request lifecycle.
  • Adds Fusion.Diagnostics.Tests with 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.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

Fusion Gateway Performance Results

Simple Composite Query

Req/s Err%
Constant (50 VUs) 6951.10 0.00%
Ramping (0-500-0 VUs) 7388.70 0.00%
Response Times & Query
Min Med Avg P90 P95 Max
Constant 0.57ms 5.96ms 7.05ms 11.01ms 15.63ms 177.82ms
Ramping 0.58ms 24.07ms 29.77ms 63.45ms 75.86ms 185.58ms
query TestQuery {
  topProducts(first: 5) {
    inStock
    name
    price
    shippingEstimate
    upc
    weight
    reviews {
      id
      body
      author {
        id
        username
        name
      }
    }
  }
}

Deep Recursion Query

Req/s Err%
Constant (50 VUs) 1266.62 0.00%
Ramping (0-500-0 VUs) 1348.30 0.00%
Response Times & Query
Min Med Avg P90 P95 Max
Constant 4.71ms 34.36ms 38.32ms 52.46ms 63.26ms 393.96ms
Ramping 1.90ms 136.02ms 157.59ms 339.70ms 385.07ms 641.50ms
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

Req/s Err%
Constant (50 VUs) 23656.17 0.00%
Ramping (0-500-0 VUs) 18501.67 0.00%
Response Times & Query
Min Med Avg P90 P95 Max
Constant 0.08ms 1.72ms 2.06ms 3.98ms 4.82ms 49.22ms
Ramping 0.08ms 9.39ms 11.43ms 23.75ms 28.47ms 117.17ms
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 22387847918 • Commit 1eade5c • Wed, 25 Feb 2026 08:43:48 GMT

@tobias-tengler tobias-tengler merged commit 8bbe4e3 into main Feb 25, 2026
118 checks passed
@tobias-tengler tobias-tengler deleted the tte/fusion-opentelemetry branch February 25, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant