Skip to content

SpanID, TraceID, KeyValue and other structs cannot be unmarshalled from JSON #1819

Open
@toby-allsopp

Description

@toby-allsopp

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 SpanSnapshots was easily unmashalled back into a slice of SpanSnapshots.

Metadata

Metadata

Assignees

Labels

area:tracePart of OpenTelemetry tracingbugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

Status

Low priority

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions