Overview
Implement the OpenTelemetry integration for the C# (ASP.NET Core + EF Core) service as specified in src/csharp/adr/008-opentelemetry.md .
Parent issue: #14
Tasks
Add required NuGet packages (OpenTelemetry.Extensions.Hosting, OpenTelemetry.Instrumentation.AspNetCore, OpenTelemetry.Instrumentation.Http, OpenTelemetry.Instrumentation.EntityFrameworkCore, OpenTelemetry.Instrumentation.Runtime, OpenTelemetry.Exporter.OpenTelemetryProtocol)
Register OTel services in Program.cs via AddOpenTelemetry() — OTLP exporters MUST NOT be registered when OTEL_EXPORTER_OTLP_ENDPOINT is absent
Configure AddAspNetCoreInstrumentation for inbound HTTP traces and metrics
Configure AddHttpClientInstrumentation for outbound HTTP traces
Configure AddEntityFrameworkCoreInstrumentation for database traces
Configure AddRuntimeInstrumentation for .NET runtime metrics (GC, threads, heap)
Bridge ILogger to OTel via AddOpenTelemetry() log provider
Verify metrics baseline: http.server.request.duration, http.server.active_requests, .NET runtime metrics
Set resource attributes: service.name=lamp-control-api-csharp, service.version, deployment.environment
Support both grpc and http/protobuf protocols via OTEL_EXPORTER_OTLP_PROTOCOL
Ensure W3C TraceContext + Baggage propagation is enabled
Add/update tests to verify instrumentation wires up correctly
Instrumentation summary
Signal
Mechanism
Type
Traces – Inbound HTTP
AddAspNetCoreInstrumentation
Config only
Traces – Outbound HTTP
AddHttpClientInstrumentation
Config only
Traces – Database (EF Core)
AddEntityFrameworkCoreInstrumentation
Config only
Metrics – HTTP server
AddAspNetCoreInstrumentation
Config only
Metrics – .NET runtime
AddRuntimeInstrumentation
Config only
Logs
OTel ILogger bridge
Config only
Acceptance criteria
OTLP exporters are not registered when OTEL_EXPORTER_OTLP_ENDPOINT is not set
All three pillars (traces, metrics, logs) emit data when collector is configured
Existing tests continue to pass
Overview
Implement the OpenTelemetry integration for the C# (ASP.NET Core + EF Core) service as specified in
src/csharp/adr/008-opentelemetry.md.Parent issue: #14
Tasks
OpenTelemetry.Extensions.Hosting,OpenTelemetry.Instrumentation.AspNetCore,OpenTelemetry.Instrumentation.Http,OpenTelemetry.Instrumentation.EntityFrameworkCore,OpenTelemetry.Instrumentation.Runtime,OpenTelemetry.Exporter.OpenTelemetryProtocol)Program.csviaAddOpenTelemetry()— OTLP exporters MUST NOT be registered whenOTEL_EXPORTER_OTLP_ENDPOINTis absentAddAspNetCoreInstrumentationfor inbound HTTP traces and metricsAddHttpClientInstrumentationfor outbound HTTP tracesAddEntityFrameworkCoreInstrumentationfor database tracesAddRuntimeInstrumentationfor .NET runtime metrics (GC, threads, heap)ILoggerto OTel viaAddOpenTelemetry()log providerhttp.server.request.duration,http.server.active_requests, .NET runtime metricsservice.name=lamp-control-api-csharp,service.version,deployment.environmentgrpcandhttp/protobufprotocols viaOTEL_EXPORTER_OTLP_PROTOCOLInstrumentation summary
AddAspNetCoreInstrumentationAddHttpClientInstrumentationAddEntityFrameworkCoreInstrumentationAddAspNetCoreInstrumentationAddRuntimeInstrumentationILoggerbridgeAcceptance criteria
OTEL_EXPORTER_OTLP_ENDPOINTis not set