Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs-metrics] Show AddView API using delegate #5557

Open
CodeBlanch opened this issue Apr 19, 2024 · 2 comments
Open

[docs-metrics] Show AddView API using delegate #5557

CodeBlanch opened this issue Apr 19, 2024 · 2 comments
Labels
documentation enhancement New feature or request good first issue Good for newcomers help wanted Good for taking. Extra help will be provided by maintainers

Comments

@CodeBlanch
Copy link
Member

See: #5554 (comment)

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 CodeBlanch added enhancement New feature or request help wanted Good for taking. Extra help will be provided by maintainers good first issue Good for newcomers documentation labels Apr 19, 2024
@devc007
Copy link

devc007 commented May 3, 2024

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

@CodeBlanch
Copy link
Member Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation enhancement New feature or request good first issue Good for newcomers help wanted Good for taking. Extra help will be provided by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants