Skip to content

[feature request] Support disabling self-diagnostics beyond start-up #7054

@martincostello

Description

@martincostello

Package

OpenTelemetry

Is your feature request related to a problem?

I was looking through profiles for an OTel instrumented application of mine, and noticed that code related to self-diagnostics was consistently showing up in the top 5 allocation samples:

Image

This is essentially because SelfDiagnosticsConfigRefresher is running in the background every 10 seconds for the lifetime of the application to see if OTEL_DIAGNOSTICS.json appears/changes to update the configuration:

private async Task Worker(CancellationToken cancellationToken)
{
await Task.Delay(ConfigurationUpdatePeriodMilliSeconds, cancellationToken).ConfigureAwait(false);
while (!cancellationToken.IsCancellationRequested)
{
this.UpdateMemoryMappedFileFromConfiguration();
await Task.Delay(ConfigurationUpdatePeriodMilliSeconds, cancellationToken).ConfigureAwait(false);
}
}

In a production, especially containerised, environment this seems wasteful - if the file didn't exist on start-up, it is unlikely to ever appear, and if it does exist, it's unlikely to be updated.

A way to opt-out of this always-on functionality would provide an efficiency, albeit small, improvement for production environments or when an application is not being actively troubleshooted.

What is the expected behavior?

An opt-in (potentially with intelligent defaults) mechanism to allow the background work to be disabled by the user.

Possible intelligent defaults could include:

  • Only refresh for updates if the file existed on start-up
  • Only refresh for updates by default in debug
  • Only refresh in ASP.NET Core applications if the DOTNET_ENVIRONMENT is Development

Which alternative solutions or features have you considered?

None.

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Labels

enhancementNew feature or requestpkg:OpenTelemetryIssues related to OpenTelemetry NuGet package

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions