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

DSET-3468: update dataset-go to latest, send more details in user-agent #23640

Merged
merged 1 commit into from
Jun 23, 2023
Merged
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
20 changes: 20 additions & 0 deletions .chloggen/dataset-more-detailed-user-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add more details to User-Agent header for DataSet HTTP requests"

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

# (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:
2 changes: 1 addition & 1 deletion cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ require (
github.com/relvacode/iso8601 v1.3.0 // indirect
github.com/rs/cors v1.9.0 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14 // indirect
github.com/scalyr/dataset-go v0.0.8 // indirect
github.com/scalyr/dataset-go v0.0.9 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.5.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions cmd/configschema/go.sum

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

2 changes: 1 addition & 1 deletion cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ require (
github.com/rs/cors v1.9.0 // indirect
github.com/samber/lo v1.37.0 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14 // indirect
github.com/scalyr/dataset-go v0.0.8 // indirect
github.com/scalyr/dataset-go v0.0.9 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.5.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.

12 changes: 10 additions & 2 deletions exporter/datasetexporter/datasetexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/google/uuid"
"github.com/scalyr/dataset-go/pkg/api/add_events"
"github.com/scalyr/dataset-go/pkg/client"
"go.opentelemetry.io/collector/exporter"
"go.uber.org/zap"
"golang.org/x/time/rate"
)
Expand All @@ -27,7 +28,8 @@ type DatasetExporter struct {
exporterCfg *ExporterConfig
}

func newDatasetExporter(entity string, config *Config, logger *zap.Logger) (*DatasetExporter, error) {
func newDatasetExporter(entity string, config *Config, set exporter.CreateSettings) (*DatasetExporter, error) {
logger := set.Logger
logger.Info("Creating new DataSetExporter",
zap.String("config", config.String()),
zap.String("entity", entity),
Expand All @@ -39,11 +41,17 @@ func newDatasetExporter(entity string, config *Config, logger *zap.Logger) (*Dat
config.String(), err,
)
}

userAgent := fmt.Sprintf(
"%s;%s;%s",
"OtelCollector",
set.BuildInfo.Version,
entity,
)
client, err := client.NewClient(
exporterCfg.datasetConfig,
&http.Client{Timeout: time.Second * 60},
logger,
&userAgent,
)
if err != nil {
logger.Error("Cannot create DataSetClient: ", zap.Error(err))
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.3.0
// github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.77.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.80.0
github.com/scalyr/dataset-go v0.0.8
github.com/scalyr/dataset-go v0.0.9
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.80.0
go.opentelemetry.io/collector/confmap v0.80.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.

2 changes: 1 addition & 1 deletion exporter/datasetexporter/logs_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var now = time.Now

func createLogsExporter(ctx context.Context, set exporter.CreateSettings, config component.Config) (exporter.Logs, error) {
cfg := castConfig(config)
e, err := newDatasetExporter("logs", cfg, set.Logger)
e, err := newDatasetExporter("logs", cfg, set)
if err != nil {
return nil, fmt.Errorf("cannot get DataSetExpoter: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/datasetexporter/traces_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ServiceNameKey = "service.name"

func createTracesExporter(ctx context.Context, set exporter.CreateSettings, config component.Config) (exporter.Traces, error) {
cfg := castConfig(config)
e, err := newDatasetExporter("logs", cfg, set.Logger)
e, err := newDatasetExporter("logs", cfg, set)
if err != nil {
return nil, fmt.Errorf("cannot get DataSetExpoter: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ require (
github.com/rs/cors v1.9.0 // indirect
github.com/samber/lo v1.37.0 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14 // indirect
github.com/scalyr/dataset-go v0.0.8 // indirect
github.com/scalyr/dataset-go v0.0.9 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.5.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.