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

logging a keyword list is incorrectly detected as a string #693

Open
thomasdziedzic-calmwave opened this issue Feb 15, 2024 · 1 comment

Comments

@thomasdziedzic-calmwave
Copy link

thomasdziedzic-calmwave commented Feb 15, 2024

I'm getting an error when using opentelemetry_experimental 0.4.0:

** (ArgumentError) errors were found at the given arguments:

  * 1st argument: not an iodata term

    (stdlib 5.2) re.erl:987: :re.replace([msg: "...", event_id: "..."], ~c",?\r?\n *", ~c", ", [{:return, :list}, :global, :unicode])

it's throwing the keyword list into :re.replace at https://github.com/open-telemetry/opentelemetry-erlang/blob/main/apps/opentelemetry_experimental/src/otel_otlp_logs.erl#L77-L78

this is because the keyword list is getting detected as a string on https://github.com/open-telemetry/opentelemetry-erlang/blob/main/apps/opentelemetry_experimental/src/otel_otlp_logs.erl#L71

where the IS_STRING macro is defined as (is_list(String) orelse is_binary(String)) so the keyword list is detected as a STRING because it's a list and so the code tries to do a regex replace on it which leads to the error.

@tsloughter
Copy link
Member

Ah yup, that should use unicode:characters_to_binary to check if its a string like is done in otel_otlp_common.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants