Skip to content

feat(sdk): implement exporter metrics#4976

Open
anuraaga wants to merge 14 commits intoopen-telemetry:mainfrom
anuraaga:exporter-metrics
Open

feat(sdk): implement exporter metrics#4976
anuraaga wants to merge 14 commits intoopen-telemetry:mainfrom
anuraaga:exporter-metrics

Conversation

@anuraaga
Copy link
Copy Markdown
Contributor

Description

I am helping to implement SDK internal metrics

https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics/

This implements the exporter metrics.

Similar PR in JS: open-telemetry/opentelemetry-js#6480

/cc @xrmx to help with review. As there are many exporters, this is a pretty big one

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@anuraaga anuraaga requested a review from a team as a code owner March 13, 2026 08:26
@xrmx xrmx moved this to Ready for review in Python PR digest Mar 19, 2026
Copy link
Copy Markdown
Contributor Author

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

I have applied the cleanups except for the method change since I couldn't see how to do it and make things significantly cleaner.

I will merge main after #5015

@anuraaga
Copy link
Copy Markdown
Contributor Author

anuraaga commented Apr 2, 2026

Now fails with this which is also somewhat unrelated to this PR. #5030 (review)

self = <opentelemetry.exporter.otlp.proto.http.metric_exporter.OTLPMetricExporter object at 0x1090b3860>, metrics_data = 'foo', timeout_millis = 10000, kwargs = {}
num_items = 0

    def export(
        self,
        metrics_data: MetricsData,
        timeout_millis: Optional[float] = 10000,
        **kwargs,
    ) -> MetricExportResult:
        if self._shutdown:
            _logger.warning("Exporter already shutdown, ignoring batch")
            return MetricExportResult.FAILURE

        num_items = 0
>       for resource_metrics in metrics_data.resource_metrics:
E       AttributeError: 'str' object has no attribute 'resource_metrics'

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py:349: AttributeError

Caused by https://github.com/open-telemetry/opentelemetry-python/blob/main/exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py#L929

@anuraaga
Copy link
Copy Markdown
Contributor Author

anuraaga commented Apr 9, 2026

@xrmx Thanks - think this is finally ready (test failure looks flaky)

@xrmx xrmx requested review from herin049 and lzchen April 13, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

4 participants