Skip to content

Commit

Permalink
JSON marshaler emits enums as ints per spec reuqirements.
Browse files Browse the repository at this point in the history
Fixes #6338
  • Loading branch information
bogdandrutu committed Oct 18, 2022
1 parent 4d44580 commit 40d258b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .chloggen/enumsasints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: pdata

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: JSON marshaler emits enums as ints per spec reuqirements. This may be a breaking change if receivers were not confirming with the spec.

# One or more tracking issues or pull requests related to the change
issues: [6338]
4 changes: 3 additions & 1 deletion pdata/plog/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (

// NewJSONMarshaler returns a Marshaler. Marshals to OTLP json bytes.
func NewJSONMarshaler() Marshaler {
return &jsonMarshaler{delegate: jsonpb.Marshaler{}}
return &jsonMarshaler{delegate: jsonpb.Marshaler{
EnumsAsInts: true,
}}
}

type jsonMarshaler struct {
Expand Down
4 changes: 3 additions & 1 deletion pdata/pmetric/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (

// NewJSONMarshaler returns a model.Marshaler. Marshals to OTLP json bytes.
func NewJSONMarshaler() Marshaler {
return &jsonMarshaler{delegate: jsonpb.Marshaler{}}
return &jsonMarshaler{delegate: jsonpb.Marshaler{
EnumsAsInts: true,
}}
}

type jsonMarshaler struct {
Expand Down
4 changes: 3 additions & 1 deletion pdata/ptrace/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (

// NewJSONMarshaler returns a model.Marshaler. Marshals to OTLP json bytes.
func NewJSONMarshaler() Marshaler {
return &jsonMarshaler{delegate: jsonpb.Marshaler{}}
return &jsonMarshaler{delegate: jsonpb.Marshaler{
EnumsAsInts: true,
}}
}

type jsonMarshaler struct {
Expand Down

0 comments on commit 40d258b

Please sign in to comment.