logs: fix serialization of Extended attributes#4342
Merged
xrmx merged 19 commits intoopen-telemetry:mainfrom Apr 18, 2025
Merged
logs: fix serialization of Extended attributes#4342xrmx merged 19 commits intoopen-telemetry:mainfrom
xrmx merged 19 commits intoopen-telemetry:mainfrom
Conversation
aabmass
approved these changes
Dec 10, 2024
lmolkova
reviewed
Dec 14, 2024
opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
Kludex
suggested changes
Dec 24, 2024
opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
66ec409 to
57a6fb3
Compare
Kludex
approved these changes
Dec 24, 2024
lmolkova
reviewed
Dec 29, 2024
xrmx
commented
Mar 4, 2025
5 tasks
57a6fb3 to
65603ac
Compare
0ad43ac to
419334b
Compare
Contributor
Author
|
Updated PR with fixes for logs attributes serialization. |
pmcollins
reviewed
Apr 2, 2025
Member
pmcollins
left a comment
There was a problem hiding this comment.
Thanks for this change -- left a couple of comments.
Contributor
Author
|
Ok tested this with an aiohttp server application with Pablo patch applied to not break logging, without that I got no logging out of the app. Before: After: And as printed by collector debug exporter: |
e215e93 to
9ee67b1
Compare
emdneto
reviewed
Apr 4, 2025
Member
There was a problem hiding this comment.
Some typing issues. Just add "opentelemetry-sdk/src/opentelemetry/sdk/_logs", in the strict list in pyright and:
tox -e typecheck | grep ExtendedAttributes -A 5
/workspaces/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py:189:15 - error: Argument of type "AnyValue | TraceFlags | SeverityNumber | BoundedAttributes" cannot be assigned to parameter "attributes" of type "ExtendedAttributes | None" in function "__init__"
Type "AnyValue | TraceFlags | SeverityNumber | BoundedAttributes" is not assignable to type "ExtendedAttributes | None"
Type "SeverityNumber" is not assignable to type "ExtendedAttributes | None"
"SeverityNumber" is not assignable to "Mapping[str, AnyValue]"
"SeverityNumber" is not assignable to "None" (reportArgumentType)
/workspaces/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py:200:32 - error: Argument of type "ExtendedAttributes | None" cannot be assigned to parameter "attributes" of type "Attributes" in function "__init__"
Type "ExtendedAttributes | None" is not assignable to type "Attributes"
Type "ExtendedAttributes" is not assignable to type "Attributes"
"Mapping[str, AnyValue]" is not assignable to "Mapping[str, AttributeValue]"
Type parameter "_VT_co@Mapping" is covariant, but "AnyValue" is not a subtype of "AttributeValue"
Type "AnyValue" is not assignable to type "AttributeValue"
"Mapping[str, AnyValue]" is not assignable to "None" (reportArgumentType)
/workspaces/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py:255:36 - error: Cannot access attribute "dropped" for class "ExtendedAttributes"
Attribute "dropped" is unknown (reportAttributeAccessIssue)
/workspaces/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py:646:17 - error: Argument of type "ExtendedAttributes | None" cannot be assigned to parameter "attributes" of type "Attributes" in function "__init__"
Type "ExtendedAttributes | None" is not assignable to type "Attributes"
Type "ExtendedAttributes" is not assignable to type "Attributes"
"Mapping[str, AnyValue]" is not assignable to "Mapping[str, AttributeValue]"
Type parameter "_VT_co@Mapping" is covariant, but "AnyValue" is not a subtype of "AttributeValue"
Type "AnyValue" is not assignable to type "AttributeValue"
"Mapping[str, AnyValue]" is not assignable to "None" (reportArgumentType)
xrmx
commented
Apr 7, 2025
xrmx
commented
Apr 7, 2025
opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
d29c930 to
07c8b0c
Compare
aabmass
reviewed
Apr 14, 2025
Logs attribute accepts AnyValue as AttributeValue add a type to describe that and start using it.
4aa2d48 to
879ab21
Compare
emdneto
approved these changes
Apr 17, 2025
3 tasks
DylanRussell
pushed a commit
to DylanRussell/opentelemetry-python
that referenced
this pull request
Apr 29, 2025
* logs: introduce LogAttributes type Logs attribute accepts AnyValue as AttributeValue add a type to describe that and start using it. * LogAttributes -> ExtendedAttributes * Handle ExtendedAttributes in BoundedAttributes * opentelemetry-sdk: serialize extended attributes * Add changelog * Fix typing * Fix handling of not attribute values inside sequences * Please mypy * Please lint * More typing * Even more typing fixes * Fix docs * Fix mypy * Update LogRecord attributes typing to match reality * More typing * Move changelog to unreleased * ExtendedAttributes -> _ExtendedAttributes * opentelemetry-sdk: keep instrumentation scope attributes as Attributes * exporter/otlp: allow export of none values in logs attributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Logs attribute accepts AnyValue as AttributeValue add a type to describe that and start using it.
Fixes #4315
Fixes #4460
Fixes #4515
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Contrib Repo Change?
Checklist: