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

Make Delta vs Cumulative based purely on Exporter #2142

Merged
merged 1 commit into from
Jul 16, 2021

Conversation

cijothomas
Copy link
Member

@cijothomas cijothomas commented Jul 16, 2021

Changes

  1. Makes Delta vs Cumulative decision tied to exporter. Its an exporter level setting, so all metrics either becomes delta or cumulative.
    Once Views are in, this'd require rework anyway, as views likely would allow per-instrument delta vs cumulative setting.

  2. Modified ConsoleExporter to pick between delta and cumulative, defaulting to delta

Cumulative Console Exporter

using var meterProvider = Sdk.CreateMeterProviderBuilder()
                .AddSource("TestMeter")
                .AddConsoleExporter(options => options.IsDelta = false)
                .Build();

Delta Console Exporter

using var meterProvider = Sdk.CreateMeterProviderBuilder()
                .AddSource("TestMeter")
                .AddConsoleExporter(options => options.IsDelta = true) //default
                .Build();

@cijothomas cijothomas requested review from victlu and a team July 16, 2021 04:06
@codecov
Copy link

codecov bot commented Jul 16, 2021

Codecov Report

Merging #2142 (73df7b2) into metrics (63c28f0) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           metrics    #2142      +/-   ##
===========================================
- Coverage    78.27%   78.24%   -0.03%     
===========================================
  Files          212      212              
  Lines         6632     6634       +2     
===========================================
  Hits          5191     5191              
- Misses        1441     1443       +2     
Impacted Files Coverage Δ
src/OpenTelemetry/Metrics/AggregatorStore.cs 0.00% <0.00%> (ø)
src/OpenTelemetry/Metrics/MeterProviderSdk.cs 0.00% <0.00%> (ø)
...Metrics/MetricAggregators/GaugeMetricAggregator.cs 0.00% <ø> (ø)
...ics/MetricAggregators/HistogramMetricAggregator.cs 0.00% <0.00%> (ø)
...y/Metrics/MetricAggregators/SumMetricAggregator.cs 0.00% <0.00%> (ø)
...trics/MetricAggregators/SummaryMetricAggregator.cs 0.00% <ø> (ø)
...elemetry/Metrics/Processors/PullMetricProcessor.cs 0.00% <0.00%> (ø)
...elemetry/Metrics/Processors/PushMetricProcessor.cs 0.00% <0.00%> (ø)

/// Gets or sets a value indicating whether to export Delta
/// values or not (Cumulative).
/// </summary>
public bool IsDelta { get; set; } = true;
Copy link
Member

Choose a reason for hiding this comment

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

I think a boolean is fine, but just pondering another idea... what if we had an enumeration for AggregationTemporality and this setting was instead

public AggregationTemporality AggregationTemporality { get; set; } = AggregationTemporality.Delta

Also, this brings up an interesting question of defaults. What's the sense from the spec regarding defaults for SDK provided exporters?

Copy link
Member

Choose a reason for hiding this comment

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

+1 with AggregationTemporality

Copy link
Member

Choose a reason for hiding this comment

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

I think defaults to delta makes more sense (for console, delta generates less output). A good topic for the SDK spec :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree. making it in next PR :)

Copy link
Member

@alanwest alanwest left a comment

Choose a reason for hiding this comment

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

LGTM

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.

@cijothomas cijothomas merged commit a572ad8 into metrics Jul 16, 2021
@cijothomas cijothomas deleted the cijothomas/metricdeltaasexporteroption branch July 16, 2021 19:13
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