Skip to content

Commit 1567f08

Browse files
authored
Merge branch 'main' into improve-baggage
2 parents 654946e + fcb5e21 commit 1567f08

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

.github/workflows/contrib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
uses: open-telemetry/opentelemetry-python-contrib/.github/workflows/core_contrib_test_0.yml@main
1212
with:
1313
CORE_REPO_SHA: ${{ github.sha }}
14-
CONTRIB_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
14+
CONTRIB_REPO_SHA: main

.github/workflows/lint_0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
env:
1313
CORE_REPO_SHA: main
14-
CONTRIB_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
14+
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

1717
jobs:

.github/workflows/misc_0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
env:
1313
CORE_REPO_SHA: main
14-
CONTRIB_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
14+
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

1717
jobs:

.github/workflows/test_0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
env:
1313
CORE_REPO_SHA: main
14-
CONTRIB_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
14+
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

1717
jobs:

.github/workflows/test_1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
env:
1313
CORE_REPO_SHA: main
14-
CONTRIB_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
14+
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

1717
jobs:

CHANGELOG.md

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

88
## Unreleased
99

10+
- Fix user agent in OTLP HTTP metrics exporter
11+
([#4475](https://github.com/open-telemetry/opentelemetry-python/pull/4475))
12+
1013
## Version 1.31.0/0.52b0 (2025-03-12)
1114

1215
- semantic-conventions: Bump to 1.31.0

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
from opentelemetry.exporter.otlp.proto.common.metrics_encoder import (
4141
encode_metrics,
4242
)
43-
from opentelemetry.exporter.otlp.proto.http import Compression
43+
from opentelemetry.exporter.otlp.proto.http import (
44+
_OTLP_HTTP_HEADERS,
45+
Compression,
46+
)
4447
from opentelemetry.proto.collector.metrics.v1.metrics_service_pb2 import ( # noqa: F401
4548
ExportMetricsServiceRequest,
4649
)
@@ -152,9 +155,7 @@ def __init__(
152155
self._compression = compression or _compression_from_env()
153156
self._session = session or requests.Session()
154157
self._session.headers.update(self._headers)
155-
self._session.headers.update(
156-
{"Content-Type": "application/x-protobuf"}
157-
)
158+
self._session.headers.update(_OTLP_HTTP_HEADERS)
158159
if self._compression is not Compression.NoCompression:
159160
self._session.headers.update(
160161
{"Content-Encoding": self._compression.value}

exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
DEFAULT_TIMEOUT,
3333
OTLPMetricExporter,
3434
)
35+
from opentelemetry.exporter.otlp.proto.http.version import __version__
3536
from opentelemetry.sdk.environment_variables import (
3637
OTEL_EXPORTER_OTLP_CERTIFICATE,
3738
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE,
@@ -124,6 +125,15 @@ def test_constructor_default(self):
124125
self.assertIs(exporter._compression, DEFAULT_COMPRESSION)
125126
self.assertEqual(exporter._headers, {})
126127
self.assertIsInstance(exporter._session, Session)
128+
self.assertIn("User-Agent", exporter._session.headers)
129+
self.assertEqual(
130+
exporter._session.headers.get("Content-Type"),
131+
"application/x-protobuf",
132+
)
133+
self.assertEqual(
134+
exporter._session.headers.get("User-Agent"),
135+
"OTel-OTLP-Exporter-Python/" + __version__,
136+
)
127137

128138
@patch.dict(
129139
"os.environ",

0 commit comments

Comments
 (0)