OpenTelemetry logs, body vs attributes for structured logs unclear in spec and behaves inconsistently in exporters #4722
Unanswered
segevfiner
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
There is something that is inconsistent/missing at this time from the OpenTelemetry logs specification and is causing me quite an headache while trying to implement it into our app.
The current spec defines:
But from this it is very unclear how structured logs should be mapped into this format, including what is the main message field when the body is an object rather than just a string, and results in mismatch between directly ingesting such logs versus using OpenTelemetry into various backends.
For example, the default instrumentation for Pino (Node.js) maps the message field into
bodyand the rest intoattributes, but when this is exported into Google Cloud Logs, it puts the body astextPayloadand attributes aslabelswherelabelsare just a string to string mapping, which means structured fields such aserrget flattened as JSON and become inconvenient to view and query, modifying the instrumentation (Directly changing its code) to put everything intobodyresults in the expected mapping of putting it all underjsonPayload, but for Google Cloud Logs to recognize the main message field and display it nicely, it must be calledmessagewhich is not part of the spec and I had to do manually in the configuration of Pino, otherwise it becomes inconvenient to view them messages as it just shows the body JSON payload instead of the message when browsing messages.Trying the same with SigNoz, when the message is mapped into body and attributes, it again doesn't handle the structured
errattribute yet and just shows it as a JSON string which is inconvenient to query and view. When mapping it all intobody, it will parse the body JSON as expected, but it will display the entire body JSON in the table, with no concept of main message field, and no option to display a field of the body as a column, though you seem able to query them but without autocompletion of fields in query message box, which is also inconvient.I'm not sure what's the canonical use for
bodyandattributeshere, and how I should handle it then to get the correct and most convenient display in different exporter as they don't seem to act the same...See also open-telemetry/opentelemetry-js-contrib#3012
Beta Was this translation helpful? Give feedback.
All reactions