-
Notifications
You must be signed in to change notification settings - Fork 706
logs: fix serialization of Extended attributes #4342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
66ec409
to
57a6fb3
Compare
57a6fb3
to
65603ac
Compare
0ad43ac
to
419334b
Compare
Updated PR with fixes for logs attributes serialization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change -- left a couple of comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
d29c930
to
07c8b0c
Compare
07c8b0c
to
4aa2d48
Compare
opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py
Outdated
Show resolved
Hide resolved
Logs attribute accepts AnyValue as AttributeValue add a type to describe that and start using it.
4aa2d48
to
879ab21
Compare
* 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
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: