Skip to content

Commit

Permalink
chore: fix CI, run "update-otel"
Browse files Browse the repository at this point in the history
  • Loading branch information
Vihas Splunk committed Oct 19, 2023
1 parent a1c46e3 commit e34fcdf
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 56 deletions.
10 changes: 5 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/cmd/configschema"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/cmd/otelcontribcol"
schedule:
Expand Down Expand Up @@ -267,11 +272,6 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/exporter/syslogexporter"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/exporter/tanzuobservabilityexporter"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion extension/encoding/jsonlogencodingextension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
[development]: https://github.com/open-telemetry/opentelemetry-collector#development
<!-- end autogenerated section -->

The `jsonlog` encoding extention is used to marshal/unmarshal JSON log body.
The `jsonlog` encoding extension is used to marshal/unmarshal JSON log body, ignoring other log fields.
10 changes: 5 additions & 5 deletions extension/encoding/jsonlogencodingextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"go.opentelemetry.io/collector/pdata/plog"
)

type jsonExtension struct {
type jsonLogExtension struct {
}

func (e *jsonExtension) MarshalLogs(ld plog.Logs) ([]byte, error) {
func (e *jsonLogExtension) MarshalLogs(ld plog.Logs) ([]byte, error) {
logRecord := ld.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Body()
var raw map[string]any
switch logRecord.Type() {
Expand All @@ -34,7 +34,7 @@ func (e *jsonExtension) MarshalLogs(ld plog.Logs) ([]byte, error) {

}

func (e *jsonExtension) UnmarshalLogs(buf []byte) (plog.Logs, error) {
func (e *jsonLogExtension) UnmarshalLogs(buf []byte) (plog.Logs, error) {
p := plog.NewLogs()

// get json logs from the buffer
Expand All @@ -54,10 +54,10 @@ func (e *jsonExtension) UnmarshalLogs(buf []byte) (plog.Logs, error) {
return p, nil
}

func (e *jsonExtension) Start(_ context.Context, _ component.Host) error {
func (e *jsonLogExtension) Start(_ context.Context, _ component.Host) error {
return nil
}

func (e *jsonExtension) Shutdown(_ context.Context) error {
func (e *jsonLogExtension) Shutdown(_ context.Context) error {
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestExtension_Start_Shutdown(t *testing.T) {
j := &jsonExtension{}
j := &jsonLogExtension{}
err := j.Start(context.Background(), componenttest.NewNopHost())
require.NoError(t, err)
err = j.Shutdown(context.Background())
Expand Down
2 changes: 1 addition & 1 deletion extension/encoding/jsonlogencodingextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewFactory() extension.Factory {
}

func createExtension(_ context.Context, _ extension.CreateSettings, _ component.Config) (extension.Extension, error) {
return &jsonExtension{}, nil
return &jsonLogExtension{}, nil
}

func createDefaultConfig() component.Config {
Expand Down
20 changes: 10 additions & 10 deletions extension/encoding/jsonlogencodingextension/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.20
require (
github.com/json-iterator/go v1.1.12
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.87.0
go.opentelemetry.io/collector/extension v0.87.0
go.opentelemetry.io/collector/pdata v1.0.0-rcv0016
go.opentelemetry.io/collector/component v0.87.1-0.20231017160804-ec0725874313
go.opentelemetry.io/collector/extension v0.87.1-0.20231017160804-ec0725874313
go.opentelemetry.io/collector/pdata v1.0.0-rcv0016.0.20231017160804-ec0725874313
)

require (
Expand All @@ -23,19 +23,19 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.87.0 // indirect
go.opentelemetry.io/collector/confmap v0.87.0 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.87.1-0.20231017160804-ec0725874313 // indirect
go.opentelemetry.io/collector/confmap v0.87.1-0.20231017160804-ec0725874313 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0016.0.20231017160804-ec0725874313 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.2 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
40 changes: 20 additions & 20 deletions extension/encoding/jsonlogencodingextension/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 3 additions & 13 deletions extension/encoding/jsonlogencodingextension/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,18 @@ package jsonlogencodingextension

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
)

func TestMarshalUnmarshal(t *testing.T) {
t.Parallel()
e := &jsonExtension{}
e := &jsonLogExtension{}
json := `{"example":"example valid json to test that the unmarshaler is correctly returning a plog value"}`
ld, err := e.UnmarshalLogs([]byte(json))
assert.NoError(t, err)
assert.Equal(t, 1, ld.LogRecordCount())
for i := 0; i < ld.ResourceLogs().Len(); i++ {
for j := 0; j < ld.ResourceLogs().At(i).ScopeLogs().Len(); j++ {
for k := 0; k < ld.ResourceLogs().At(i).ScopeLogs().At(j).LogRecords().Len(); k++ {
lr := ld.ResourceLogs().At(i).ScopeLogs().At(j).LogRecords().At(k)
lr.SetObservedTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 0)))
}
}
}

buf, err := e.MarshalLogs(ld)
assert.NoError(t, err)
Expand All @@ -35,15 +25,15 @@ func TestMarshalUnmarshal(t *testing.T) {
}

func TestInvalidMarshal(t *testing.T) {
e := &jsonExtension{}
e := &jsonLogExtension{}
p := plog.NewLogs()
p.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty().Body().SetStr("NOT A MAP")
_, err := e.MarshalLogs(p)
assert.ErrorContains(t, err, "Marshal: Expected 'Map' found 'Str'")
}

func TestInvalidUnmarshal(t *testing.T) {
e := &jsonExtension{}
e := &jsonLogExtension{}
_, err := e.UnmarshalLogs([]byte("NOT A JSON"))
assert.ErrorContains(t, err, "ReadMapCB: expect { or n, but found N")
}
1 change: 1 addition & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module-sets:
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jaegerencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jsonlogencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/textencodingextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension
- github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension
Expand Down

0 comments on commit e34fcdf

Please sign in to comment.