Skip to content
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

LogRecord Produces Invalid JSON Serialization of Resource #3345

Closed
sernst opened this issue Jun 13, 2023 · 1 comment
Closed

LogRecord Produces Invalid JSON Serialization of Resource #3345

sernst opened this issue Jun 13, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@sernst
Copy link

sernst commented Jun 13, 2023

Describe your environment

Not Python version or environment specific.

Steps to reproduce

Use a console log exporter or create a lightweight log exporter that calls the LogRecord.to_json method to observe that the Resource object is a Python repr serialized object and not a JSON-compatible serialized object.

What is the expected behavior?

I expect the Resource object serialization to be valid JSON and match the serialization of the other two signal types from ReadableSpan.to_json and MetricsData.to_json.

What is the actual behavior?

The output displays a Python repr version of the Resource attributes and is not a compatible structure with the other signal type exports of the same data format.

Additional context

N/A

@sernst sernst added the bug Something isn't working label Jun 13, 2023
sernst added a commit to sernst/opentelemetry-python that referenced this issue Jun 13, 2023
Currently, the `LogRecord.to_json`
method serializes the resource object
using `repr` of its attributes. This
differs from how the serialization
process is handled in `ReadableSpan.to_json`
and `MetricsData.to_json`, which utilize the
`Resource.to_json` functionality directly.
Using `repr` does not produce a json-parseable
output and doesn't follow the same depth of
serialization as the other two signal types.
Therefore, this change carries over the
serialization process from the spans and
metrics signal types to the logs type.

Closes open-telemetry#3345
sernst added a commit to sernst/opentelemetry-python that referenced this issue Jun 13, 2023
Currently, the `LogRecord.to_json`
method serializes the resource object
using `repr` of its attributes. This
differs from how the serialization
process is handled in `ReadableSpan.to_json`
and `MetricsData.to_json`, which utilize the
`Resource.to_json` functionality directly.
Using `repr` does not produce a json-parseable
output and doesn't follow the same depth of
serialization as the other two signal types.
Therefore, this change carries over the
serialization process from the spans and
metrics signal types to the logs type.

Fixes open-telemetry#3345
sernst added a commit to sernst/opentelemetry-python that referenced this issue Jun 13, 2023
Currently, the `LogRecord.to_json`
method serializes the resource object
using `repr` of its attributes. This
differs from how the serialization
process is handled in `ReadableSpan.to_json`
and `MetricsData.to_json`, which utilize the
`Resource.to_json` functionality directly.
Using `repr` does not produce a json-parseable
output and doesn't follow the same depth of
serialization as the other two signal types.
Therefore, this change carries over the
serialization process from the spans and
metrics signal types to the logs type.

Fixes open-telemetry#3345
sernst added a commit to sernst/opentelemetry-python that referenced this issue Jun 20, 2023
Currently, the `LogRecord.to_json`
method serializes the resource object
using `repr` of its attributes. This
differs from how the serialization
process is handled in `ReadableSpan.to_json`
and `MetricsData.to_json`, which utilize the
`Resource.to_json` functionality directly.
Using `repr` does not produce a json-parseable
output and doesn't follow the same depth of
serialization as the other two signal types.
Therefore, this change carries over the
serialization process from the spans and
metrics signal types to the logs type.

Fixes open-telemetry#3345
sernst added a commit to sernst/opentelemetry-python that referenced this issue Jul 2, 2023
Currently, the `LogRecord.to_json`
method serializes the resource object
using `repr` of its attributes. This
differs from how the serialization
process is handled in `ReadableSpan.to_json`
and `MetricsData.to_json`, which utilize the
`Resource.to_json` functionality directly.
Using `repr` does not produce a json-parseable
output and doesn't follow the same depth of
serialization as the other two signal types.
Therefore, this change carries over the
serialization process from the spans and
metrics signal types to the logs type.

Fixes open-telemetry#3345
ocelotl pushed a commit to sernst/opentelemetry-python that referenced this issue Feb 2, 2024
Currently, the `LogRecord.to_json`
method serializes the resource object
using `repr` of its attributes. This
differs from how the serialization
process is handled in `ReadableSpan.to_json`
and `MetricsData.to_json`, which utilize the
`Resource.to_json` functionality directly.
Using `repr` does not produce a json-parseable
output and doesn't follow the same depth of
serialization as the other two signal types.
Therefore, this change carries over the
serialization process from the spans and
metrics signal types to the logs type.

Fixes open-telemetry#3345
@emdneto
Copy link
Member

emdneto commented Jun 25, 2024

@open-telemetry/python-approvers I think this is fixed in #3972. We can close this one, too

@xrmx xrmx closed this as completed Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants