Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[extension/encoding/jsonlogencoding] add new extension for JSON codec #27484

Merged
merged 13 commits into from
Oct 19, 2023
Prev Previous commit
Next Next commit
fix: lint
  • Loading branch information
Vihas Splunk committed Oct 11, 2023
commit 494c7399497d537fa3eb8f41ae36225e227f7fde
10 changes: 5 additions & 5 deletions extension/encoding/jsonlogencodingextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package jsonlogencodingextension // import "github.com/open-telemetry/openteleme

import (
"context"
"errors"
"fmt"
"time"

Expand All @@ -25,13 +24,14 @@ func (e *jsonExtension) MarshalLogs(ld plog.Logs) ([]byte, error) {
case pcommon.ValueTypeMap:
raw = logRecord.Map().AsRaw()
default:
return nil, errors.New(fmt.Sprintf("Marshal: Expected 'Map' found '%v'", logRecord.Type().String()))
return nil, fmt.Errorf("Marshal: Expected 'Map' found '%v'", logRecord.Type().String())
}
if buf, err := jsoniter.Marshal(raw); err != nil {
buf, err := jsoniter.Marshal(raw)
if err != nil {
return nil, err
} else {
return buf, nil
}
return buf, nil

}

func (e *jsonExtension) UnmarshalLogs(buf []byte) (plog.Logs, error) {
Expand Down
Loading