Replies: 3 comments 1 reply
-
I think I could do a less risky workaround here, and instead of overriding values of existing keys - introduce new keys. Doing so reduces the risk of breaking some code elsewhere that expects the values to be charlists: Logger.metadata(%{
my_otel_span_id: to_string(metadata[:otel_span_id]),
my_otel_trace_flags: to_string(metadata[:otel_trace_flags]),
my_otel_trace_id: to_string(metadata[:otel_trace_id])
}) Still not 100% sure if this is the right way, and judging by popularity of opentelemetry-erlang - if there shouldn't be some way where library could assist with rendering of span context info in a better way 🙈 |
Beta Was this translation helpful? Give feedback.
-
Forgot to mention - I am merely interested in having the span context info in the logs, so that later I could "manually link" it to a span in Grafana like this: datasources:
# ...
- name: Loki
type: loki
access: proxy
url: http://loki:3100
version: 1
editable: false
jsonData:
derivedFields:
- datasourceUid: tempo
matcherRegex: "trace_id=(\\w+)"
name: TraceID
url: "$${__value.raw}" So, this is not to be confused with |
Beta Was this translation helpful? Give feedback.
-
Oh no... if that is the case with Elixir then we need to just change to using a binary string. |
Beta Was this translation helpful? Give feedback.
-
Hi!
What's the current recommended approach to set the Logger metadata in a way that it actually shows up on calls to Logger macros, such as
Logger.info/2
?Today, when calling
Logger.info/2
or other macros from the Logger module in Elixir, the keys:otel_span_id
,:otel_trace_flags
, and:otel_trace_id
are missing. However, these keys and respective values are present in the output ofLogger.metadata/0
. I suspect this is due to::otel_span_id
,:otel_trace_flags
, and:otel_trace_id
- all pointing to values that are character lists,Here's a script to reproduce what I am talking about
The output:
I doubt my approach with merely overriding the keys is a correct one 🤔 For context, the application I am working on is a web server. While I could, in principle, add a code like this - I just doubt that's the right way to do it:
Beta Was this translation helpful? Give feedback.
All reactions