Correlate Microsoft SQL Server queries with .NET traces
Skip step 1 if you've already instrumented your .NET application.
- If your .NET application is uninstrumented, instrument it first:
- If you plan to use the
OpenTelemetry.AutoInstrumentationNuGet package (otel-dotnet-autoinstrumentation), make sure that you use its latest version, which is currently 1.12.0. - Follow the steps to instrument your .NET application.
- Add these environment variables to the OTLP exporter for the .NET application:
OTEL_EXPORTER_OTLP_INSECURE:"true"OTEL_EXPORTER_OTLP_PROTOCOL:"grpc"OTEL_RESOURCE_ATTRIBUTES: prependservice.name=your-app-nameto your current values. For example,"service.name=your-app-name, deployment.environment=environment-name"OTEL_EXPORTER_OTLP_ENDPOINT:"http://your-otel-collector-endpoint:4317"Note: Port 4317 is for OTLP over gRPC whereas port 4318 is for OTLP over HTTP/JSON.OTEL_DOTNET_EXPERIMENTAL_SQLCLIENT_ENABLE_TRACE_CONTEXT_PROPAGATION:"true"
apiVersion: apps/v1 kind: Deployment spec: selector: matchLabels: app: your-application template: spec: containers: - name: myapp env: - name: SPLUNK_OTEL_AGENT valueFrom: fieldRef: fieldPath: status.hostIP - name: OTEL_EXPORTER_OTLP_INSECURE value: "true" - name: OTEL_EXPORTER_OTLP_PROTOCOL value: "grpc" - name: OTEL_RESOURCE_ATTRIBUTES value: "service.name=your-app-name, deployment.environment=environment-name" - name: OTEL_SERVICE_NAME value: "service-name" - name: OTEL_EXPORTER_OTLP_ENDPOINT value: "http://$(SPLUNK_OTEL_AGENT):4318" - name: OTEL_DOTNET_EXPERIMENTAL_SQLCLIENT_ENABLE_TRACE_CONTEXT_PROPAGATION value: "true"
- If you plan to use the
- In your .csproj file, use the latest version (1.11.0) of the Splunk
OpenTelemetry.AutoInstrumentationlibrary:<PackageReference Include="Splunk.OpenTelemetry.AutoInstrumentation" Version="1.11.0" /> - Restart your application.
You can now view database query correlation with APM traces from the APM trace view or the Query details pane in the Database Monitoring Overview.