Support for attribute.ByteSlice to avoid invalid-UTF-8 issues in instrumentation
AFAIK there are multiple issues here:
- exporter is disconnected on marshaling errors which may hurt performance and cause data loss
- protobuf rejects strings with invalid UTF-8
- OpenTelemetry does not validate strings
- OpenTelemetry does not support
[]byteand usingattribute.String("foo", string(bytes))looks harmless enough, but it very likely produces an invalid UTF-8 string
Assuming protobuf is not going to change current behavior, OpenTelemetry probably should have some answer to this. At least, dropping the problematic span instead of disconnecting.
PS go2sky seem to have this problem too.
The otlp supports a byte value:
https://github.com/open-telemetry/opentelemetry-proto-go/blob/139c123be3af14819da93c7c5225d4a56afd1f2f/otlp/common/v1/common.pb.go#L37-L57
A possible solution could be to add a ByteSlice value to the attributes package. The compatibility of this would need be investigated further though.
This is a near-duplicate of #3021. Adjusting the title.
Would anyone be opposed to me picking up this issue?