Skip to content

Commit

Permalink
Use env var
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Jun 25, 2024
1 parent f53b342 commit 22fc06c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion playground/TestShop/ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.SetExemplarFilter(ExemplarFilterType.TraceBased);
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
Expand Down
2 changes: 2 additions & 0 deletions src/Aspire.Hosting/OtlpConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public static void AddOtlpEnvironment(IResource resource, IConfiguration configu

// Configure trace sampler to send all traces to the dashboard.
context.EnvironmentVariables["OTEL_TRACES_SAMPLER"] = "always_on";
// Configure metrics to include exemplars.
context.EnvironmentVariables["OTEL_METRICS_EXEMPLAR_FILTER"] = "trace_based";
}
}));

Expand Down
5 changes: 5 additions & 0 deletions tests/Aspire.Hosting.Tests/ProjectResourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public async Task AddProjectAddsEnvironmentVariablesAndServiceMetadata()
Assert.Equal("always_on", env.Value);
},
env =>
{
Assert.Equal("OTEL_METRICS_EXEMPLAR_FILTER", env.Key);
Assert.Equal("trace_based", env.Value);
},
env =>
{
Assert.Equal("DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION", env.Key);
Assert.Equal("true", env.Value);
Expand Down

0 comments on commit 22fc06c

Please sign in to comment.