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 celery and urllib tests #2170

Merged
merged 2 commits into from
Feb 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_0.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150
CORE_REPO_SHA: e98af82ff0ebe7e687fda265093aa576cd9ba80f

jobs:
instrumentations-0:
2 changes: 1 addition & 1 deletion .github/workflows/instrumentations_1.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150
CORE_REPO_SHA: e98af82ff0ebe7e687fda265093aa576cd9ba80f

jobs:
instrumentations-1:
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: d829e375202d0106d45d7a2441409be82086b423
CORE_REPO_SHA: e98af82ff0ebe7e687fda265093aa576cd9ba80f

jobs:
misc:
Original file line number Diff line number Diff line change
@@ -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
@@ -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,
)