Add Engine Telemetry - Phase 1 - #3825
Open
aaronburtle wants to merge 6 commits into
Open
aaronburtle wants to merge 6 commits into
aaronburtle wants to merge 6 commits into
Conversation
Introduce isolated, default-off engine telemetry with explicit validation gates, bounded aggregation, and Azure Monitor export. Cover startup, configuration, request and transport completion with synthetic regression tests. Honor the umbrella opt-out and preserve customer telemetry independence. Keep internal design drafts local and ignored, outside the published commit history.
Use closed failure stages and attempt-scoped attribution for web, stdio, late configuration, validation, and hot reload. Preserve first-failure attribution, prior epochs, handler task semantics, and nested disabled-provider isolation. Add startup, recovery, concurrency, and compatibility regression coverage.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved critical credential-selection and moderate telemetry completion/classification issues remain.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
“Add Engine Telemetry - Phase 1” introduces default-off, synthetic engine telemetry across REST, GraphQL, MCP, lifecycle events, aggregation, and Application Insights delivery.
Changes:
- Adds bounded lifecycle, request, operation, cache, embedding, database, and HTTP telemetry.
- Adds privacy safeguards, identity handling, opt-out controls, and extensive tests.
- Review findings remain: one critical Startup issue (1 vote) and three moderate MCP/GraphQL issues (1, 2, and 2 votes).
| File | Summary |
|---|---|
src/Service/Utilities/McpStdioHelper.cs |
Integrates MCP stdio lifecycle telemetry. |
src/Service/Telemetry/EngineTelemetrySdkTransportHandler.cs |
Guards SDK transport payloads and responses. |
src/Service/Telemetry/EngineTelemetryHttpMiddleware.cs |
Tracks REST request completion. |
src/Service/Telemetry/EngineTelemetryHttpCompletion.cs |
Coordinates HTTP completion outcomes. |
src/Service/Telemetry/EngineTelemetryHosting.cs |
Hosts telemetry and cache observers. |
src/Service/Telemetry/EngineTelemetryHealthProbe.cs |
Excludes internal health probes. |
src/Service/Telemetry/EngineTelemetryGraphQLListener.cs |
Tracks GraphQL execution and eligibility. |
src/Service/Telemetry/EngineTelemetryExportAttempt.cs |
Stores export-attempt state. |
src/Service/Telemetry/EngineTelemetryEmbeddingEndpointMetadata.cs |
Identifies embedding endpoints. |
src/Service/Telemetry/EngineTelemetryApplicationInsightsExporter.cs |
Implements guarded Application Insights export. |
src/Service/Telemetry/ApplicationInsightsTelemetryDestination.cs |
Validates telemetry destinations. |
src/Service/Telemetry/ApplicationInsightsEventAttributes.cs |
Maps events to SDK attributes. |
src/Service/Startup.cs |
Registers telemetry throughout the host pipeline. |
src/Service/Program.cs |
Adds telemetry bootstrap and shutdown handling. |
src/Service/Controllers/ConfigurationController.cs |
Reports configuration parsing failures. |
src/Service/Azure.DataApiBuilder.Service.csproj |
Adds the exporter dependency. |
src/Service.Tests/UnitTests/PostgreSqlQueryExecutorUnitTests.cs |
Makes credential tests deterministic. |
src/Service.Tests/UnitTests/McpStdioHelperTests.cs |
Tests stdio telemetry failures. |
src/Service.Tests/Telemetry/EngineTelemetryQueryExecutorTests.cs |
Tests database-attempt attribution. |
src/Service.Tests/Telemetry/EngineTelemetryContextTests.cs |
Tests runtime context privacy. |
src/Service.Tests/Telemetry/EngineTelemetryCloudTests.cs |
Adds opt-in cloud smoke coverage. |
src/Service.Tests/Telemetry/ApplicationInsightsTelemetryDestinationTests.cs |
Tests destination validation. |
src/Service.Tests/Telemetry/ApplicationInsightsEventAttributesTests.cs |
Tests payload attribute guards. |
src/Service.Tests/telemetry.runsettings |
Sets SDK statistics opt-outs for tests. |
src/Service.Tests/Azure.DataApiBuilder.Service.Tests.csproj |
Applies telemetry test settings. |
src/Directory.Packages.props |
Updates compatible package versions. |
src/Core/Telemetry/Product/IProductTelemetryControl.cs |
Defines host telemetry control. |
src/Core/Telemetry/Product/IEngineTelemetryExporter.cs |
Defines exporter abstraction. |
src/Core/Telemetry/Product/EngineTelemetryValueFormatter.cs |
Defines stable telemetry spellings. |
src/Core/Telemetry/Product/EngineTelemetryRequestScope.cs |
Tracks request state and completion. |
src/Core/Telemetry/Product/EngineTelemetryOptions.cs |
Defines bounded aggregation options. |
src/Core/Telemetry/Product/EngineTelemetryMeasurementScope.cs |
Tracks operation measurements. |
src/Core/Telemetry/Product/EngineTelemetryMeasurements.cs |
Defines telemetry dimensions and windows. |
src/Core/Telemetry/Product/EngineTelemetryEvent.cs |
Defines immutable event envelopes. |
src/Core/Telemetry/Product/EngineTelemetryDelivery.cs |
Provides bounded asynchronous delivery. |
src/Core/Telemetry/Product/EngineTelemetryContext.cs |
Captures categorical runtime context. |
src/Core/Telemetry/Product/EngineTelemetryCacheObserver.cs |
Observes cache-layer lookups. |
src/Core/Telemetry/Product/EngineTelemetryAggregator.cs |
Aggregates bounded usage windows. |
src/Core/Services/RestService.cs |
Instruments REST operations. |
src/Core/Services/ExecutionHelper.cs |
Instruments GraphQL operations. |
src/Core/Services/Embeddings/EmbeddingService.cs |
Instruments embedding calls. |
src/Core/Resolvers/QueryExecutor.cs |
Instruments database attempts. |
src/Core/Resolvers/CosmosClientProvider.cs |
Applies the product opt-out to Cosmos identity. |
src/Core/Configurations/RuntimeConfigValidator.cs |
Attributes validation failures. |
src/Core/Azure.DataApiBuilder.Core.csproj |
Grants telemetry internals access. |
src/Config/Telemetry/TelemetryFailureStage.cs |
Defines failure stages. |
src/Config/Telemetry/TelemetryFailureContext.cs |
Carries reload failure context. |
src/Config/Telemetry/TelemetryConfigurationPresence.cs |
Captures bounded configuration presence. |
src/Config/Telemetry/ProductTelemetryPolicy.cs |
Defines enablement and opt-out policy. |
src/Config/Telemetry/ApplicationNameTelemetry.cs |
Implements application-name opt-out behavior. |
src/Config/RuntimeConfigLoader.cs |
Captures configuration provenance. |
src/Config/Properties/AssemblyInfo.cs |
Adds telemetry friend assemblies. |
src/Config/ObjectModel/RuntimeConfig.cs |
Stores telemetry provenance metadata. |
src/Config/FileSystemRuntimeConfigLoader.cs |
Integrates reload telemetry attribution. |
src/Config/DabChangeToken.cs |
Preserves reload failure context. |
src/Azure.DataApiBuilder.Mcp/Utils/McpTelemetryHelper.cs |
Instruments MCP tool execution. |
src/Azure.DataApiBuilder.Mcp/Utils/McpProductResponseStream.cs |
Observes MCP response writes. |
src/Azure.DataApiBuilder.Mcp/Utils/McpProductResponseCompletion.cs |
Completes MCP responses at transport boundaries. |
src/Azure.DataApiBuilder.Mcp/Core/McpStdioServer.cs |
Delays stdio completion until response writing. |
src/Azure.DataApiBuilder.Mcp/Core/McpServerConfiguration.cs |
Registers MCP response filters. |
src/Azure.DataApiBuilder.Mcp/Core/McpEndpointRouteBuilderExtensions.cs |
Wraps MCP HTTP response streams. |
.gitignore |
Excludes local telemetry design drafts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+305
to
+309
| string? role = isStdio | ||
| ? configuration?.GetValue<string>("MCP:Role") | ||
| : httpContext?.Request.Headers[AuthorizationResolver.CLIENT_ROLE_HEADER].ToString(); | ||
| EngineTelemetryRole roleClass = EngineTelemetrySession.ClassifyRole( | ||
| role, httpContext?.User.Identity?.IsAuthenticated == true); |
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.

Why make this change?
Closes #3215
Add engine-owned telemetry for runtime context, configured capabilities, lifecycle, and aggregate usage across REST, GraphQL, and MCP without relying on customer diagnostic pipelines. This establishes a default-off, synthetic-validation implementation, not production collection.
Set these variables before starting DAB in a dedicated process using synthetic test data.
DAB_PRODUCT_TELEMETRY_TEST_MODE1ortrueDAB_PRODUCT_TELEMETRY_CONNECTION_STRINGAPPLICATIONINSIGHTS_STATSBEAT_DISABLEDtrueAPPLICATIONINSIGHTS_SDKSTATS_DISABLEDtrueDAB_TELEMETRY_OPT_OUT1ortruedisables itThe two SDK statistics flags require literal
true(case-insensitive, without surrounding whitespace). They are process-wide settings; DAB checks them but never changes them.Test mode does not generate synthetic data or anonymize real traffic. Use an isolated test workload and destination, and do not commit connection strings.
What is this change?
Azure.Monitor.OpenTelemetry.Exporter1.9.0 through a dedicated custom-event pipeline, with explicit destination selection, payload guards, and source-IP suppression. Updates compatible Azure/OpenTelemetry dependencies.DAB_TELEMETRY_OPT_OUT, including suppression of the DAB-added Application Name/version segment while preserving customer content and legacy-switch behavior.Scope: Collection remains off by default in every build. CLI command telemetry, installation-profile identity, CLI-to-engine linkage, and production activation remain separate work. Arbitrary embedded/customer-exporter coexistence is not claimed.
How was this tested?
Sample Request(s)
For a dedicated synthetic fixture, configure these before process startup:
DAB_PRODUCT_TELEMETRY_TEST_MODE=1DAB_PRODUCT_TELEMETRY_CONNECTION_STRINGpointing to the selected test destinationAPPLICATIONINSIGHTS_STATSBEAT_DISABLED=trueAPPLICATIONINSIGHTS_SDKSTATS_DISABLED=trueLaunch with
dab start, ordab start --mcp-stdio anonymousfor MCP stdio. SettingDAB_TELEMETRY_OPT_OUT=1overrides enablement.With a configured
Booksentity,GET /api/Booksor this GraphQL query exercises eligible data usage:{ books { items { id title } } }This query must not establish data usage or first-success telemetry because its data selection is excluded:
{ __typename books @skip(if: true) { items { id } } }