Skip to content

Commit 0ad43ac

Browse files
committed
opentelemetry-sdk: serialize extended attributes
1 parent 1184b32 commit 0ad43ac

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def __init__(
200200
attributes=attributes if bool(attributes) else None,
201201
immutable=False,
202202
max_value_len=limits.max_attribute_length,
203+
extended_attributes=True,
203204
),
204205
}
205206
)

opentelemetry-sdk/tests/logs/test_log_record.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ def test_log_record_to_json(self):
3333
"body": "a log line",
3434
"severity_number": None,
3535
"severity_text": None,
36-
"attributes": None,
36+
"attributes": {
37+
"mapping": {"key": "value"},
38+
"none": None,
39+
"sequence": [1, 2],
40+
"str": "string",
41+
},
3742
"dropped_attributes": 0,
3843
"timestamp": "1970-01-01T00:00:00.000000Z",
3944
"observed_timestamp": "1970-01-01T00:00:00.000000Z",
@@ -52,12 +57,18 @@ def test_log_record_to_json(self):
5257
observed_timestamp=0,
5358
body="a log line",
5459
resource=Resource({"service.name": "foo"}),
60+
attributes={
61+
"mapping": {"key": "value"},
62+
"none": None,
63+
"sequence": [1, 2],
64+
"str": "string",
65+
},
5566
)
5667

5768
self.assertEqual(expected, actual.to_json(indent=4))
5869
self.assertEqual(
5970
actual.to_json(indent=None),
60-
'{"body": "a log line", "severity_number": null, "severity_text": null, "attributes": null, "dropped_attributes": 0, "timestamp": "1970-01-01T00:00:00.000000Z", "observed_timestamp": "1970-01-01T00:00:00.000000Z", "trace_id": "", "span_id": "", "trace_flags": null, "resource": {"attributes": {"service.name": "foo"}, "schema_url": ""}}',
71+
'{"body": "a log line", "severity_number": null, "severity_text": null, "attributes": {"mapping": {"key": "value"}, "none": null, "sequence": [1, 2], "str": "string"}, "dropped_attributes": 0, "timestamp": "1970-01-01T00:00:00.000000Z", "observed_timestamp": "1970-01-01T00:00:00.000000Z", "trace_id": "", "span_id": "", "trace_flags": null, "resource": {"attributes": {"service.name": "foo"}, "schema_url": ""}}',
6172
)
6273

6374
def test_log_record_to_json_serializes_severity_number_as_int(self):

0 commit comments

Comments
 (0)