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

Fix running otelcol.exporter.awss3 with sumo_ic marshaler #2865

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Main (unreleased)

- Added OpenTelemetry logs and metrics support to Alloy mixin's dashboards and alerts. (@thampiotr)

### Bugfixes

- Fixed an issue where the `otelcol.exporter.awss3` could not be started with the `sumo_ic` marshaler. (@wildum)

v1.7.1
-----------------

Expand Down
12 changes: 11 additions & 1 deletion internal/component/otelcol/exporter/awss3/awss3.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ func init() {

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
fact := awss3exporter.NewFactory()
return exporter.New(opts, fact, args.(Arguments), exporter.TypeSignalConstFunc(exporter.TypeAll))

typeSignalFunc := func(opts component.Options, args component.Arguments) exporter.TypeSignal {
switch args.(Arguments).MarshalerName.Type {
case "sumo_ic":
return exporter.TypeLogs
default:
return exporter.TypeAll
}
}

return exporter.New(opts, fact, args.(Arguments), typeSignalFunc)
},
})
}
Expand Down
76 changes: 76 additions & 0 deletions internal/component/otelcol/exporter/awss3/awss3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package awss3_test

import (
"testing"
"time"

otelcolCfg "github.com/grafana/alloy/internal/component/otelcol/config"
"github.com/grafana/alloy/internal/component/otelcol/exporter/awss3"
"github.com/grafana/alloy/internal/runtime/componenttest"
"github.com/grafana/alloy/internal/util"
"github.com/grafana/alloy/syntax"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -105,3 +108,76 @@ func TestDebugMetricsConfig(t *testing.T) {
})
}
}

// Checks that the component can start with the sumo_ic marshaler.
func TestSumoICMarshaler(t *testing.T) {
ctx := componenttest.TestContext(t)
l := util.TestLogger(t)

ctrl, err := componenttest.NewControllerFromID(l, "otelcol.exporter.awss3")
require.NoError(t, err)

cfg := `
s3_uploader {
s3_bucket = "test"
s3_prefix = "logs"
}

marshaler {
type = "sumo_ic"
}
`
var args awss3.Arguments
require.NoError(t, syntax.Unmarshal([]byte(cfg), &args))

go func() {
err := ctrl.Run(ctx, args)
require.NoError(t, err)
}()

require.NoError(t, ctrl.WaitRunning(time.Second), "component never started")
}

// Checks that the component can be updated with the sumo_ic marshaler.
func TestSumoICMarshalerUpdate(t *testing.T) {
ctx := componenttest.TestContext(t)
l := util.TestLogger(t)

ctrl, err := componenttest.NewControllerFromID(l, "otelcol.exporter.awss3")
require.NoError(t, err)

cfg := `
s3_uploader {
s3_bucket = "test"
s3_prefix = "logs"
}

marshaler {
type = "otlp_json"
}
`
var args awss3.Arguments
require.NoError(t, syntax.Unmarshal([]byte(cfg), &args))

go func() {
err := ctrl.Run(ctx, args)
require.NoError(t, err)
}()

require.NoError(t, ctrl.WaitRunning(time.Second), "component never started")

cfg2 := `
s3_uploader {
s3_bucket = "test"
s3_prefix = "logs"
}

marshaler {
type = "sumo_ic"
}
`

var args2 awss3.Arguments
require.NoError(t, syntax.Unmarshal([]byte(cfg2), &args2))
require.NoError(t, ctrl.Update(args2))
}
Loading