Skip to content

Commit

Permalink
changelog and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxi91f committed Dec 18, 2024
1 parent 63c9ab2 commit 5533b96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- Add `attributes` field in `metrics.get_meter` wrapper function
([#4364](https://github.com/open-telemetry/opentelemetry-python/pull/4364))

## Version 1.29.0/0.50b0 (2024-12-11)

Expand Down
21 changes: 20 additions & 1 deletion opentelemetry-api/tests/metrics/test_meter_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
get_meter_provider,
set_meter_provider,
)
from opentelemetry.metrics._internal import _ProxyMeter, _ProxyMeterProvider
from opentelemetry.metrics._internal import _ProxyMeter, _ProxyMeterProvider, get_meter
from opentelemetry.metrics._internal.instrument import (
_ProxyCounter,
_ProxyGauge,
Expand Down Expand Up @@ -140,6 +140,25 @@ def test_invalid_name(self):
self.assertTrue(isinstance(meter, NoOpMeter))

self.assertEqual(meter.name, None)

def test_get_meter_wrapper(self):
"""
`metrics._internal.get_meter` called with valid parameters and a NoOpMeterProvider
should return a NoOpMeter with the same parameters.
"""

meter = get_meter(
"name",
version = "version",
meter_provider = NoOpMeterProvider(),
schema_url = "schema_url",
attributes = {"key": "value", "key2": 5, "key3": "value3"},
)

self.assertIsInstance(meter, NoOpMeter)
self.assertEqual(meter.name, "name")
self.assertEqual(meter.version, "version")
self.assertEqual(meter.schema_url, "schema_url")


class TestProxy(MetricsGlobalsTest, TestCase):
Expand Down

0 comments on commit 5533b96

Please sign in to comment.