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

Add README for Metrics #4528

Merged
merged 4 commits into from
May 31, 2023

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented May 30, 2023

Changes

  • Add a README doc that mentions the best practices and common issues when using Metrics

@utpilla utpilla requested review from a team and cijothomas May 30, 2023 23:33
docs/metrics/README.md Outdated Show resolved Hide resolved
docs/metrics/README.md Outdated Show resolved Hide resolved
docs/metrics/README.md Outdated Show resolved Hide resolved
docs/metrics/README.md Outdated Show resolved Hide resolved
docs/metrics/README.md Outdated Show resolved Hide resolved
docs/metrics/README.md Outdated Show resolved Hide resolved
Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments, nothing should be blocking this; but are very important to be added now or a future PR.

@codecov
Copy link

codecov bot commented May 30, 2023

Codecov Report

Merging #4528 (82f2567) into main (a0eb696) will decrease coverage by 0.03%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4528      +/-   ##
==========================================
- Coverage   85.13%   85.11%   -0.03%     
==========================================
  Files         318      318              
  Lines       12620    12620              
==========================================
- Hits        10744    10741       -3     
- Misses       1876     1879       +3     

see 3 files with indirect coverage changes

- Instruments SHOULD only be created once and reused throughout the application
lifetime. This
[example](../../docs/metrics/getting-started-console/Program.cs) shows how an
instrument is created a `static` field and then used in the application. You
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instrument is created a `static` field and then used in the application. You
instrument is created and stored in a `static` field and then used in the application. You

instrument is created a `static` field and then used in the application. You
could also look at this ASP .NET Core
[example](../../examples/AspNetCore/Program.cs) which shows a more Dependency
Injection friendly way of doing this by extracting the `Meter` and an
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which shows a more Dependency Injection friendly way of doing this. -> I think this much is sufficient, to avoid too much details here.

a single MeterProvider is built at application startup, and is disposed of at
application shutdown. For an ASP.NET Core application, use `AddOpenTelemetry`
and `WithMetrics` methods from the `OpenTelemetry.Extensions.Hosting` package
to correctly setup `MeterProvider`. Here's a [sample ASP .NET Core
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sample -> example
ASP .NET -> ASP.NET

and `WithMetrics` methods from the `OpenTelemetry.Extensions.Hosting` package
to correctly setup `MeterProvider`. Here's a [sample ASP .NET Core
app](../../examples/AspNetCore/Program.cs) for reference. For simpler
applications such as Console apps, refer to this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
applications such as Console apps, refer to this
applications such as console apps, refer to this

[doc](../../docs/metrics/customizing-the-sdk/README.md#changing-maximum-metricpoints-per-metricstream)
for more information. The SDK would not process any newer unique key-value
combination that it encounters, once this limit is reached.
- MeterProvider is disposed. You need to ensure that the `MeterProvider`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- MeterProvider is disposed. You need to ensure that the `MeterProvider`
- MeterProvider is disposed incorrectly/earlier than desired. You need to ensure that the `MeterProvider`

to correctly setup `MeterProvider`. Here's a [sample ASP .NET Core
app](../../examples/AspNetCore/Program.cs) for reference. For simpler
applications such as Console apps, refer to this
[example](../../docs/metrics/getting-started-console/Program.cs).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also show asp.net example from controib repo.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@cijothomas cijothomas merged commit 64df5e3 into open-telemetry:main May 31, 2023
@utpilla utpilla deleted the utpilla/Add-Metrics-Readme branch November 3, 2023 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants