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 log message #2414

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def shutdown(self):

if not metric_reader_result:
_logger.warning(
"MetricReader {metric_reader} failed to shutdown"
"MetricReader %s failed to shutdown", metric_reader
)

overall_result = overall_result and metric_reader_result
Expand Down
16 changes: 13 additions & 3 deletions opentelemetry-sdk/tests/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from logging import WARNING
from unittest import TestCase
from unittest.mock import Mock, patch
from unittest.mock import MagicMock, Mock, patch

from opentelemetry.sdk._metrics import Meter, MeterProvider
from opentelemetry.sdk._metrics.instrument import (
Expand Down Expand Up @@ -92,14 +92,24 @@ def test_get_meter_duplicate(self):

def test_shutdown(self):

mock_metric_reader_0 = Mock(**{"shutdown.return_value": False})
mock_metric_reader_0 = MagicMock(
**{
"shutdown.return_value": False,
"__str__.return_value": "mock_metric_reader_0",
}
)
mock_metric_reader_1 = Mock(**{"shutdown.return_value": True})

meter_provider = MeterProvider(
metric_readers=[mock_metric_reader_0, mock_metric_reader_1]
)

self.assertFalse(meter_provider.shutdown())
with self.assertLogs(level=WARNING) as log:
self.assertFalse(meter_provider.shutdown())
self.assertEqual(
log.records[0].getMessage(),
"MetricReader mock_metric_reader_0 failed to shutdown",
)
mock_metric_reader_0.shutdown.assert_called_once()
mock_metric_reader_1.shutdown.assert_called_once()

Expand Down