From 40df300a41c5e18108e45d2e41d0f8324c58c971 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Mon, 5 Jun 2023 13:33:44 -0700 Subject: [PATCH 01/20] Added dropped_attributes_count to the exporter --- .../otlp/proto/common/_internal/_log_encoder/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py index 7c135d90baf..47c254033bc 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py @@ -47,6 +47,7 @@ def _encode_log(log_data: LogData) -> PB2LogRecord: body=_encode_value(log_data.log_record.body), severity_text=log_data.log_record.severity_text, attributes=_encode_attributes(log_data.log_record.attributes), + dropped_attributes_count=log_data.log_record.dropped_attributes, severity_number=log_data.log_record.severity_number.value, ) From e1931196d1f36f9f25f7f872049f2df370062ba2 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Wed, 7 Jun 2023 15:26:06 -0700 Subject: [PATCH 02/20] Test for dropped_attributes_count --- .../tests/test_log_encoder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 1cd86b2833e..3b6c35c7a19 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -51,6 +51,11 @@ def test_encode(self): sdk_logs, expected_encoding = self.get_test_logs() self.assertEqual(encode_logs(sdk_logs), expected_encoding) + def test_dropped_attributes_count(self): + sdk_logs, _ = self.get_test_logs() + encoded_logs = str(encode_logs(sdk_logs)) + self.assertTrue("dropped_attributes_count" in encoded_logs) + @staticmethod def _get_sdk_log_data() -> List[LogData]: log1 = LogData( From 4b072b0fd870819ed4ac5fb0fd4bb24a8c461dfc Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Fri, 9 Jun 2023 22:56:48 -0700 Subject: [PATCH 03/20] Added check for dropped_attributes --- .../otlp/proto/common/_internal/_log_encoder/__init__.py | 2 +- .../tests/test_log_encoder.py | 1 + .../src/opentelemetry/sdk/_logs/_internal/__init__.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py index 47c254033bc..ba8e85ff136 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py @@ -70,7 +70,7 @@ def _encode_resource_logs(batch: Sequence[LogData]) -> List[ResourceLogs]: scope_logs.append( ScopeLogs( scope=(_encode_instrumentation_scope(sdk_instrumentation)), - log_records=pb2_logs, + log_records=pb2_logs ) ) pb2_resource_logs.append( diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 3b6c35c7a19..c35ced93bee 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -53,6 +53,7 @@ def test_encode(self): def test_dropped_attributes_count(self): sdk_logs, _ = self.get_test_logs() + self.assertTrue(hasattr(sdk_logs[0].log_record, "dropped_attributes")) encoded_logs = str(encode_logs(sdk_logs)) self.assertTrue("dropped_attributes_count" in encoded_logs) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py index 7410138067c..5c9a202b8d7 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py @@ -203,6 +203,7 @@ def to_json(self, indent=4) -> str: "attributes": dict(self.attributes) if bool(self.attributes) else None, + "dropped_attributes": repr(self.dropped_attributes), "timestamp": ns_to_iso_str(self.timestamp), "trace_id": f"0x{format_trace_id(self.trace_id)}" if self.trace_id is not None From 7e602cf254e7faefb3f2779c81d056b3cb1276c0 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Fri, 9 Jun 2023 23:02:51 -0700 Subject: [PATCH 04/20] Updated to_json test --- opentelemetry-sdk/tests/logs/test_log_record.py | 1 + 1 file changed, 1 insertion(+) diff --git a/opentelemetry-sdk/tests/logs/test_log_record.py b/opentelemetry-sdk/tests/logs/test_log_record.py index a5993e5833f..8b0137c89bc 100644 --- a/opentelemetry-sdk/tests/logs/test_log_record.py +++ b/opentelemetry-sdk/tests/logs/test_log_record.py @@ -27,6 +27,7 @@ def test_log_record_to_json(self): "severity_number": "None", "severity_text": None, "attributes": None, + "dropped+_attributes": "0", "timestamp": "1970-01-01T00:00:00.000000Z", "trace_id": "", "span_id": "", From 24619841420f35717f4fc8caa8d8665af5fca143 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Fri, 9 Jun 2023 23:04:53 -0700 Subject: [PATCH 05/20] Lint --- opentelemetry-sdk/tests/logs/test_log_record.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-sdk/tests/logs/test_log_record.py b/opentelemetry-sdk/tests/logs/test_log_record.py index 8b0137c89bc..75ea6749a39 100644 --- a/opentelemetry-sdk/tests/logs/test_log_record.py +++ b/opentelemetry-sdk/tests/logs/test_log_record.py @@ -27,7 +27,7 @@ def test_log_record_to_json(self): "severity_number": "None", "severity_text": None, "attributes": None, - "dropped+_attributes": "0", + "dropped_attributes": "0", "timestamp": "1970-01-01T00:00:00.000000Z", "trace_id": "", "span_id": "", From c994f3f6eafd4784ac53620cea87fd3f939dcd00 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Fri, 9 Jun 2023 23:13:30 -0700 Subject: [PATCH 06/20] Lint --- .../otlp/proto/common/_internal/_log_encoder/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py index ba8e85ff136..47c254033bc 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py @@ -70,7 +70,7 @@ def _encode_resource_logs(batch: Sequence[LogData]) -> List[ResourceLogs]: scope_logs.append( ScopeLogs( scope=(_encode_instrumentation_scope(sdk_instrumentation)), - log_records=pb2_logs + log_records=pb2_logs, ) ) pb2_resource_logs.append( From 6d56b273b7c58b1593a6ba046ec62b01edbdd604 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Mon, 12 Jun 2023 15:07:00 -0700 Subject: [PATCH 07/20] Fixed test --- .../tests/test_log_encoder.py | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index c35ced93bee..574b2ba5f3f 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -41,6 +41,7 @@ ) from opentelemetry.sdk._logs import LogData from opentelemetry.sdk._logs import LogRecord as SDKLogRecord +from opentelemetry.sdk._logs import LogLimits from opentelemetry.sdk.resources import Resource as SDKResource from opentelemetry.sdk.util.instrumentation import InstrumentationScope from opentelemetry.trace import TraceFlags @@ -52,10 +53,13 @@ def test_encode(self): self.assertEqual(encode_logs(sdk_logs), expected_encoding) def test_dropped_attributes_count(self): - sdk_logs, _ = self.get_test_logs() + sdk_logs = self._get_test_logs_dropped_attributes() + encoded_logs = encode_logs(sdk_logs) self.assertTrue(hasattr(sdk_logs[0].log_record, "dropped_attributes")) - encoded_logs = str(encode_logs(sdk_logs)) - self.assertTrue("dropped_attributes_count" in encoded_logs) + self.assertEqual( + encoded_logs.resource_logs[0].scope_logs[0].log_records[0].dropped_attributes_count, + 2 + ) @staticmethod def _get_sdk_log_data() -> List[LogData]: @@ -126,6 +130,45 @@ def _get_sdk_log_data() -> List[LogData]: ) return [log1, log2, log3, log4] + + @staticmethod + def _get_test_logs_dropped_attributes() -> List[LogData]: + log1 = LogData( + log_record=SDKLogRecord( + timestamp=1644650195189786880, + trace_id=89564621134313219400156819398935297684, + span_id=1312458408527513268, + trace_flags=TraceFlags(0x01), + severity_text="WARN", + severity_number=SeverityNumber.WARN, + body="Do not go gentle into that good night. Rage, rage against the dying of the light", + resource=SDKResource({"first_resource": "value"}), + attributes={"a": 1, "b": "c", "user_id": "B121092"}, + limits=LogLimits(max_attributes=1), + ), + instrumentation_scope=InstrumentationScope( + "first_name", "first_version" + ), + ) + + log2 = LogData( + log_record=SDKLogRecord( + timestamp=1644650249738562048, + trace_id=0, + span_id=0, + trace_flags=TraceFlags.DEFAULT, + severity_text="WARN", + severity_number=SeverityNumber.WARN, + body="Cooper, this is no time for caution!", + resource=SDKResource({"second_resource": "CASE"}), + attributes={}, + ), + instrumentation_scope=InstrumentationScope( + "second_name", "second_version" + ), + ) + + return [log1, log2] def get_test_logs( self, From b017abbdf078519202d765b2868afbd198d9259a Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Mon, 12 Jun 2023 15:41:14 -0700 Subject: [PATCH 08/20] Lint --- .../tests/test_log_encoder.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 574b2ba5f3f..597f6900e11 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -57,7 +57,10 @@ def test_dropped_attributes_count(self): encoded_logs = encode_logs(sdk_logs) self.assertTrue(hasattr(sdk_logs[0].log_record, "dropped_attributes")) self.assertEqual( - encoded_logs.resource_logs[0].scope_logs[0].log_records[0].dropped_attributes_count, + encoded_logs.resource_logs[0] + .scope_logs[0] + .log_records[0] + .dropped_attributes_count, 2 ) @@ -130,7 +133,7 @@ def _get_sdk_log_data() -> List[LogData]: ) return [log1, log2, log3, log4] - + @staticmethod def _get_test_logs_dropped_attributes() -> List[LogData]: log1 = LogData( From 118ca12ad1c60969aa020e019aae06f81252af7c Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Mon, 12 Jun 2023 16:09:07 -0700 Subject: [PATCH 09/20] Lint --- .../tests/test_log_encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 597f6900e11..4a6cc8e8568 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -61,7 +61,7 @@ def test_dropped_attributes_count(self): .scope_logs[0] .log_records[0] .dropped_attributes_count, - 2 + 2, ) @staticmethod From 3228f14dd609d136e7f1e6ef2d1a75e44844a8b4 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Mon, 12 Jun 2023 16:11:51 -0700 Subject: [PATCH 10/20] Lint --- .../tests/test_log_encoder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 4a6cc8e8568..b3ef05cd1c5 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -39,9 +39,8 @@ from opentelemetry.proto.resource.v1.resource_pb2 import ( Resource as PB2Resource, ) -from opentelemetry.sdk._logs import LogData +from opentelemetry.sdk._logs import LogData, LogLimits from opentelemetry.sdk._logs import LogRecord as SDKLogRecord -from opentelemetry.sdk._logs import LogLimits from opentelemetry.sdk.resources import Resource as SDKResource from opentelemetry.sdk.util.instrumentation import InstrumentationScope from opentelemetry.trace import TraceFlags From 3baca1fb5325958a1bcdad79c409d24c9d0dc46a Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Mon, 12 Jun 2023 16:25:48 -0700 Subject: [PATCH 11/20] Lint --- .../tests/test_log_encoder.py | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index b3ef05cd1c5..d211929855f 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -133,45 +133,6 @@ def _get_sdk_log_data() -> List[LogData]: return [log1, log2, log3, log4] - @staticmethod - def _get_test_logs_dropped_attributes() -> List[LogData]: - log1 = LogData( - log_record=SDKLogRecord( - timestamp=1644650195189786880, - trace_id=89564621134313219400156819398935297684, - span_id=1312458408527513268, - trace_flags=TraceFlags(0x01), - severity_text="WARN", - severity_number=SeverityNumber.WARN, - body="Do not go gentle into that good night. Rage, rage against the dying of the light", - resource=SDKResource({"first_resource": "value"}), - attributes={"a": 1, "b": "c", "user_id": "B121092"}, - limits=LogLimits(max_attributes=1), - ), - instrumentation_scope=InstrumentationScope( - "first_name", "first_version" - ), - ) - - log2 = LogData( - log_record=SDKLogRecord( - timestamp=1644650249738562048, - trace_id=0, - span_id=0, - trace_flags=TraceFlags.DEFAULT, - severity_text="WARN", - severity_number=SeverityNumber.WARN, - body="Cooper, this is no time for caution!", - resource=SDKResource({"second_resource": "CASE"}), - attributes={}, - ), - instrumentation_scope=InstrumentationScope( - "second_name", "second_version" - ), - ) - - return [log1, log2] - def get_test_logs( self, ) -> Tuple[List[SDKLogRecord], ExportLogsServiceRequest]: @@ -302,3 +263,43 @@ def get_test_logs( ) return sdk_logs, pb2_service_request + + + @staticmethod + def _get_test_logs_dropped_attributes() -> List[LogData]: + log1 = LogData( + log_record=SDKLogRecord( + timestamp=1644650195189786880, + trace_id=89564621134313219400156819398935297684, + span_id=1312458408527513268, + trace_flags=TraceFlags(0x01), + severity_text="WARN", + severity_number=SeverityNumber.WARN, + body="Do not go gentle into that good night. Rage, rage against the dying of the light", + resource=SDKResource({"first_resource": "value"}), + attributes={"a": 1, "b": "c", "user_id": "B121092"}, + limits=LogLimits(max_attributes=1), + ), + instrumentation_scope=InstrumentationScope( + "first_name", "first_version" + ), + ) + + log2 = LogData( + log_record=SDKLogRecord( + timestamp=1644650249738562048, + trace_id=0, + span_id=0, + trace_flags=TraceFlags.DEFAULT, + severity_text="WARN", + severity_number=SeverityNumber.WARN, + body="Cooper, this is no time for caution!", + resource=SDKResource({"second_resource": "CASE"}), + attributes={}, + ), + instrumentation_scope=InstrumentationScope( + "second_name", "second_version" + ), + ) + + return [log1, log2] \ No newline at end of file From 2dca33bf5d08aaed3c03be1b60537cc48a776319 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Mon, 12 Jun 2023 16:37:34 -0700 Subject: [PATCH 12/20] Lint --- .../tests/test_log_encoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index d211929855f..42ba8c80bb8 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -264,7 +264,6 @@ def get_test_logs( return sdk_logs, pb2_service_request - @staticmethod def _get_test_logs_dropped_attributes() -> List[LogData]: log1 = LogData( @@ -302,4 +301,5 @@ def _get_test_logs_dropped_attributes() -> List[LogData]: ), ) - return [log1, log2] \ No newline at end of file + return [log1, log2] + \ No newline at end of file From 552080708d2dc4635238bd1ebd2b8f41564bcca6 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Tue, 13 Jun 2023 09:46:01 -0700 Subject: [PATCH 13/20] Lint --- .../tests/test_log_encoder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 42ba8c80bb8..993a20cb323 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -302,4 +302,5 @@ def _get_test_logs_dropped_attributes() -> List[LogData]: ) return [log1, log2] + \ No newline at end of file From 9385b5aa8f7e51640142d7eaac156090b33ae454 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Tue, 13 Jun 2023 10:02:02 -0700 Subject: [PATCH 14/20] Lint --- .../tests/test_log_encoder.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 993a20cb323..ad245ab54f3 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -302,5 +302,3 @@ def _get_test_logs_dropped_attributes() -> List[LogData]: ) return [log1, log2] - - \ No newline at end of file From 4a833dff00b90efc0abe9ffc0b22fb1c32157f5e Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Tue, 13 Jun 2023 12:37:11 -0700 Subject: [PATCH 15/20] lint --- .../tests/test_log_encoder.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index ad245ab54f3..3805c3a34ee 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -23,9 +23,7 @@ _encode_value, ) from opentelemetry.exporter.otlp.proto.common._log_encoder import encode_logs -from opentelemetry.proto.collector.logs.v1.logs_service_pb2 import ( - ExportLogsServiceRequest, -) +from opentelemetry.proto.collector.logs.v1.logs_service_pb2 import ExportLogsServiceRequest from opentelemetry.proto.common.v1.common_pb2 import AnyValue as PB2AnyValue from opentelemetry.proto.common.v1.common_pb2 import ( InstrumentationScope as PB2InstrumentationScope, From e2c5c48b76acb3eda9f472ca290ad707f5a5de19 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Thu, 15 Jun 2023 09:21:03 -0700 Subject: [PATCH 16/20] Lint --- .../tests/test_log_encoder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index 3805c3a34ee..ad245ab54f3 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -23,7 +23,9 @@ _encode_value, ) from opentelemetry.exporter.otlp.proto.common._log_encoder import encode_logs -from opentelemetry.proto.collector.logs.v1.logs_service_pb2 import ExportLogsServiceRequest +from opentelemetry.proto.collector.logs.v1.logs_service_pb2 import ( + ExportLogsServiceRequest, +) from opentelemetry.proto.common.v1.common_pb2 import AnyValue as PB2AnyValue from opentelemetry.proto.common.v1.common_pb2 import ( InstrumentationScope as PB2InstrumentationScope, From 5a3608537314125af98c6810fb34a0506aca02cc Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Thu, 15 Jun 2023 11:11:43 -0700 Subject: [PATCH 17/20] pylint:disable=no-member for ExportLogServiceRequest in test_log_encoder --- .../tests/test_log_encoder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index ad245ab54f3..cbd190b91ec 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -56,6 +56,7 @@ def test_dropped_attributes_count(self): encoded_logs = encode_logs(sdk_logs) self.assertTrue(hasattr(sdk_logs[0].log_record, "dropped_attributes")) self.assertEqual( + # pylint:disable=no-member encoded_logs.resource_logs[0] .scope_logs[0] .log_records[0] From 4ceef9771ec8693112fe0d9ee0000c7babeec5c8 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Thu, 15 Jun 2023 13:09:49 -0700 Subject: [PATCH 18/20] Lint --- .../tests/test_log_encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py index cbd190b91ec..1fdb1977bab 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-common/tests/test_log_encoder.py @@ -56,7 +56,7 @@ def test_dropped_attributes_count(self): encoded_logs = encode_logs(sdk_logs) self.assertTrue(hasattr(sdk_logs[0].log_record, "dropped_attributes")) self.assertEqual( - # pylint:disable=no-member + # pylint:disable=no-member encoded_logs.resource_logs[0] .scope_logs[0] .log_records[0] From ec20a7d551863240758efdc19a63f1055e60d5f0 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Thu, 15 Jun 2023 13:29:31 -0700 Subject: [PATCH 19/20] Changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ce6fc42516..623b1d65e53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased -- Use BoundedAttributes instead of raw dict to extract attributes from LogRecord and Support dropped_attributes_count in LogRecord ([#3310](https://github.com/open-telemetry/opentelemetry-python/pull/3310)) +- Use BoundedAttributes instead of raw dict to extract attributes from LogRecord ([#3310](https://github.com/open-telemetry/opentelemetry-python/pull/3310)) +- Support dropped_attributes_count in LogRecord and exporters ([#3351](https://github.com/open-telemetry/opentelemetry-python/pull/3351)) ## Version 1.18.0/0.39b0 (2023-05-04) - Select histogram aggregation with an environment variable From 0f1eeb480371a6f8f0106151d32a5fa4e2788f31 Mon Sep 17 00:00:00 2001 From: Nina Stawski Date: Fri, 16 Jun 2023 08:57:59 -0700 Subject: [PATCH 20/20] Addressed pull request comments --- .../src/opentelemetry/sdk/_logs/_internal/__init__.py | 2 +- opentelemetry-sdk/tests/logs/test_log_record.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py index 5c9a202b8d7..578ce2c3916 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py @@ -203,7 +203,7 @@ def to_json(self, indent=4) -> str: "attributes": dict(self.attributes) if bool(self.attributes) else None, - "dropped_attributes": repr(self.dropped_attributes), + "dropped_attributes": self.dropped_attributes, "timestamp": ns_to_iso_str(self.timestamp), "trace_id": f"0x{format_trace_id(self.trace_id)}" if self.trace_id is not None diff --git a/opentelemetry-sdk/tests/logs/test_log_record.py b/opentelemetry-sdk/tests/logs/test_log_record.py index 75ea6749a39..1f0bd785a85 100644 --- a/opentelemetry-sdk/tests/logs/test_log_record.py +++ b/opentelemetry-sdk/tests/logs/test_log_record.py @@ -27,7 +27,7 @@ def test_log_record_to_json(self): "severity_number": "None", "severity_text": None, "attributes": None, - "dropped_attributes": "0", + "dropped_attributes": 0, "timestamp": "1970-01-01T00:00:00.000000Z", "trace_id": "", "span_id": "",