diff --git a/content/en/docs/demo/services/cart.md b/content/en/docs/demo/services/cart.md index 3b87c0646608..350d47f7e519 100644 --- a/content/en/docs/demo/services/cart.md +++ b/content/en/docs/demo/services/cart.md @@ -22,19 +22,22 @@ exporters, and set other options. Configuration of the exporter and resource attributes is performed through environment variables. ```cs -services.AddOpenTelemetry().WithTracing(builder => builder - .ConfigureResource(r => r +Action appResourceBuilder = + resource => resource .AddTelemetrySdk() .AddEnvironmentVariableDetector() - .AddDetector(new DockerResourceDetector()) - ) - .AddRedisInstrumentation( - cartStore.GetConnection(), - options => options.SetVerboseDatabaseStatements = true) - .AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation() - .AddOtlpExporter()); + .AddDetector(new ContainerResourceDetector()); + +builder.Services.AddOpenTelemetry() + .ConfigureResource(appResourceBuilder) + .WithTracing(builder => builder + .AddRedisInstrumentation( + cartStore.GetConnection(), + options => options.SetVerboseDatabaseStatements = true) + .AddAspNetCoreInstrumentation() + .AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation() + .AddOtlpExporter()); ``` ### Add attributes to auto-instrumented spans @@ -76,15 +79,18 @@ call to `AddOpenTelemetry()`. This builder configures desired instrumentation libraries, exporters, etc. ```cs -services.AddOpenTelemetry().WithMetrics(builder => builder - .ConfigureResource(r => r +Action appResourceBuilder = + resource => resource .AddTelemetrySdk() .AddEnvironmentVariableDetector() - .AddDetector(new DockerResourceDetector()) - ) - .AddRuntimeInstrumentation() - .AddAspNetCoreInstrumentation() - .AddOtlpExporter()); + .AddDetector(new ContainerResourceDetector()); + +builder.Services.AddOpenTelemetry() + .ConfigureResource(appResourceBuilder) + .WithMetrics(builder => builder + .AddRuntimeInstrumentation() + .AddAspNetCoreInstrumentation() + .AddOtlpExporter()); ``` ## Logs