Skip to content

Commit bbb541c

Browse files
Merge branch 'main' into mypy-to-pyright
2 parents acd53e3 + e01fa0c commit bbb541c

File tree

47 files changed

+831
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+831
-214
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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Add type annotations to context's attach & detach
11+
([#4346](https://github.com/open-telemetry/opentelemetry-python/pull/4346))
12+
- Fix OTLP encoders missing instrumentation scope schema url and attributes
13+
([#4359](https://github.com/open-telemetry/opentelemetry-python/pull/4359))
14+
- prometheus-exporter: fix labels out of place for data points with different
15+
attribute sets
16+
([#4413](https://github.com/open-telemetry/opentelemetry-python/pull/4413))
17+
- Type indent parameter in to_json
18+
([#4402](https://github.com/open-telemetry/opentelemetry-python/pull/4402))
1019
- Tolerates exceptions when loading resource detectors via `OTEL_EXPERIMENTAL_RESOURCE_DETECTORS`
1120
([#4373](https://github.com/open-telemetry/opentelemetry-python/pull/4373))
21+
- Disconnect gRPC client stub when shutting down `OTLPSpanExporter`
22+
([#4370](https://github.com/open-telemetry/opentelemetry-python/pull/4370))
23+
- opentelemetry-sdk: fix OTLP exporting of Histograms with explicit buckets advisory
24+
([#4434](https://github.com/open-telemetry/opentelemetry-python/pull/4434))
25+
- opentelemetry-exporter-otlp-proto-grpc: better dependency version range for Python 3.13
26+
([#4444](https://github.com/open-telemetry/opentelemetry-python/pull/4444))
27+
- opentelemetry-exporter-opencensus: better dependency version range for Python 3.13
28+
([#4444](https://github.com/open-telemetry/opentelemetry-python/pull/4444))
29+
- Updated `tracecontext-integration-test` gitref to `d782773b2cf2fa4afd6a80a93b289d8a74ca894d`
30+
([#4448](https://github.com/open-telemetry/opentelemetry-python/pull/4448))
31+
- Make `trace_api.use_span()` record `BaseException` as well as `Exception`
32+
([#4406](https://github.com/open-telemetry/opentelemetry-python/pull/4406))
33+
- Fix env var error message for TraceLimits/SpanLimits
34+
([#4458](https://github.com/open-telemetry/opentelemetry-python/pull/4458))
1235

1336
## Version 1.30.0/0.51b0 (2025-02-03)
1437

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Meeting notes are available as a public [Google doc](https://docs.google.com/doc
9797

9898
Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)):
9999

100-
- [Emídio Neto](https://github.com/emdneto), Zenvia
100+
- [Emídio Neto](https://github.com/emdneto), PicPay
101101
- [Jeremy Voss](https://github.com/jeremydvoss), Microsoft
102102
- [Owais Lone](https://github.com/owais), Splunk
103103
- [Pablo Collins](https://github.com/pmcollins), Splunk

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@
150150
"py:class",
151151
"opentelemetry.sdk.metrics._internal.aggregation._Aggregation",
152152
),
153+
(
154+
"py:class",
155+
"_contextvars.Token",
156+
),
153157
]
154158

155159
# Add any paths that contain templates here, relative to this directory.

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-common/src/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def _encode_instrumentation_scope(
6161
return PB2InstrumentationScope(
6262
name=instrumentation_scope.name,
6363
version=instrumentation_scope.version,
64+
attributes=_encode_attributes(instrumentation_scope.attributes),
6465
)
6566

6667

exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def _encode_resource_logs(batch: Sequence[LogData]) -> List[ResourceLogs]:
8282
ScopeLogs(
8383
scope=(_encode_instrumentation_scope(sdk_instrumentation)),
8484
log_records=pb2_logs,
85+
schema_url=sdk_instrumentation.schema_url
86+
if sdk_instrumentation
87+
else None,
8588
)
8689
)
8790
pb2_resource_logs.append(

exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/metrics_encoder/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from __future__ import annotations
15+
1416
import logging
1517
from os import environ
1618
from typing import Dict, List
1719

1820
from opentelemetry.exporter.otlp.proto.common._internal import (
1921
_encode_attributes,
22+
_encode_instrumentation_scope,
2023
_encode_span_id,
2124
_encode_trace_id,
2225
)
2326
from opentelemetry.proto.collector.metrics.v1.metrics_service_pb2 import (
2427
ExportMetricsServiceRequest,
2528
)
26-
from opentelemetry.proto.common.v1.common_pb2 import InstrumentationScope
2729
from opentelemetry.proto.metrics.v1 import metrics_pb2 as pb2
2830
from opentelemetry.proto.resource.v1.resource_pb2 import (
2931
Resource as PB2Resource,
@@ -66,8 +68,9 @@
6668
class OTLPMetricExporterMixin:
6769
def _common_configuration(
6870
self,
69-
preferred_temporality: Dict[type, AggregationTemporality] = None,
70-
preferred_aggregation: Dict[type, Aggregation] = None,
71+
preferred_temporality: dict[type, AggregationTemporality]
72+
| None = None,
73+
preferred_aggregation: dict[type, Aggregation] | None = None,
7174
) -> None:
7275
MetricExporter.__init__(
7376
self,
@@ -219,10 +222,8 @@ def _encode_resource_metrics(resource_metrics, resource_metrics_dict):
219222
# there is no need to check for existing instrumentation scopes
220223
# here.
221224
pb2_scope_metrics = pb2.ScopeMetrics(
222-
scope=InstrumentationScope(
223-
name=instrumentation_scope.name,
224-
version=instrumentation_scope.version,
225-
)
225+
scope=_encode_instrumentation_scope(instrumentation_scope),
226+
schema_url=instrumentation_scope.schema_url,
226227
)
227228

228229
scope_metrics_dict[instrumentation_scope] = pb2_scope_metrics

exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/trace_encoder/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def _encode_resource_spans(
8989
PB2ScopeSpans(
9090
scope=(_encode_instrumentation_scope(sdk_instrumentation)),
9191
spans=pb2_spans,
92+
schema_url=sdk_instrumentation.schema_url
93+
if sdk_instrumentation
94+
else None,
9295
)
9396
)
9497
pb2_resource_spans.append(

exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,54 @@ def _get_sdk_log_data() -> List[LogData]:
178178
),
179179
)
180180

181-
return [log1, log2, log3, log4, log5]
181+
log6 = LogData(
182+
log_record=SDKLogRecord(
183+
timestamp=1644650584292683022,
184+
observed_timestamp=1644650584292683022,
185+
trace_id=212592107417388365804938480559624925522,
186+
span_id=6077757853989569222,
187+
trace_flags=TraceFlags(0x01),
188+
severity_text="ERROR",
189+
severity_number=SeverityNumber.ERROR,
190+
body="This instrumentation scope has a schema url",
191+
resource=SDKResource(
192+
{"first_resource": "value"},
193+
"resource_schema_url",
194+
),
195+
attributes={"filename": "model.py", "func_name": "run_method"},
196+
),
197+
instrumentation_scope=InstrumentationScope(
198+
"scope_with_url",
199+
"scope_with_url_version",
200+
"instrumentation_schema_url",
201+
),
202+
)
203+
204+
log7 = LogData(
205+
log_record=SDKLogRecord(
206+
timestamp=1644650584292683033,
207+
observed_timestamp=1644650584292683033,
208+
trace_id=212592107417388365804938480559624925533,
209+
span_id=6077757853989569233,
210+
trace_flags=TraceFlags(0x01),
211+
severity_text="FATAL",
212+
severity_number=SeverityNumber.FATAL,
213+
body="This instrumentation scope has a schema url and attributes",
214+
resource=SDKResource(
215+
{"first_resource": "value"},
216+
"resource_schema_url",
217+
),
218+
attributes={"filename": "model.py", "func_name": "run_method"},
219+
),
220+
instrumentation_scope=InstrumentationScope(
221+
"scope_with_attributes",
222+
"scope_with_attributes_version",
223+
"instrumentation_schema_url",
224+
{"one": 1, "two": "2"},
225+
),
226+
)
227+
228+
return [log1, log2, log3, log4, log5, log6, log7]
182229

183230
def get_test_logs(
184231
self,
@@ -253,6 +300,71 @@ def get_test_logs(
253300
)
254301
],
255302
),
303+
PB2ScopeLogs(
304+
scope=PB2InstrumentationScope(
305+
name="scope_with_url",
306+
version="scope_with_url_version",
307+
),
308+
schema_url="instrumentation_schema_url",
309+
log_records=[
310+
PB2LogRecord(
311+
time_unix_nano=1644650584292683022,
312+
observed_time_unix_nano=1644650584292683022,
313+
trace_id=_encode_trace_id(
314+
212592107417388365804938480559624925522
315+
),
316+
span_id=_encode_span_id(
317+
6077757853989569222
318+
),
319+
flags=int(TraceFlags(0x01)),
320+
severity_text="ERROR",
321+
severity_number=SeverityNumber.ERROR.value,
322+
body=_encode_value(
323+
"This instrumentation scope has a schema url"
324+
),
325+
attributes=_encode_attributes(
326+
{
327+
"filename": "model.py",
328+
"func_name": "run_method",
329+
}
330+
),
331+
)
332+
],
333+
),
334+
PB2ScopeLogs(
335+
scope=PB2InstrumentationScope(
336+
name="scope_with_attributes",
337+
version="scope_with_attributes_version",
338+
attributes=_encode_attributes(
339+
{"one": 1, "two": "2"}
340+
),
341+
),
342+
schema_url="instrumentation_schema_url",
343+
log_records=[
344+
PB2LogRecord(
345+
time_unix_nano=1644650584292683033,
346+
observed_time_unix_nano=1644650584292683033,
347+
trace_id=_encode_trace_id(
348+
212592107417388365804938480559624925533
349+
),
350+
span_id=_encode_span_id(
351+
6077757853989569233
352+
),
353+
flags=int(TraceFlags(0x01)),
354+
severity_text="FATAL",
355+
severity_number=SeverityNumber.FATAL.value,
356+
body=_encode_value(
357+
"This instrumentation scope has a schema url and attributes"
358+
),
359+
attributes=_encode_attributes(
360+
{
361+
"filename": "model.py",
362+
"func_name": "run_method",
363+
}
364+
),
365+
)
366+
],
367+
),
256368
],
257369
schema_url="resource_schema_url",
258370
),

0 commit comments

Comments
 (0)