Skip to content

Commit 439defc

Browse files
authored
Merge branch 'main' into patch-1
2 parents 05b0ad7 + 1bd9ec6 commit 439defc

File tree

17 files changed

+148
-33
lines changed

17 files changed

+148
-33
lines changed

.github/workflows/fossa.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: FOSSA scanning
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
fossa:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
17+
- uses: fossas/fossa-action@93a52ecf7c3ac7eb40f5de77fd69b1a19524de94 # v1.5.0
18+
with:
19+
api-key: ${{secrets.FOSSA_API_KEY}}
20+
team: OpenTelemetry

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- prometheus-exporter: fix labels out of place for data points with different
11+
attribute sets
12+
([#4413](https://github.com/open-telemetry/opentelemetry-python/pull/4413))
13+
- Type indent parameter in to_json
14+
([#4402](https://github.com/open-telemetry/opentelemetry-python/pull/4402))
1015
- Tolerates exceptions when loading resource detectors via `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS`
1116
([#4373](https://github.com/open-telemetry/opentelemetry-python/pull/4373))
1217
- Disconnect gRPC client stub when shutting down `OTLPSpanExporter`
1318
([#4370](https://github.com/open-telemetry/opentelemetry-python/pull/4370))
1419
- opentelemetry-sdk: fix OTLP exporting of Histograms with explicit buckets advisory
1520
([#4434](https://github.com/open-telemetry/opentelemetry-python/pull/4434))
21+
- opentelemetry-exporter-otlp-proto-grpc: better dependency version range for Python 3.13
22+
([#4444](https://github.com/open-telemetry/opentelemetry-python/pull/4444))
23+
- opentelemetry-exporter-opencensus: better dependency version range for Python 3.13
24+
([#4444](https://github.com/open-telemetry/opentelemetry-python/pull/4444))
25+
- Updated `tracecontext-integration-test` gitref to `d782773b2cf2fa4afd6a80a93b289d8a74ca894d`
26+
([#4448](https://github.com/open-telemetry/opentelemetry-python/pull/4448))
27+
- Make `trace_api.use_span()` record `BaseException` as well as `Exception`
28+
([#4406](https://github.com/open-telemetry/opentelemetry-python/pull/4406))
1629

1730
## Version 1.30.0/0.51b0 (2025-02-03)
1831

exporter/opentelemetry-exporter-opencensus/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ classifiers = [
2929
"Typing :: Typed",
3030
]
3131
dependencies = [
32-
"grpcio >= 1.0.0, < 2.0.0",
32+
"grpcio >= 1.63.2, < 2.0.0; python_version < '3.13'",
33+
"grpcio >= 1.66.2, < 2.0.0; python_version >= '3.13'",
3334
"opencensus-proto >= 0.1.0, < 1.0.0",
3435
"opentelemetry-api >= 1.31.0.dev",
3536
"opentelemetry-sdk >= 1.15",

exporter/opentelemetry-exporter-otlp-proto-grpc/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ classifiers = [
3030
dependencies = [
3131
"Deprecated >= 1.2.6",
3232
"googleapis-common-protos ~= 1.52",
33-
"grpcio >= 1.63.2, < 2.0.0",
33+
"grpcio >= 1.63.2, < 2.0.0; python_version < '3.13'",
34+
"grpcio >= 1.66.2, < 2.0.0; python_version >= '3.13'",
3435
"opentelemetry-api ~= 1.15",
3536
"opentelemetry-proto == 1.31.0.dev",
3637
"opentelemetry-sdk ~= 1.31.0.dev",

exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,14 @@ def _translate_to_prometheus(
224224
metrics.append(metric)
225225

226226
for metric in metrics:
227-
label_valuess = []
227+
label_values_data_points = []
228+
label_keys_data_points = []
228229
values = []
229230

230-
pre_metric_family_ids = []
231+
per_metric_family_ids = []
231232

232233
metric_name = sanitize_full_name(metric.name)
233-
234234
metric_description = metric.description or ""
235-
236235
metric_unit = map_unit(metric.unit)
237236

238237
for number_data_point in metric.data.data_points:
@@ -243,7 +242,7 @@ def _translate_to_prometheus(
243242
label_keys.append(sanitize_attribute(key))
244243
label_values.append(self._check_value(value))
245244

246-
pre_metric_family_ids.append(
245+
per_metric_family_ids.append(
247246
"|".join(
248247
[
249248
metric_name,
@@ -254,7 +253,8 @@ def _translate_to_prometheus(
254253
)
255254
)
256255

257-
label_valuess.append(label_values)
256+
label_values_data_points.append(label_values)
257+
label_keys_data_points.append(label_keys)
258258
if isinstance(number_data_point, HistogramDataPoint):
259259
values.append(
260260
{
@@ -268,8 +268,11 @@ def _translate_to_prometheus(
268268
else:
269269
values.append(number_data_point.value)
270270

271-
for pre_metric_family_id, label_values, value in zip(
272-
pre_metric_family_ids, label_valuess, values
271+
for per_metric_family_id, label_keys, label_values, value in zip(
272+
per_metric_family_ids,
273+
label_keys_data_points,
274+
label_values_data_points,
275+
values,
273276
):
274277
is_non_monotonic_sum = (
275278
isinstance(metric.data, Sum)
@@ -291,7 +294,7 @@ def _translate_to_prometheus(
291294
and not should_convert_sum_to_gauge
292295
):
293296
metric_family_id = "|".join(
294-
[pre_metric_family_id, CounterMetricFamily.__name__]
297+
[per_metric_family_id, CounterMetricFamily.__name__]
295298
)
296299

297300
if metric_family_id not in metric_family_id_metric_family:
@@ -311,7 +314,7 @@ def _translate_to_prometheus(
311314
or should_convert_sum_to_gauge
312315
):
313316
metric_family_id = "|".join(
314-
[pre_metric_family_id, GaugeMetricFamily.__name__]
317+
[per_metric_family_id, GaugeMetricFamily.__name__]
315318
)
316319

317320
if (
@@ -331,7 +334,7 @@ def _translate_to_prometheus(
331334
].add_metric(labels=label_values, value=value)
332335
elif isinstance(metric.data, Histogram):
333336
metric_family_id = "|".join(
334-
[pre_metric_family_id, HistogramMetricFamily.__name__]
337+
[per_metric_family_id, HistogramMetricFamily.__name__]
335338
)
336339

337340
if (

exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,59 @@ def test_semconv(self):
638638
"""
639639
),
640640
)
641+
642+
def test_multiple_data_points_with_different_label_sets(self):
643+
hist_point_1 = HistogramDataPoint(
644+
attributes={"http_target": "/foobar", "net_host_port": 8080},
645+
start_time_unix_nano=1641946016139533244,
646+
time_unix_nano=1641946016139533244,
647+
count=6,
648+
sum=579.0,
649+
bucket_counts=[1, 3, 2],
650+
explicit_bounds=[123.0, 456.0],
651+
min=1,
652+
max=457,
653+
)
654+
hist_point_2 = HistogramDataPoint(
655+
attributes={"net_host_port": 8080},
656+
start_time_unix_nano=1641946016139533245,
657+
time_unix_nano=1641946016139533245,
658+
count=7,
659+
sum=579.0,
660+
bucket_counts=[1, 3, 3],
661+
explicit_bounds=[123.0, 456.0],
662+
min=1,
663+
max=457,
664+
)
665+
666+
metric = Metric(
667+
name="http.server.request.duration",
668+
description="test multiple label sets",
669+
unit="s",
670+
data=Histogram(
671+
data_points=[hist_point_1, hist_point_2],
672+
aggregation_temporality=AggregationTemporality.CUMULATIVE,
673+
),
674+
)
675+
676+
self.verify_text_format(
677+
metric,
678+
dedent(
679+
"""\
680+
# HELP http_server_request_duration_seconds test multiple label sets
681+
# TYPE http_server_request_duration_seconds histogram
682+
http_server_request_duration_seconds_bucket{http_target="/foobar",le="123.0",net_host_port="8080"} 1.0
683+
http_server_request_duration_seconds_bucket{http_target="/foobar",le="456.0",net_host_port="8080"} 4.0
684+
http_server_request_duration_seconds_bucket{http_target="/foobar",le="+Inf",net_host_port="8080"} 6.0
685+
http_server_request_duration_seconds_count{http_target="/foobar",net_host_port="8080"} 6.0
686+
http_server_request_duration_seconds_sum{http_target="/foobar",net_host_port="8080"} 579.0
687+
# HELP http_server_request_duration_seconds test multiple label sets
688+
# TYPE http_server_request_duration_seconds histogram
689+
http_server_request_duration_seconds_bucket{le="123.0",net_host_port="8080"} 1.0
690+
http_server_request_duration_seconds_bucket{le="456.0",net_host_port="8080"} 4.0
691+
http_server_request_duration_seconds_bucket{le="+Inf",net_host_port="8080"} 7.0
692+
http_server_request_duration_seconds_count{net_host_port="8080"} 7.0
693+
http_server_request_duration_seconds_sum{net_host_port="8080"} 579.0
694+
"""
695+
),
696+
)

opentelemetry-api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies = [
3030
"Deprecated >= 1.2.6",
3131
# FIXME This should be able to be removed after 3.12 is released if there is a reliable API
3232
# in importlib.metadata.
33-
"importlib-metadata >= 6.0, <= 8.5.0",
33+
"importlib-metadata >= 6.0, < 8.7.0",
3434
]
3535
dynamic = [
3636
"version",

opentelemetry-api/src/opentelemetry/trace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def use_span(
590590
finally:
591591
context_api.detach(token)
592592

593-
except Exception as exc: # pylint: disable=broad-exception-caught
593+
except BaseException as exc: # pylint: disable=broad-exception-caught
594594
if isinstance(span, Span) and span.is_recording():
595595
# Record the exception as an event
596596
if record_exception:

opentelemetry-api/test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
asgiref==3.7.2
22
Deprecated==1.2.14
3-
importlib-metadata==8.5.0
3+
importlib-metadata==8.5.0 ; python_version < "3.9"
4+
importlib-metadata==8.6.1 ; python_version >= "3.9"
45
iniconfig==2.0.0
56
packaging==24.0
67
pluggy==1.5.0

opentelemetry-api/tests/trace/test_globals.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ class TestUseSpanException(Exception):
133133

134134
self.assertEqual(test_span.recorded_exception, exception)
135135

136+
def test_use_span_base_exception(self):
137+
class TestUseSpanBaseException(BaseException):
138+
pass
139+
140+
test_span = SpanTest(trace.INVALID_SPAN_CONTEXT)
141+
exception = TestUseSpanBaseException("test exception")
142+
with self.assertRaises(TestUseSpanBaseException):
143+
with trace.use_span(test_span):
144+
raise exception
145+
146+
self.assertEqual(test_span.recorded_exception, exception)
147+
136148
def test_use_span_set_status(self):
137149
class TestUseSpanException(Exception):
138150
pass

0 commit comments

Comments
 (0)