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

Initial Metric API/SDK framing #2034

Merged
merged 9 commits into from
May 5, 2021

Conversation

victlu
Copy link
Contributor

@victlu victlu commented May 4, 2021

Setting up initial framing for Metrics API and SDK based on currently available specs.

@victlu victlu requested a review from a team May 4, 2021 22:32
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.

LGTM overall, I've put two blocking comments regarding the API/SDK separation and the namespace (Metrics vs. Metric).

@codecov
Copy link

codecov bot commented May 5, 2021

Codecov Report

Merging #2034 (c1ad21f) into metrics (c5a8535) will increase coverage by 2.68%.
The diff coverage is 50.92%.

Impacted file tree graph

@@             Coverage Diff             @@
##           metrics    #2034      +/-   ##
===========================================
+ Coverage    79.85%   82.54%   +2.68%     
===========================================
  Files          203      205       +2     
  Lines         6498     6461      -37     
===========================================
+ Hits          5189     5333     +144     
+ Misses        1309     1128     -181     
Impacted Files Coverage Δ
src/System.Diagnostics.Metrics.Temp/Histogram.cs 0.00% <0.00%> (ø)
src/System.Diagnostics.Metrics.Temp/Measurement.cs 0.00% <0.00%> (ø)
...System.Diagnostics.Metrics.Temp/ObservableGauge.cs 0.00% <0.00%> (ø)
...iagnostics.Metrics.Temp/ObservableUpDownCounter.cs 0.00% <0.00%> (ø)
src/System.Diagnostics.Metrics.Temp/Meter.cs 17.56% <14.08%> (+17.56%) ⬆️
...c/System.Diagnostics.Metrics.Temp/MeterListener.cs 55.17% <55.17%> (ø)
src/System.Diagnostics.Metrics.Temp/Counter.cs 60.00% <57.14%> (+60.00%) ⬆️
...m.Diagnostics.Metrics.Temp/ObservableInstrument.cs 66.66% <66.66%> (ø)
src/System.Diagnostics.Metrics.Temp/Instrument.cs 75.00% <75.00%> (ø)
src/System.Diagnostics.Metrics.Temp/InstrumentT.cs 76.92% <76.92%> (ø)
... and 13 more


namespace OpenTelemetry.Metrics
{
public class MetricProvider : IDisposable
Copy link
Member

Choose a reason for hiding this comment

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

This is different from my understanding, I guess:

  1. The name will be MeterProvider.
  2. It will derive from OpenTelemetry.BaseProvider.
  3. We might want to move something to the API? (e.g. considering if someone wants to implement their own SDK) @cijothomas might have better idea here.

Copy link
Member

Choose a reason for hiding this comment

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

We can follow similar approach as tracing. Will iterate over several PRs. :)

private BuildOptions options;
private ConcurrentDictionary<Meter, int> meters;
private MeterListener listener;
private CancellationTokenSource cts;
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
private CancellationTokenSource cts;
private readonly CancellationTokenSource cts;


public Meter GetMeter(string name, string version)
{
var meter = new Meter(name, version);
Copy link
Member

Choose a reason for hiding this comment

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

Might need some concurrency support here.

Copy link
Member

Choose a reason for hiding this comment

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

For example, if the same name is already used, we could end up creating a Meter via .NET API but fail to update the this.meters dictionary.

If creating a dangling meter doesn't have any negative impact, it is probably fine.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/new_api.md#get-a-meter

It is unspecified whether or under which conditions the same or different Meter instances are returned from this functions.

We might need to define the behavior for OpenTelemetry .NET?


public bool Verbose { get; set; } = true;

public int ObservationPeriodMilliseconds { get; set; } = 1000;
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker, I think we need to call out that this is not observation period, instead, it is the delay/sleep between two observations.
Let's say each observation callback takes 800ms, and ObservationPeriodMilliseconds is 200ms, we will end up with pushes at every 1000ms (instead of every 200ms) approximately.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

And this

int scheduledDelayMilliseconds = DefaultScheduledDelayMilliseconds,

Note that in OTel.NET it was called "Milliseconds" instead of "Millis" since the former is more idiomatic to .NET (and the later is more Java-ish).

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.

LGTM as the initial skeleton.
I've left some comments about the actual implementation but these can be addressed in other PRs.

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.

Thanks Victor for getting this started!
LGTM.
We can iterate on this to address issues.

@cijothomas cijothomas merged commit c8d8b8c into open-telemetry:metrics May 5, 2021
@victlu victlu deleted the otel-metrics branch May 5, 2021 16:51
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.

3 participants