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 #3695: add attributes to get_meter fn and InstrumentationScope #4015

Merged
merged 18 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3965](https://github.com/open-telemetry/opentelemetry-python/pull/3965))
- Validate links at span creation
([#3991](https://github.com/open-telemetry/opentelemetry-python/pull/3991))
- Fix to add attributes field in get_meter and instrumentationScope
vivek378521 marked this conversation as resolved.
Show resolved Hide resolved
([#3695](https://github.com/open-telemetry/opentelemetry-python/issues/3695))
vivek378521 marked this conversation as resolved.
Show resolved Hide resolved

## Version 1.25.0/0.46b0 (2024-05-30)

Expand Down Expand Up @@ -1601,6 +1603,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3778](https://github.com/open-telemetry/opentelemetry-python/pull/3778))
- Fix license field in pyproject.toml files
([#3803](https://github.com/open-telemetry/opentelemetry-python/pull/3803))
- Fix to add attributes field in get_meter and instrumentationScope
([#3695](https://github.com/open-telemetry/opentelemetry-python/issues/3695))

35 changes: 35 additions & 0 deletions opentelemetry-sdk/tests/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,41 @@ def test_get_meter_duplicate(self):
self.assertIs(meter1, meter2)
self.assertIsNot(meter1, meter3)

def test_get_meter_attributes_duplicate(self):
vivek378521 marked this conversation as resolved.
Show resolved Hide resolved
"""
Subsequent calls to `MeterProvider.get_meter` with the same arguments
should return the same `Meter` instance.
"""
mp = MeterProvider()
meter1 = mp.get_meter(
"name",
version="version",
schema_url="schema_url",
attributes={"key": "value", "key2": 5, "key3": "value3"},
)
meter2 = mp.get_meter(
"name",
version="version",
schema_url="schema_url",
attributes={"key": "value", "key2": 5, "key3": "value3"},
)
meter3 = mp.get_meter(
"name2",
version="version",
schema_url="schema_url",
)
meter4 = mp.get_meter(
"name",
version="version",
schema_url="schema_url",
attributes={"key": "value", "key2": 5, "key3": "value4"},
)
self.assertIs(meter1, meter2)
self.assertIsNot(meter1, meter3)
self.assertTrue(
meter3._instrumentation_scope > meter4._instrumentation_scope
)

def test_shutdown(self):

mock_metric_reader_0 = MagicMock(
Expand Down