Skip to content
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

[AzureMonitorDistro] Add LiveMetricsActivityProcessor only when live metrics is enabled #43524

Merged
merged 2 commits into from
Apr 19, 2024
Merged
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 @@ -125,13 +125,18 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui
return true;
})
.AddProcessor<ProfilingSessionTraceProcessor>()
.AddProcessor(sp =>
{
var manager = sp.GetRequiredService<Manager>();
return new LiveMetricsActivityProcessor(manager);
})
.AddAzureMonitorTraceExporter());

builder.Services.ConfigureOpenTelemetryTracerProvider((sp, builder) =>
{
var azureMonitorOptions = sp.GetRequiredService<IOptionsMonitor<AzureMonitorOptions>>().Get(Options.DefaultName);
if (azureMonitorOptions.EnableLiveMetrics)
{
var manager = sp.GetRequiredService<Manager>();
builder.AddProcessor(new LiveMetricsActivityProcessor(manager));
}
});

builder.WithMetrics(b => b
.AddHttpClientAndServerMetrics()
.AddAzureMonitorMetricExporter());
Expand All @@ -141,11 +146,6 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui
logging.AddOpenTelemetry(builderOptions =>
{
builderOptions.IncludeFormattedMessage = true;
builderOptions.AddProcessor(sp =>
{
var manager = sp.GetRequiredService<Manager>();
return new LiveMetricsLogProcessor(manager);
});
});
});

Expand Down Expand Up @@ -178,6 +178,15 @@ public static OpenTelemetryBuilder UseAzureMonitor(this OpenTelemetryBuilder bui
{
loggingOptions.AddAzureMonitorLogExporter(o => azureMonitorOptions.SetValueToExporterOptions(o));
}

if (azureMonitorOptions.EnableLiveMetrics)
{
loggingOptions.AddProcessor(sp =>
{
var manager = sp.GetRequiredService<Manager>();
return new LiveMetricsLogProcessor(manager);
});
}
});

// Register a configuration action so that when
Expand Down
Loading