From 621d8b2c30251a504c26418f5c0d1dd535ceb7af Mon Sep 17 00:00:00 2001 From: wasup-yash Date: Fri, 16 Aug 2024 06:32:27 +0530 Subject: [PATCH 1/7] updated for bytes Signed-off-by: wasup-yash --- .../exporter/otlp/proto/common/_internal/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py index 23bc23822c4..65f94771407 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py @@ -75,6 +75,8 @@ def _encode_value(value: Any) -> PB2AnyValue: return PB2AnyValue(int_value=value) if isinstance(value, float): return PB2AnyValue(double_value=value) + if isinstance(value, bytes): + return PB2AnyValue(bytes_value=value) if isinstance(value, Sequence): return PB2AnyValue( array_value=PB2ArrayValue(values=[_encode_value(v) for v in value]) From 95de5e92b2a181984feccc752a4e10702fc7efcc Mon Sep 17 00:00:00 2001 From: wasup-yash Date: Tue, 20 Aug 2024 21:10:51 +0530 Subject: [PATCH 2/7] updated test for otlp bytes Signed-off-by: wasup-yash --- .../tests/test_attribute_encoder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py index 01856611036..be4f58367cc 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py @@ -36,6 +36,7 @@ def test_encode_attributes_all_kinds(self): "greet": ["hola", "bonjour"], # Sequence[str] "data": [1, 2], # Sequence[int] "data_granular": [1.4, 2.4], # Sequence[float] + "binary_data": b'x00\x01\x02' #bytes } ) self.assertEqual( @@ -80,6 +81,10 @@ def test_encode_attributes_all_kinds(self): ) ), ), + PB2AnyValue( + key="binary_data", + value=PB2AnyValue(bytes_value=b'x00\x01\x02'), + ), ], ) From 995d5fcc8278f00e098fbef8b325ec75534b1c8e Mon Sep 17 00:00:00 2001 From: wasup-yash Date: Wed, 21 Aug 2024 09:25:39 +0530 Subject: [PATCH 3/7] nit in tests Signed-off-by: wasup-yash --- .../tests/test_attribute_encoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py index be4f58367cc..c9e188b2b76 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py @@ -81,9 +81,9 @@ def test_encode_attributes_all_kinds(self): ) ), ), - PB2AnyValue( + PB2KeyValue( key="binary_data", - value=PB2AnyValue(bytes_value=b'x00\x01\x02'), + value=PB2AnyValue(bytes_value= b'x00\x01\x02'), ), ], ) From 750180c5a394d808607749dccc0db1d51828cf00 Mon Sep 17 00:00:00 2001 From: wasup-yash Date: Wed, 28 Aug 2024 00:39:07 +0530 Subject: [PATCH 4/7] updated for CHANGELOG.md Signed-off-by: wasup-yash --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93861d2b9dc..b97f6b38f74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#4103](https://github.com/open-telemetry/opentelemetry-python/pull/4103)) - Update semantic conventions to version 1.27.0 ([#4104](https://github.com/open-telemetry/opentelemetry-python/pull/4104)) +- Add support to type bytes for OTLP AnyValue + ([#4128](https://github.com/open-telemetry/opentelemetry-python/pull/4128)) ## Version 1.26.0/0.47b0 (2024-07-25) From 6bd95f8c23a70dc91171148d574a297dcb8873ff Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Wed, 28 Aug 2024 09:42:07 -0700 Subject: [PATCH 5/7] black --- .../tests/test_attribute_encoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py index c9e188b2b76..0c512798de7 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py @@ -36,7 +36,7 @@ def test_encode_attributes_all_kinds(self): "greet": ["hola", "bonjour"], # Sequence[str] "data": [1, 2], # Sequence[int] "data_granular": [1.4, 2.4], # Sequence[float] - "binary_data": b'x00\x01\x02' #bytes + "binary_data": b'x00\x01\x02' # bytes } ) self.assertEqual( @@ -83,7 +83,7 @@ def test_encode_attributes_all_kinds(self): ), PB2KeyValue( key="binary_data", - value=PB2AnyValue(bytes_value= b'x00\x01\x02'), + value=PB2AnyValue(bytes_value=b"x00\x01\x02"), ), ], ) From dfa6e9082f17636c8d82703eb758ee7a36bdbbff Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Wed, 28 Aug 2024 09:48:12 -0700 Subject: [PATCH 6/7] black --- .../tests/test_attribute_encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py index 0c512798de7..c7e4dbc843a 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_attribute_encoder.py @@ -36,7 +36,7 @@ def test_encode_attributes_all_kinds(self): "greet": ["hola", "bonjour"], # Sequence[str] "data": [1, 2], # Sequence[int] "data_granular": [1.4, 2.4], # Sequence[float] - "binary_data": b'x00\x01\x02' # bytes + "binary_data": b"x00\x01\x02", # bytes } ) self.assertEqual( From 5b42a7efc680c5f9e65ec52594bcc876a71dba7f Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Wed, 28 Aug 2024 10:00:15 -0700 Subject: [PATCH 7/7] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com> --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0d9360a745..4a1e279a4cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#4103](https://github.com/open-telemetry/opentelemetry-python/pull/4103)) - Update semantic conventions to version 1.27.0 ([#4104](https://github.com/open-telemetry/opentelemetry-python/pull/4104)) - - Add support to type bytes for OTLP AnyValue ([#4128](https://github.com/open-telemetry/opentelemetry-python/pull/4128)) - Export ExponentialHistogram and ExponentialHistogramDataPoint