Skip to content

Instantly share code, notes, and snippets.

@joaopgrassi
Last active October 12, 2021 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaopgrassi/5a4e424ed42af5fccada37a3fb694144 to your computer and use it in GitHub Desktop.
Save joaopgrassi/5a4e424ed42af5fccada37a3fb694144 to your computer and use it in GitHub Desktop.
OTel .NET metrics SDK questions

Questions about the .NET OTel metrics SDK

Same instrument names, different meters

Spec says:

Different Meters MUST be treated as separate namespaces. The names of the Instruments under one Meter SHOULD NOT interfere with Instruments under another Meter.

Usecase: I have an app that has a request_count instrument to count requests. I consume an external library that also has a request_count under a meter that it controls internally. I want to get metrics from both my app and from the external library.

Another example:

Meter                                        Instrument                        Unit
My.Database.Instrumentation                  response_size                     1 (= number of rows returned)
My.HttpClient.Instrumentation                response_size                     Byte

Actual behavior: The instrument from the external library is ignored, even though it is from a different meter.

Sample: https://github.com/dynatrace-oss-contrib/opentelemetry-dotnet/blob/metrics_tryout/docs/metrics/getting-started/Program.cs

Want to use a view to sum two instruments

Usecase: I have an app that has a request_count instrument to count requests. I consume a library that also has a request_count under a meter that it controls internally. I add both meters with AddMeter on my MeterProvider. I want to create a view, to sum up both counters from the two meters

Actual behavior: It is not adding two counters together

The view name is saved into a dictionary, and upon the second instrument, the same view name is checked and the instrument is dropped.

Sample: https://github.com/dynatrace-oss-contrib/opentelemetry-dotnet/blob/metrics_tryout/docs/metrics/getting-started/Program.cs (Uncoment the AddView code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment