-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use new UseOtlpExporter method from the OTEL library #3017
Comments
Currently available in 1.8.0-beta.1 This would be an update to the templates IIUC, specifically the ServiceDefaults project. We should wait until there's a stable release before integrating I think. |
Really the whole point of putting out that beta was for Aspire to take it for a spin and provide feedback 🤣 Please do! Here's the things in 1.8.0-beta.1 which should be of interest to Aspire:
This one didn't make the first beta but will come in the next drop: open-telemetry/opentelemetry-dotnet#5448 |
@CodeBlanch great! I'll try it out to get a sense of how it would impact our experience, thanks. |
OK so yeah, this allows us to simplify the ServiceDefaults code to enable OTLP quite a bit: private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
{
+ builder.Services.AddOpenTelemetry()
+ // Enable OTLP exporter for all telemetry based on defaults and environment variables
+ .UseOtlpExporter();
+ // Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
+ //.WithMetrics(metrics => metrics.AddPrometheusExporter());
- var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
- if (useOtlpExporter)
- {
- builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddOtlpExporter());
- builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter());
- builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter());
- }
- // Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
- // builder.Services.AddOpenTelemetry()
- // .WithMetrics(metrics => metrics.AddPrometheusExporter());
// 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"]))
//{
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}
return builder;
} |
I'll move this to preview.6 as I'm not expecting we're going to get a stable version of the package with this change in time for preview.5 |
@DamianEdwards Does Aspire use something like aspire/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/Extensions.cs Lines 58 to 62 in 93a1efb
...and do it via config: appSettings.Development.json {
"OTEL_TRACES_SAMPLER": "always_on"
} If you wanted to 😄 |
We can set environment variables. cc @JamesNK |
Stable 1.8.0 OTel packages should be on Nuget now. One late change to pay attention to: https://github.com/open-telemetry/opentelemetry-dotnet/blob/fb74013d644d56f44ef89dd57358947bd9f68345/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md?plain=1#L17-L22 The envar key/value for enabling in-memory retry changed for stable. |
Done in #3359 |
FYI I've found a bunch of trim warnings related to this: open-telemetry/opentelemetry-dotnet#5518 (comment) |
open-telemetry/opentelemetry-dotnet#5400
The text was updated successfully, but these errors were encountered: