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

OTLP exporter options separate out MetricReader options #2717

Conversation

alanwest
Copy link
Member

@alanwest alanwest commented Dec 2, 2021

Related to #2552.

This separates out options meant for configuring the MetricReader when using the AddOltpExporter extension method.

I think this PR is a better alternative to #2716. However unlike #2716 it does not attempt to add support the for the OTEL_EXPORTER_OTLP_METRICS_* environment variables. This could be a follow up PR.

If folks like this approach, I can port it to the Console and In-memory metric exporters.

@alanwest alanwest requested a review from a team December 2, 2021 03:03
@codecov
Copy link

codecov bot commented Dec 2, 2021

Codecov Report

Merging #2717 (c7fdd42) into main (4f40d74) will decrease coverage by 0.53%.
The diff coverage is 62.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2717      +/-   ##
==========================================
- Coverage   84.41%   83.88%   -0.54%     
==========================================
  Files         252      253       +1     
  Lines        8893     8910      +17     
==========================================
- Hits         7507     7474      -33     
- Misses       1386     1436      +50     
Impacted Files Coverage Δ
...orter.OpenTelemetryProtocol/OtlpExporterOptions.cs 100.00% <ø> (ø)
...nTelemetryProtocol/OtlpMetricExporterExtensions.cs 64.28% <57.14%> (-35.72%) ⬇️
src/OpenTelemetry/Metrics/MetricReaderOptions.cs 75.00% <75.00%> (ø)
...Telemetry/Metrics/PeriodicExportingMetricReader.cs 0.00% <0.00%> (-78.73%) ⬇️
...OpenTelemetry/Metrics/BaseExportingMetricReader.cs 83.33% <0.00%> (-1.67%) ⬇️

Copy link
Member

@joaopgrassi joaopgrassi left a comment

Choose a reason for hiding this comment

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

I think this approach is great!

@alanwest alanwest marked this pull request as draft December 2, 2021 20:11
@alanwest
Copy link
Member Author

alanwest commented Dec 2, 2021

@CodeBlanch requested I convert this to draft for now. He's working on another approach and we'd like to give people a chance to compare.

Copy link
Contributor

@mic-max mic-max left a comment

Choose a reason for hiding this comment

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

I'm liking this option

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2022

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Feb 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2022

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Feb 9, 2022
@alanwest alanwest reopened this Feb 9, 2022
@alanwest alanwest marked this pull request as ready for review February 9, 2022 05:22
@alanwest alanwest removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Feb 16, 2022
@alanwest alanwest requested a review from cijothomas February 16, 2022 00:35
@alanwest alanwest added this to the 1.2.0 milestone Feb 16, 2022
/// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns>
public static MeterProviderBuilder AddOtlpExporter(
this MeterProviderBuilder builder,
Action<OtlpExporterOptions, MetricReaderOptions> configureExporterAndMetricReader)
Copy link
Member

Choose a reason for hiding this comment

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

AddOtlpExporter(Action<OtlpExporterOptions> configureExporter, Action <MetricReaderOptions> configureMetricReader)

^ would this be more easy to use?

Copy link
Member Author

@alanwest alanwest Feb 18, 2022

Choose a reason for hiding this comment

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

Maybe? It depends on who you ask 😄. I do not personally have a strong preference either way.

But... I think I may have landed on this solution in part because we're anticipating following this pattern eventually with traces as well. If I recall, the one issue I encountered was that we have

public static TracerProviderBuilder AddOtlpExporter(
    this TracerProviderBuilder builder,
    Action<OtlpExporterOptions> configure = null)

Because of the default parameter for configure we can't introduce the following because the methods would be ambiguous if someone were just calling this with no parameters AddOtlpExporter() <- this now does not compile.

public static TracerProviderBuilder AddOtlpExporter(
    this TracerProviderBuilder builder,
    Action<OtlpExporterOptions> configure = null,
    Action<ProcessorOptions> configureProcessor = null)

... though this was a while ago, so I may not have my head on straight about this 😄 - I'll try it out and refresh my memory.

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.

var metricExporter = new OtlpMetricExporter(options);
var metricExporter = new OtlpMetricExporter(exporterOptions);

if (metricReaderOptions.MetricReaderType == (MetricReaderType)(-1))
Copy link
Member

Choose a reason for hiding this comment

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

lets take this as a follow up to decide

  1. What should be the MetricReaderType default
  2. Would that be same for all exporters (Console , OTLP). Or do we want separate defaults.

Not blocking this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

@alanwest alanwest merged commit f234829 into open-telemetry:main Feb 18, 2022
@alanwest alanwest deleted the alanwest/otlp-separate-out-metric-reader-options branch February 18, 2022 20:02
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