opentelemetry-go
opentelemetry-go copied to clipboard
SpanID, TraceID, KeyValue and other structs cannot be unmarshalled from JSON
Description
A number of structs, e.g. trace.SpanID
, define MarshalJSON
methods but not the corresponding UnmarshalJSON
. This means that the JSON written by the stdout exporter, which consists of a stream of []*SpanSnapshot
values, cannot be unmarshalled back into Go objects easily.
Environment
- OS: Linux
- Architecture: amd64
- Go Version: 1.15.7
- opentelemetry-go version: v0.19.0
Steps To Reproduce
ss := trace.SpanSnapshot{}
b, _ := json.Marshal(ss)
var ss2 trace.SpanSnapshot
err := json.Unmarshal(b, &ss2)
require.NoError(t, err)
require.Equal(t, ss, ss2)
Expected behavior
It would be helpful if the JSON produced by marshalling a slice of SpanSnapshot
s was easily unmashalled back into a slice of SpanSnapshots
.