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

[exporter/datasetexporter] Upgrade to dataset-go v0.19.0 #33675

Merged
merged 20 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
128393f
[exporter/datasetexporter] Upgrade to dataset-go v0.19.0
martin-majlis-s1 Jun 20, 2024
010408f
Add pointer to the PR
martin-majlis-s1 Jun 20, 2024
3d54930
Do not generate life-cycle tests
martin-majlis-s1 Jun 20, 2024
4afd0f0
Use expected version of go.
martin-majlis-s1 Jun 20, 2024
361bf02
Merge branch 'main' into datasetexporter-update-to-0.19.0
martin-majlis-s1 Jun 20, 2024
4c16b52
Merge branch 'main' into datasetexporter-update-to-0.19.0
martin-majlis-s1 Jun 21, 2024
f7c9296
Merge branch 'main' into datasetexporter-update-to-0.19.0
martin-majlis-s1 Jun 21, 2024
6cf2e6d
Add more details to the changelog
martin-majlis-s1 Jun 21, 2024
651021b
Merge branch 'main' into datasetexporter-update-to-0.19.0
martin-majlis-s1 Jun 21, 2024
748f135
[chore] Remove unused internal code (#33690)
crobert-1 Jun 21, 2024
9856d78
[chore] [receiver/mongodb] Remove redundant resource grouping (#33691)
dmitryax Jun 21, 2024
754d433
[pkg/ottl] Add schema_url field to contexts (#31444)
kernelpanic77 Jun 21, 2024
6b0129b
[chore] fix testbed runner (#33711)
codeboten Jun 21, 2024
2ca55ef
[chore][receiver/redis] Update username/password README description (…
crobert-1 Jun 21, 2024
4c7bb9f
Add @pjanotti as codeowner for Windows perf counter and related compo…
pjanotti Jun 21, 2024
0cf9240
Add OTel-Arrow components to contribcol; mark these alpha (#33628)
jmacd Jun 21, 2024
ca91220
[chore] update solace receiver to use mdatagen (#33582)
codeboten Jun 21, 2024
0bd870e
[chore] [receiver/mongodb] Fix test assertion (#33713)
dmitryax Jun 21, 2024
788c6bf
Statsdreceiver optimizations (#33683)
hardproblems Jun 22, 2024
ad53dd2
Merge branch 'main' into datasetexporter-update-to-0.19.0
martin-majlis-s1 Jun 24, 2024
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
30 changes: 30 additions & 0 deletions .chloggen/datasetexporter-update-to-0.19.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'bug_fix'

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Upgrade dataset-go to v0.19.0 and fix found issues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to briefly clarity what those "found issues" were under subtext.


# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [33498, 32533, 33675]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
Upgrade `dataset-go` library from v0.18.0 to v0.19.0.
Enable skipped integration test and adjust the test so it is passing again.
Do not validate configuration, let the framework run the validation.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.25 // indirect
github.com/scalyr/dataset-go v0.18.0 // indirect
github.com/scalyr/dataset-go v0.19.0 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcontribcol/go.sum

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

54 changes: 24 additions & 30 deletions exporter/datasetexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,39 +202,33 @@ func (c *Config) String() string {
return s
}

func (c *Config) convert() (*ExporterConfig, error) {
err := c.Validate()
if err != nil {
return nil, fmt.Errorf("config is not valid: %w", err)
}

func (c *Config) convert() *ExporterConfig {
return &ExporterConfig{
datasetConfig: &datasetConfig.DataSetConfig{
Endpoint: c.DatasetURL,
Tokens: datasetConfig.DataSetTokens{WriteLog: string(c.APIKey)},
BufferSettings: buffer_config.DataSetBufferSettings{
MaxLifetime: c.BufferSettings.MaxLifetime,
PurgeOlderThan: c.BufferSettings.PurgeOlderThan,
MaxSize: buffer.LimitBufferSize,
GroupBy: c.BufferSettings.GroupBy,
RetryInitialInterval: c.BufferSettings.RetryInitialInterval,
RetryMaxInterval: c.BufferSettings.RetryMaxInterval,
RetryMaxElapsedTime: c.BufferSettings.RetryMaxElapsedTime,
RetryMultiplier: backoff.DefaultMultiplier,
RetryRandomizationFactor: backoff.DefaultRandomizationFactor,
RetryShutdownTimeout: c.BufferSettings.RetryShutdownTimeout,
},
ServerHostSettings: server_host_config.DataSetServerHostSettings{
UseHostName: c.ServerHostSettings.UseHostName,
ServerHost: c.ServerHostSettings.ServerHost,
},
Debug: c.Debug,
datasetConfig: &datasetConfig.DataSetConfig{
Endpoint: c.DatasetURL,
Tokens: datasetConfig.DataSetTokens{WriteLog: string(c.APIKey)},
BufferSettings: buffer_config.DataSetBufferSettings{
MaxLifetime: c.BufferSettings.MaxLifetime,
PurgeOlderThan: c.BufferSettings.PurgeOlderThan,
MaxSize: buffer.LimitBufferSize,
GroupBy: c.BufferSettings.GroupBy,
RetryInitialInterval: c.BufferSettings.RetryInitialInterval,
RetryMaxInterval: c.BufferSettings.RetryMaxInterval,
RetryMaxElapsedTime: c.BufferSettings.RetryMaxElapsedTime,
RetryMultiplier: backoff.DefaultMultiplier,
RetryRandomizationFactor: backoff.DefaultRandomizationFactor,
RetryShutdownTimeout: c.BufferSettings.RetryShutdownTimeout,
},
tracesSettings: c.TracesSettings,
logsSettings: c.LogsSettings,
serverHostSettings: c.ServerHostSettings,
ServerHostSettings: server_host_config.DataSetServerHostSettings{
UseHostName: c.ServerHostSettings.UseHostName,
ServerHost: c.ServerHostSettings.ServerHost,
},
Debug: c.Debug,
},
nil
tracesSettings: c.TracesSettings,
logsSettings: c.LogsSettings,
serverHostSettings: c.ServerHostSettings,
}
}

type ExporterConfig struct {
Expand Down
8 changes: 1 addition & 7 deletions exporter/datasetexporter/datasetexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ func newDatasetExporter(entity string, config *Config, set exporter.Settings) (*
zap.String("id.string", set.ID.String()),
zap.String("id.name", set.ID.Name()),
)
exporterCfg, err := config.convert()
if err != nil {
return nil, fmt.Errorf(
"cannot convert config: %s; %w",
config.String(), err,
)
}
exporterCfg := config.convert()
userAgent := fmt.Sprintf(
"%s;%s;%s",
"OtelCollector",
Expand Down
23 changes: 22 additions & 1 deletion exporter/datasetexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ func TestLoadConfig(t *testing.T) {
}
}

func TestValidateConfigs(t *testing.T) {
tests := createExporterTests()

for _, tt := range tests {
t.Run(tt.name, func(*testing.T) {
err := component.ValidateConfig(tt.config)
assert.Equal(t, tt.expectedError, err)
})
}
}

type CreateTest struct {
name string
config component.Config
Expand All @@ -169,7 +180,17 @@ func createExporterTests() []CreateTest {
{
name: "broken",
config: &Config{},
expectedError: fmt.Errorf("cannot get DataSetExporter: cannot convert config: DatasetURL: ; APIKey: [REDACTED] (0); Debug: false; BufferSettings: {MaxLifetime:0s PurgeOlderThan:0s GroupBy:[] RetryInitialInterval:0s RetryMaxInterval:0s RetryMaxElapsedTime:0s RetryShutdownTimeout:0s}; LogsSettings: {ExportResourceInfo:false ExportResourcePrefix: ExportScopeInfo:false ExportScopePrefix: DecomposeComplexMessageField:false DecomposedComplexMessagePrefix: exportSettings:{ExportSeparator: ExportDistinguishingSuffix:}}; TracesSettings: {exportSettings:{ExportSeparator: ExportDistinguishingSuffix:}}; ServerHostSettings: {UseHostName:false ServerHost:}; BackOffConfig: {Enabled:false InitialInterval:0s RandomizationFactor:0 Multiplier:0 MaxInterval:0s MaxElapsedTime:0s}; QueueSettings: {Enabled:false NumConsumers:0 QueueSize:0 StorageID:<nil>}; TimeoutSettings: {Timeout:0s}; config is not valid: api_key is required"),
expectedError: fmt.Errorf("api_key is required"),
},
{
name: "missing-url",
config: &Config{APIKey: "AAA"},
expectedError: fmt.Errorf("dataset_url is required"),
},
{
name: "missing-key",
config: &Config{DatasetURL: "bbb"},
expectedError: fmt.Errorf("api_key is required"),
},
{
name: "valid",
Expand Down
2 changes: 1 addition & 1 deletion exporter/datasetexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/google/uuid v1.6.0
// github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.103.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.103.0
github.com/scalyr/dataset-go v0.18.0
github.com/scalyr/dataset-go v0.19.0
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.103.0
go.opentelemetry.io/collector/confmap v0.103.0
Expand Down
4 changes: 2 additions & 2 deletions exporter/datasetexporter/go.sum

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

11 changes: 8 additions & 3 deletions exporter/datasetexporter/logs_exporter_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (
)

func TestConsumeLogsManyLogsShouldSucceed(t *testing.T) {
t.Skip("TODO: Skipping due to https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/32533")

const maxDelay = 200 * time.Millisecond
createSettings := exportertest.NewNopSettings()

Expand All @@ -52,7 +50,7 @@ func TestConsumeLogsManyLogsShouldSucceed(t *testing.T) {

for _, ev := range cer.Events {
processedEvents.Add(1)
key, found := ev.Attrs["body.str"]
key, found := ev.Attrs["key"]
assert.True(t, found)
mutex.Lock()
sKey := key.(string)
Expand Down Expand Up @@ -82,11 +80,18 @@ func TestConsumeLogsManyLogsShouldSucceed(t *testing.T) {
BufferSettings: BufferSettings{
MaxLifetime: maxDelay,
GroupBy: []string{"attributes.container_id"},
RetryInitialInterval: maxDelay,
RetryMaxInterval: 10 * maxDelay,
RetryMaxElapsedTime: 50 * maxDelay,
RetryShutdownTimeout: time.Minute,
PurgeOlderThan: 100 * maxDelay,
},
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
ServerHostSettings: ServerHostSettings{
UseHostName: true,
},
}

logs, err := createLogsExporter(context.Background(), createSettings, config)
Expand Down
24 changes: 0 additions & 24 deletions exporter/datasetexporter/logs_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,6 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata"
)

func TestCreateLogsExporter(t *testing.T) {
ctx := context.Background()
createSettings := exportertest.NewNopSettings()
tests := createExporterTests()

for _, tt := range tests {
t.Run(tt.name, func(*testing.T) {
logs, err := createLogsExporter(ctx, createSettings, tt.config)

if err == nil {
assert.Nil(t, tt.expectedError, tt.name)
assert.NotNil(t, logs, tt.name)
} else {
if tt.expectedError == nil {
assert.Nil(t, err, tt.name)
} else {
assert.Equal(t, tt.expectedError.Error(), err.Error(), tt.name)
assert.Nil(t, logs, tt.name)
}
}
})
}
}

func TestBuildBody(t *testing.T) {
slice := pcommon.NewValueSlice()
err := slice.FromRaw([]any{1, 2, 3})
Expand Down
22 changes: 0 additions & 22 deletions exporter/datasetexporter/traces_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,19 @@
package datasetexporter

import (
"context"
"fmt"
"strings"
"testing"
"time"

"github.com/scalyr/dataset-go/pkg/api/add_events"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/ptrace"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata"
)

func TestCreateTracesExporter(t *testing.T) {
ctx := context.Background()
createSettings := exportertest.NewNopSettings()
tests := createExporterTests()

for _, tt := range tests {
t.Run(tt.name, func(*testing.T) {
logs, err := createTracesExporter(ctx, createSettings, tt.config)

if err == nil {
assert.Nil(t, tt.expectedError)
assert.NotNil(t, logs)
} else {
assert.Equal(t, tt.expectedError.Error(), err.Error())
assert.Nil(t, logs)
}
})
}
}

func generateTEvent1Raw() *add_events.Event {
return &add_events.Event{
Thread: "TT",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.25 // indirect
github.com/scalyr/dataset-go v0.18.0 // indirect
github.com/scalyr/dataset-go v0.19.0 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum

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

Loading