File tree Expand file tree Collapse file tree 8 files changed +23
-9
lines changed
exporter/opentelemetry-exporter-otlp-proto-http
src/opentelemetry/exporter/otlp/proto/http/metric_exporter Expand file tree Collapse file tree 8 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1111
1212env :
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
1717jobs :
Original file line number Diff line number Diff line change 1111
1212env :
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
1717jobs :
Original file line number Diff line number Diff line change 1111
1212env :
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
1717jobs :
Original file line number Diff line number Diff line change 1111
1212env :
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
1717jobs :
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 4040from 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+ )
4447from 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 }
Original file line number Diff line number Diff line change 3232 DEFAULT_TIMEOUT ,
3333 OTLPMetricExporter ,
3434)
35+ from opentelemetry .exporter .otlp .proto .http .version import __version__
3536from 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" ,
You can’t perform that action at this time.
0 commit comments