opentelemetry-dotnet
opentelemetry-dotnet copied to clipboard
[docs-metrics] Show AddView API using delegate
See: https://github.com/open-telemetry/opentelemetry-dotnet/pull/5554#issuecomment-2066915358
We should have some sort of advanced documentation which shows the AddView API which exposes a callback/delegate. The important part is strong wording that it isn't recommended to be used due to failures being swallowed at runtime and only written to self-diagnostic logging.
hey @CodeBlanch! I love to work on this but I don't know how to start.
@devc007
Let's add a section in here: https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/docs/metrics/customizing-the-sdk/README.md
Something at the bottom. Like "Advanced scenarios" maybe?
Advanced scenarios
View configuration using delegate
The following code snippet shows how to
use advanced selection criteria to customize the metrics output by the SDK. This requires
the user to provide a Func<Instrument, MetricStreamConfiguration>
which offers
more flexibility in filtering the instruments to which the View
should be
applied.
[!CAUTION] It is not recommended to use the delegate overload of the
AddView
API because it is not evaluated until the process is running and a measurement is recorded. The OpenTelemetry SDK will NOT throw exceptions when running. Any mistakes made using this overload will cause theView
to be ignored. Exceptions will be written to the internal logging only. Use this API with caution and only when the more simple overloads cannot be used instead.
[Content goes here]
For the content you could start by just restoring what we removed: https://github.com/open-telemetry/opentelemetry-dotnet/pull/5554/files#diff-425a8f436c341c05d10b76aac12d1295330116295a3556990ddf3d2bdaffdaecL43-L53
Hi @CodeBlanch, if this issue is not yet picked up, can I work on this?
Hi @CodeBlanch, if this issue is not yet picked up, can I work on this?
Yes please.