Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Elastic.OpenTelemetry" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience"/>
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery"/>
Expand Down
21 changes: 11 additions & 10 deletions src/Elastic.Documentation.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
logging.IncludeScopes = true;
});

_ = builder.Services.AddOpenTelemetry()
_ = builder.Services.AddElasticOpenTelemetry()
.WithMetrics(metrics =>
{
_ = metrics.AddAspNetCoreInstrumentation()
Expand Down Expand Up @@ -79,17 +79,18 @@ private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builde
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

if (useOtlpExporter)
if (!useOtlpExporter)
return builder;

// Configure delta temporality for Elasticsearch compatibility
// See: https://www.elastic.co/docs/reference/opentelemetry/compatibility/limitations#histograms-in-delta-temporality-only
_ = builder.Services.Configure<MetricReaderOptions>(options =>
{
// Configure delta temporality for Elasticsearch compatibility
// See: https://www.elastic.co/docs/reference/opentelemetry/compatibility/limitations#histograms-in-delta-temporality-only
_ = builder.Services.Configure<MetricReaderOptions>(options =>
{
options.TemporalityPreference = MetricReaderTemporalityPreference.Delta;
});
options.TemporalityPreference = MetricReaderTemporalityPreference.Delta;
});

_ = builder.Services.AddOpenTelemetry().UseOtlpExporter();
Copy link
Contributor

@cotti cotti Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a new OTLP Exporter, breaking integration testing (and I'd assume live).

The reason it creates a new one is that an implicit default ElasticOpenTelemetryOptions has its SkipOtlpExporter set to false. Also, this starts a new OpenTelemetry service which is already defined in the beginning of ConfigureOpenTelemetry, is this wanted?


_ = builder.Services.AddOpenTelemetry().UseOtlpExporter();
}

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
Expand Down
Loading