Skip to content

How to disable OpenTelemetry #5627

Answered by cijothomas
mkaszub asked this question in Q&A
May 17, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

All metrics (traces too) are explicit opt-in - i.e metrics must be enabled by using AddMeter() API. If you want to only enable metrics in one environment, but not in another, the easiest way is by controlling AddMeter() calls. For example, you can keep the list of meter names in config file (like appsettings.json), and call AddMeter() using the names from the config. By controlling the config for each environment, you can control the metrics itself.

if (app.Environment.IsDevelopment())
{

}
else
{
AddMeter("My-meter");
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mkaszub
Comment options

@cijothomas
Comment options

Answer selected by mkaszub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants