From 04792310b3b81eb1947d110b1af30ba5bbf86e7d Mon Sep 17 00:00:00 2001 From: pegasas Date: Sat, 6 Jan 2024 20:30:14 +0800 Subject: [PATCH 1/2] ObservedTimestamp field is not set --- CHANGELOG.md | 2 ++ .../src/opentelemetry/sdk/_logs/_internal/__init__.py | 1 + opentelemetry-sdk/tests/logs/test_log_record.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f359c6b633f..d6d02b6e99c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Version 1.22.0/0.43b0 (2023-12-15) +- Logs: ObservedTimestamp field is missing in console exporter output + ([#3564](https://github.com/open-telemetry/opentelemetry-python/pull/3564)) - Prometheus exporter sanitize info metric ([#3572](https://github.com/open-telemetry/opentelemetry-python/pull/3572)) - Remove Jaeger exporters ([#3554](https://github.com/open-telemetry/opentelemetry-python/pull/3554)) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py index cfa4d6cfa9b..eec60e09213 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py @@ -206,6 +206,7 @@ def to_json(self, indent=4) -> str: else None, "dropped_attributes": self.dropped_attributes, "timestamp": ns_to_iso_str(self.timestamp), + "observed_timestamp": ns_to_iso_str(self.observed_timestamp), "trace_id": f"0x{format_trace_id(self.trace_id)}" if self.trace_id is not None else "", diff --git a/opentelemetry-sdk/tests/logs/test_log_record.py b/opentelemetry-sdk/tests/logs/test_log_record.py index 1f0bd785a85..6a33db101c8 100644 --- a/opentelemetry-sdk/tests/logs/test_log_record.py +++ b/opentelemetry-sdk/tests/logs/test_log_record.py @@ -29,6 +29,7 @@ def test_log_record_to_json(self): "attributes": None, "dropped_attributes": 0, "timestamp": "1970-01-01T00:00:00.000000Z", + "observed_timestamp": "1970-01-01T00:00:00.000000Z", "trace_id": "", "span_id": "", "trace_flags": None, @@ -38,6 +39,7 @@ def test_log_record_to_json(self): ) actual = LogRecord( timestamp=0, + observed_timestamp=0, body="a log line", ).to_json() self.assertEqual(expected, actual) From 204d5620e774fd8d631015eb7487fc0e93232d7d Mon Sep 17 00:00:00 2001 From: John Huang Date: Sat, 3 Feb 2024 21:18:22 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md unrelease --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8d89ab62a8..dd0f2a9ef07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,11 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3623](https://github.com/open-telemetry/opentelemetry-python/pull/3623)) - Improve Resource Detector timeout messaging ([#3645](https://github.com/open-telemetry/opentelemetry-python/pull/3645)) +- Logs: ObservedTimestamp field is missing in console exporter output + ([#3564](https://github.com/open-telemetry/opentelemetry-python/pull/3564)) ## Version 1.22.0/0.43b0 (2023-12-15) -- Logs: ObservedTimestamp field is missing in console exporter output - ([#3564](https://github.com/open-telemetry/opentelemetry-python/pull/3564)) - Prometheus exporter sanitize info metric ([#3572](https://github.com/open-telemetry/opentelemetry-python/pull/3572)) - Remove Jaeger exporters