Skip to content

Commit

Permalink
add unmarshal for exportertype
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoVillar committed Nov 22, 2024
1 parent 5f70e7b commit 62583c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions trace/exporter_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ func (t ExporterType) MarshalJSON() ([]byte, error) {
return []byte(`"` + t.String() + `"`), nil
}

func (t *ExporterType) UnmarshalJSON(b []byte) error {
exporterTypeStr := strings.Trim(string(b), `"`)
exporterType, err := ExporterTypeFromString(exporterTypeStr)
if err != nil && !errors.Is(err, errUnknownExporterType) {
return err
}
*t = exporterType
return nil
}

func (t ExporterType) String() string {
switch t {
case GRPC:
Expand Down

0 comments on commit 62583c1

Please sign in to comment.