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 metrics exporter modes #2353

Merged
merged 6 commits into from
Sep 15, 2021

Conversation

reyang
Copy link
Member

@reyang reyang commented Sep 14, 2021

Introduced ExportModes attribute for metric exporters.
With the change, the SDK will throw exception if the user is trying to setup a PeriodicExportingMetricReader with an exporter which only supports pull mode.

PrometheusExporter will look like:

    [AggregationTemporality(AggregationTemporality.Cumulative)]
    [ExportModes(ExportModes.Pull)]
    public class PrometheusExporter : BaseExporter<Metric>
    {
        ...
    }

If someone is doing this:

provider.AddMetricReader(new PeriodicExportingMetricReader(new PrometheusExporter(...)))

an InvalidOperationException("The exporter does not support push mode.") will be thrown.

@reyang reyang requested a review from a team September 14, 2021 21:12
@codecov
Copy link

codecov bot commented Sep 14, 2021

Codecov Report

Merging #2353 (5860327) into main (2df1a62) will decrease coverage by 0.45%.
The diff coverage is 27.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2353      +/-   ##
==========================================
- Coverage   81.08%   80.62%   -0.46%     
==========================================
  Files         228      229       +1     
  Lines        7305     7318      +13     
==========================================
- Hits         5923     5900      -23     
- Misses       1382     1418      +36     
Impacted Files Coverage Δ
src/OpenTelemetry/Metrics/ExportModesAttribute.cs 0.00% <0.00%> (ø)
...Telemetry/Metrics/PeriodicExportingMetricReader.cs 0.00% <0.00%> (ø)
...OpenTelemetry/Metrics/BaseExportingMetricReader.cs 71.42% <45.45%> (-4.77%) ⬇️
...ation.AspNet.TelemetryHttpModule/ActivityHelper.cs 56.14% <0.00%> (-28.08%) ⬇️
src/OpenTelemetry.Api/Context/RuntimeContext.cs 63.15% <0.00%> (-13.16%) ⬇️
...emetry.Api/Context/AsyncLocalRuntimeContextSlot.cs 87.50% <0.00%> (-12.50%) ⬇️
...Zipkin/Implementation/ZipkinExporterEventSource.cs 63.63% <0.00%> (-9.10%) ⬇️
....TelemetryHttpModule/AspNetTelemetryEventSource.cs 23.33% <0.00%> (-6.67%) ⬇️
...ZPages/Implementation/ZPagesExporterEventSource.cs 56.25% <0.00%> (-6.25%) ⬇️
...Telemetry/Internal/SelfDiagnosticsEventListener.cs 96.85% <0.00%> (-0.79%) ⬇️
... and 1 more

@reyang reyang mentioned this pull request Sep 15, 2021
3 tasks
@reyang reyang changed the title Add metrics exporter mode Add metrics exporter modes Sep 15, 2021
@cijothomas cijothomas merged commit 5deeb07 into open-telemetry:main Sep 15, 2021
@reyang reyang deleted the reyang/metrics-export-mode branch September 16, 2021 02:18
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