Skip to content

Commit

Permalink
Fix celery and urllib tests (#2170)
Browse files Browse the repository at this point in the history
* Update core SHA

Fixes #2173

* Fix celery and urllib tests

Fixes #2164
  • Loading branch information
ocelotl authored Feb 12, 2024
1 parent 8fd2105 commit d167ef7
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_0.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: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150
CORE_REPO_SHA: e98af82ff0ebe7e687fda265093aa576cd9ba80f

jobs:
instrumentations-0:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_1.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: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150
CORE_REPO_SHA: e98af82ff0ebe7e687fda265093aa576cd9ba80f

jobs:
instrumentations-1:
Expand Down
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: d829e375202d0106d45d7a2441409be82086b423
CORE_REPO_SHA: e98af82ff0ebe7e687fda265093aa576cd9ba80f

jobs:
misc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,44 @@ def test_basic_metric(self):

def test_metric_uninstrument(self):
CeleryInstrumentor().instrument()
metrics = self.get_metrics()
self.assertEqual(len(metrics), 1)

self.get_metrics()
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
.bucket_counts[1]
),
1,
)

self.get_metrics()
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
.bucket_counts[1]
),
2,
)

CeleryInstrumentor().uninstrument()

self.assertIsNone(self.memory_metrics_reader.get_metrics_data())
self.get_metrics()
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
.bucket_counts[1]
),
2,
)
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,147 @@ def test_basic_metric_request_not_empty(self):
)
def test_metric_uninstrument(self):
with request.urlopen(self.URL):
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)
self.assertEqual(
len(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics
)
),
3,
)

self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
.bucket_counts[1]
),
1,
)
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[1]
.data.data_points[0]
.bucket_counts[0]
),
1,
)
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[2]
.data.data_points[0]
.bucket_counts[2]
),
1,
)

with request.urlopen(self.URL):

self.assertEqual(
len(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics
)
),
3,
)

self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
.bucket_counts[1]
),
2,
)
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[1]
.data.data_points[0]
.bucket_counts[0]
),
2,
)
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[2]
.data.data_points[0]
.bucket_counts[2]
),
2,
)

URLLibInstrumentor().uninstrument()

with request.urlopen(self.URL):

self.assertEqual(
len(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics
)
),
3,
)

URLLibInstrumentor().uninstrument()
with request.urlopen(self.URL):
self.assertIsNone(
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
.bucket_counts[1]
),
2,
)
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
)
.resource_metrics[0]
.scope_metrics[0]
.metrics[1]
.data.data_points[0]
.bucket_counts[0]
),
2,
)
self.assertEqual(
(
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics[2]
.data.data_points[0]
.bucket_counts[2]
),
2,
)

0 comments on commit d167ef7

Please sign in to comment.