opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

[docs-metrics] Show AddView API using delegate

Open CodeBlanch opened this issue 10 months ago • 7 comments

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.

CodeBlanch avatar Apr 19 '24 18:04 CodeBlanch

hey @CodeBlanch! I love to work on this but I don't know how to start.

devc007 avatar May 03 '24 07:05 devc007

@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 the View 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

CodeBlanch avatar May 03 '24 16:05 CodeBlanch

Hi @CodeBlanch, if this issue is not yet picked up, can I work on this?

geekrypter avatar Jul 11 '24 22:07 geekrypter

Hi @CodeBlanch, if this issue is not yet picked up, can I work on this?

Yes please.

cijothomas avatar Jul 12 '24 15:07 cijothomas