Skip to content

Commit f8486ec

Browse files
committed
wip
1 parent 1bf999e commit f8486ec

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Unreleased
99

1010
- Add metric instrumentation for celery
11-
([#1679](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1679/files))
11+
([#1679](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1679))
1212

1313
### Added
1414

instrumentation/opentelemetry-instrumentation-celery/tests/test_metrics.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ def tearDown(self):
3030
self._thread.join()
3131

3232
def get_metrics(self):
33-
CeleryInstrumentor().instrument()
3433
result = task_add.delay(1, 2)
3534

3635
timeout = time.time() + 60 * 1 # 1 minutes from now
3736
while not result.ready():
3837
if time.time() > timeout:
3938
break
4039
time.sleep(0.05)
41-
CeleryInstrumentor().uninstrument()
4240
resource_metrics = (
4341
self.memory_metrics_reader.get_metrics_data().resource_metrics
4442
)
@@ -88,10 +86,12 @@ def assert_metric_expected(
8886
)
8987

9088
def test_basic_metric(self):
89+
CeleryInstrumentor().instrument()
9190
start_time = default_timer()
9291
task_runtime_estimated = (default_timer() - start_time) * 1000
9392

9493
metrics = self.get_metrics()
94+
CeleryInstrumentor().uninstrument()
9595
self.assertEqual(len(metrics), 1)
9696

9797
task_runtime = metrics[0]
@@ -106,3 +106,16 @@ def test_basic_metric(self):
106106
},
107107
est_delta=200,
108108
)
109+
110+
def test_metric_uninstrument(self):
111+
CeleryInstrumentor().instrument()
112+
metrics = self.get_metrics()
113+
self.assertEqual(len(metrics), 1)
114+
CeleryInstrumentor().uninstrument()
115+
116+
metrics = self.get_metrics()
117+
self.assertEqual(len(metrics), 1)
118+
119+
for metric in metrics:
120+
for point in list(metric.data.data_points):
121+
self.assertEqual(point.count, 1)

0 commit comments

Comments
 (0)