getsentry / sentry-go

The official Go SDK for Sentry (sentry.io)

Home Page:https://docs.sentry.io/platforms/go/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[OTel] Non-string attributes are being sent as an empty string

vtfr opened this issue · comments

Summary

Non-string attributes are being sent as an empty string.

Steps To Reproduce

  • Configure an Open Telemetry TraceProvider using sentry's SpanProcessor
  • Start a Span
  • Set a non-string Attribute (such as semconv.HTTPStatusCode)
  • Verify that in the dashboard this Attribute is an empty string, despite it's value being non-zero

Expected Behavior

  • All attributes should reach Sentry's Dashboard with their respective values.

SDK

  • sentry-go version: v0.22.0
  • Go version: 1.19
  • Using Go Modules? yes

Sentry

  • Using hosted Sentry in sentry.io? yes
  • Anything particular to your environment that could be related to this issue? No.

Additional context

The problem seems to be due to these two calls:

attributes[kv.Key] = kv.Value.AsString()

resource[kv.Key] = kv.Value.AsString()

As stated by Value.AsString method's doc:

// AsString returns the string value. Make sure that the Value's type
// is STRING.

Probably the code's intention was to use Value.Emit(), instead. This method returns the string representation of the Value's data.