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

fix: add attributes to get_meter wrapper #4364

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Maxi91f
Copy link

@Maxi91f Maxi91f commented Dec 17, 2024

Description

On #4015 the attributes parameter was added for meter providers, and all interfaces were updated, but the global wrapper was not updated with the new API.

Since the function doc says that "This function is a convenience wrapper for opentelemetry.metrics.MeterProvider.get_meter." I expect this to have the same parameters.

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?

First I started a aws-otel-collector docker container for testing
Then I run this minimal script.

from opentelemetry import metrics
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader

exporter = OTLPMetricExporter(endpoint="localhost:4317", insecure=True)
metric_reader = PeriodicExportingMetricReader(exporter)
metrics.set_meter_provider(MeterProvider(metric_readers=[metric_reader]))
meter = metrics.get_meter("test", attributes={})

Without this PR this fails with

TypeError: get_meter() got an unexpected keyword argument 'attributes'

Now is working as expected.

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

@Maxi91f Maxi91f requested a review from a team as a code owner December 17, 2024 23:32
Copy link

linux-foundation-easycla bot commented Dec 17, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@Maxi91f Maxi91f closed this Dec 17, 2024
@Maxi91f Maxi91f reopened this Dec 17, 2024
@Maxi91f
Copy link
Author

Maxi91f commented Dec 17, 2024

Hi!

First time contributor here.

I didn't knew if I needed to change the changelog or not. LMK if needed.

Also, I couldn't find a specific test just for this specific interface, or any API in fact, so I didn't wanted to add a new test. But LMK if it's needed.

Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

@Maxi91f welcome! please add a changelog entry and also add a test in opentelemetry-api/tests/metrics/test_meter_provider.py since it doesn't look this helper is tested

@Maxi91f
Copy link
Author

Maxi91f commented Dec 18, 2024

Thanks for the response @xrmx ! I'm doing it.

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.

2 participants