Skip to content

Commit 6ad4cf7

Browse files
authored
Merge branch 'main' into cleanup-suppress
2 parents 7de7508 + 9afaf26 commit 6ad4cf7

File tree

6 files changed

+55
-19
lines changed

6 files changed

+55
-19
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Consolidate instrumentation suppression mechanisms and fix bug in httpx instrumentation
1515
([#2061](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2061))
1616

17+
### Fixed
18+
19+
- `opentelemetry-instrumentation-urllib`/`opentelemetry-instrumentation-urllib3` Fix metric descriptions to match semantic conventions
20+
([#1959]((https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1959))
21+
1722
## Version 1.21.0/0.42b0 (2023-11-01)
1823

1924
### Added
@@ -33,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3338
([#1980](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1980))
3439
- `opentelemetry-resource-detector-azure` Using new Cloud Resource ID attribute.
3540
([#1976](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1976))
41+
- Do not collect `system.network.connections` by default on macOS which was causing exceptions in metrics collection.
42+
([#2008](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2008))
3643

3744
## Version 1.20.0/0.41b0 (2023-09-01)
3845

@@ -1396,6 +1403,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13961403
- `opentelemetry-ext-wsgi` Updates for core library changes
13971404
- `opentelemetry-ext-http-requests` Updates for core library changes
13981405

1406+
- `Added support for PyPy3` Initial release
1407+
## [#1033](https://github.com/open-telemetryopentelemetry-python-contrib/issues/1033)
1408+
13991409
## Version 0.1a0 (2019-09-30)
14001410

14011411
### Added

instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777

7878
import gc
7979
import os
80+
import sys
81+
import logging
8082
import threading
8183
from platform import python_implementation
8284
from typing import Collection, Dict, Iterable, List, Optional
@@ -91,6 +93,9 @@
9193
from opentelemetry.metrics import CallbackOptions, Observation, get_meter
9294
from opentelemetry.sdk.util import get_dict_as_key
9395

96+
_logger = logging.getLogger(__name__)
97+
98+
9499
_DEFAULT_CONFIG = {
95100
"system.cpu.time": ["idle", "user", "system", "irq"],
96101
"system.cpu.utilization": ["idle", "user", "system", "irq"],
@@ -115,6 +120,10 @@
115120
"process.runtime.context_switches": ["involuntary", "voluntary"],
116121
}
117122

123+
if sys.platform == "darwin":
124+
# see https://github.com/giampaolo/psutil/issues/1219
125+
_DEFAULT_CONFIG.pop("system.network.connections")
126+
118127

119128
class SystemMetricsInstrumentor(BaseInstrumentor):
120129
def __init__(
@@ -352,12 +361,18 @@ def _instrument(self, **kwargs):
352361
)
353362

354363
if "process.runtime.gc_count" in self._config:
355-
self._meter.create_observable_counter(
356-
name=f"process.runtime.{self._python_implementation}.gc_count",
357-
callbacks=[self._get_runtime_gc_count],
358-
description=f"Runtime {self._python_implementation} GC count",
359-
unit="bytes",
360-
)
364+
if self._python_implementation == "pypy":
365+
_logger.warning(
366+
"The process.runtime.gc_count metric won't be collected because the interpreter is PyPy"
367+
)
368+
else:
369+
self._meter.create_observable_counter(
370+
name=f"process.runtime.{self._python_implementation}.gc_count",
371+
callbacks=[self._get_runtime_gc_count],
372+
description=f"Runtime {self._python_implementation} GC count",
373+
unit="bytes",
374+
)
375+
361376

362377
if "process.runtime.thread_count" in self._config:
363378
self._meter.create_observable_up_down_counter(

instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from collections import namedtuple
1818
from platform import python_implementation
19-
from unittest import mock
19+
from unittest import mock, skipIf
2020

2121
from opentelemetry.sdk.metrics import MeterProvider
2222
from opentelemetry.sdk.metrics.export import InMemoryMetricReader
@@ -97,7 +97,6 @@ def test_system_metrics_instrument(self):
9797
for scope_metrics in resource_metrics.scope_metrics:
9898
for metric in scope_metrics.metrics:
9999
metric_names.append(metric.name)
100-
self.assertEqual(len(metric_names), 21)
101100

102101
observer_names = [
103102
"system.cpu.time",
@@ -117,11 +116,16 @@ def test_system_metrics_instrument(self):
117116
"system.thread_count",
118117
f"process.runtime.{self.implementation}.memory",
119118
f"process.runtime.{self.implementation}.cpu_time",
120-
f"process.runtime.{self.implementation}.gc_count",
121119
f"process.runtime.{self.implementation}.thread_count",
122120
f"process.runtime.{self.implementation}.context_switches",
123121
f"process.runtime.{self.implementation}.cpu.utilization",
124122
]
123+
124+
if self.implementation == "pypy":
125+
self.assertEqual(len(metric_names), 20)
126+
else:
127+
self.assertEqual(len(metric_names), 21)
128+
observer_names.append(f"process.runtime.{self.implementation}.gc_count",)
125129

126130
for observer in metric_names:
127131
self.assertIn(observer, observer_names)
@@ -131,11 +135,13 @@ def test_runtime_metrics_instrument(self):
131135
runtime_config = {
132136
"process.runtime.memory": ["rss", "vms"],
133137
"process.runtime.cpu.time": ["user", "system"],
134-
"process.runtime.gc_count": None,
135138
"process.runtime.thread_count": None,
136139
"process.runtime.cpu.utilization": None,
137140
"process.runtime.context_switches": ["involuntary", "voluntary"],
138141
}
142+
143+
if self.implementation != "pypy":
144+
runtime_config["process.runtime.gc_count"] = None
139145

140146
reader = InMemoryMetricReader()
141147
meter_provider = MeterProvider(metric_readers=[reader])
@@ -147,17 +153,21 @@ def test_runtime_metrics_instrument(self):
147153
for scope_metrics in resource_metrics.scope_metrics:
148154
for metric in scope_metrics.metrics:
149155
metric_names.append(metric.name)
150-
self.assertEqual(len(metric_names), 6)
151156

152157
observer_names = [
153158
f"process.runtime.{self.implementation}.memory",
154159
f"process.runtime.{self.implementation}.cpu_time",
155-
f"process.runtime.{self.implementation}.gc_count",
156160
f"process.runtime.{self.implementation}.thread_count",
157161
f"process.runtime.{self.implementation}.context_switches",
158162
f"process.runtime.{self.implementation}.cpu.utilization",
159163
]
160164

165+
if self.implementation == "pypy":
166+
self.assertEqual(len(metric_names), 5)
167+
else:
168+
self.assertEqual(len(metric_names), 6)
169+
observer_names.append(f"process.runtime.{self.implementation}.gc_count")
170+
161171
for observer in metric_names:
162172
self.assertIn(observer, observer_names)
163173
observer_names.remove(observer)
@@ -781,6 +791,7 @@ def test_runtime_cpu_time(self, mock_process_cpu_times):
781791
)
782792

783793
@mock.patch("gc.get_count")
794+
@skipIf(python_implementation().lower() == "pypy", "not supported for pypy")
784795
def test_runtime_get_count(self, mock_gc_get_count):
785796
mock_gc_get_count.configure_mock(**{"return_value": (1, 2, 3)})
786797

instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,17 @@ def _create_client_histograms(meter) -> Dict[str, Histogram]:
299299
MetricInstruments.HTTP_CLIENT_DURATION: meter.create_histogram(
300300
name=MetricInstruments.HTTP_CLIENT_DURATION,
301301
unit="ms",
302-
description="measures the duration outbound HTTP requests",
302+
description="Measures the duration of outbound HTTP requests.",
303303
),
304304
MetricInstruments.HTTP_CLIENT_REQUEST_SIZE: meter.create_histogram(
305305
name=MetricInstruments.HTTP_CLIENT_REQUEST_SIZE,
306306
unit="By",
307-
description="measures the size of HTTP request messages (compressed)",
307+
description="Measures the size of HTTP request messages.",
308308
),
309309
MetricInstruments.HTTP_CLIENT_RESPONSE_SIZE: meter.create_histogram(
310310
name=MetricInstruments.HTTP_CLIENT_RESPONSE_SIZE,
311311
unit="By",
312-
description="measures the size of HTTP response messages (compressed)",
312+
description="Measures the size of HTTP response messages.",
313313
),
314314
}
315315

instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,17 @@ def _instrument(self, **kwargs):
180180
duration_histogram = meter.create_histogram(
181181
name=MetricInstruments.HTTP_CLIENT_DURATION,
182182
unit="ms",
183-
description="measures the duration outbound HTTP requests",
183+
description="Measures the duration of outbound HTTP requests.",
184184
)
185185
request_size_histogram = meter.create_histogram(
186186
name=MetricInstruments.HTTP_CLIENT_REQUEST_SIZE,
187187
unit="By",
188-
description="measures the size of HTTP request messages (compressed)",
188+
description="Measures the size of HTTP request messages.",
189189
)
190190
response_size_histogram = meter.create_histogram(
191191
name=MetricInstruments.HTTP_CLIENT_RESPONSE_SIZE,
192192
unit="By",
193-
description="measures the size of HTTP response messages (compressed)",
193+
description="Measures the size of HTTP response messages.",
194194
)
195195

196196
_instrument(

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ envlist =
194194

195195
; opentelemetry-instrumentation-system-metrics
196196
py3{6,7,8,9,10,11}-test-instrumentation-system-metrics
197-
; instrumentation-system-metrics intentionally excluded from pypy3
197+
pypy3-test-instrumentation-system-metrics
198198

199199
; opentelemetry-instrumentation-tornado
200200
py3{7,8,9,10,11}-test-instrumentation-tornado

0 commit comments

Comments
 (0)