Skip to content

Commit

Permalink
Fix failing test cases
Browse files Browse the repository at this point in the history
These test cases started failing after a fix for the handling of empty
metric collection cycles was added to the core repo.

Fixes open-telemetry#2032
  • Loading branch information
ocelotl committed Nov 3, 2023
1 parent 657d502 commit 28f70a8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 0ef76a5cc39626f783416ca75e43556e2bb2739d
CORE_REPO_SHA: d054dff47d2da663a39b9656d106c3d15f344269

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,7 @@ def test_no_metric_for_websockets(self):
self.send_input({"type": "websocket.receive", "text": "ping"})
self.send_input({"type": "websocket.disconnect"})
self.get_all_output()
metrics_list = self.memory_metrics_reader.get_metrics_data()
self.assertEqual(
len(metrics_list.resource_metrics[0].scope_metrics), 0
)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())


class TestAsgiAttributes(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,4 @@ def test_metric_uninstrument(self):
self.assertEqual(len(metrics), 1)
CeleryInstrumentor().uninstrument()

metrics = self.get_metrics()
self.assertEqual(len(metrics), 1)

for metric in metrics:
for point in list(metric.data.data_points):
self.assertEqual(point.count, 1)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def test_metrics_one_connection(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
self.assert_pool_idle_used_expected(
Expand All @@ -78,8 +77,7 @@ def test_metrics_without_pool_name(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
self.assert_pool_idle_used_expected(
Expand All @@ -100,8 +98,7 @@ def test_metrics_two_connections(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
with engine.connect():
Expand All @@ -122,8 +119,7 @@ def test_metrics_connections(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
with engine.connect():
Expand Down Expand Up @@ -156,5 +152,4 @@ def test_metric_uninstrument(self):

engine.connect()

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,18 @@ def test_metric_uninstrument(self):
metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 3)

self.assertEqual(
metrics[0].data.data_points[0].sum, 1
)
self.assertEqual(
metrics[1].data.data_points[0].sum, 0
)
self.assertEqual(
metrics[2].data.data_points[0].sum, 6
)

URLLibInstrumentor().uninstrument()
with request.urlopen(self.URL):
metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 3)

for metric in metrics:
for point in list(metric.data.data_points):
self.assertEqual(point.count, 1)
self.assertIsNone(
self.memory_metrics_reader.get_metrics_data()
)

0 comments on commit 28f70a8

Please sign in to comment.