From 4a1d7c8f16f0fd9fcc170ec7341a4048288ea788 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Mon, 16 Oct 2023 11:11:31 -0700 Subject: [PATCH] [exporter/signalfx] expose build version in user agent string (#27612) **Description:** The current SignalFx exporter maps to a static user agent string "OpenTelemetry-Collector SignalFx Exporter/v0.0.1". This PR changes the version to match the build info version. **Link to tracking Issue:** Fixes #16841 --- .chloggen/signalfxexporter-user-agent.yaml | 27 ++++++++++++++++++++++ exporter/signalfxexporter/exporter.go | 11 +++++---- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 .chloggen/signalfxexporter-user-agent.yaml diff --git a/.chloggen/signalfxexporter-user-agent.yaml b/.chloggen/signalfxexporter-user-agent.yaml new file mode 100644 index 000000000000..8d75f4a834ad --- /dev/null +++ b/.chloggen/signalfxexporter-user-agent.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# 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: signalfxexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add the build version to the user agent of the SignalFx exporter + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [16841] + +# (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: + +# 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: [] diff --git a/exporter/signalfxexporter/exporter.go b/exporter/signalfxexporter/exporter.go index 9826a8293e76..219dc34f5524 100644 --- a/exporter/signalfxexporter/exporter.go +++ b/exporter/signalfxexporter/exporter.go @@ -52,6 +52,7 @@ func (sme *signalfMetadataExporter) ConsumeMetadata(metadata []*metadata.Metadat type signalfxExporter struct { config *Config + version string logger *zap.Logger telemetrySettings component.TelemetrySettings pushMetricsData func(ctx context.Context, md pmetric.Metrics) (droppedTimeSeries int, err error) @@ -90,6 +91,7 @@ func newSignalFxExporter( return &signalfxExporter{ config: config, + version: createSettings.BuildInfo.Version, logger: createSettings.Logger, telemetrySettings: createSettings.TelemetrySettings, converter: converter, @@ -102,7 +104,7 @@ func (se *signalfxExporter) start(ctx context.Context, host component.Host) (err return err } - headers := buildHeaders(se.config) + headers := buildHeaders(se.config, se.version) client, err := se.createClient(host) if err != nil { return err @@ -176,6 +178,7 @@ func newEventExporter(config *Config, createSettings exporter.CreateSettings) (* return &signalfxExporter{ config: config, + version: createSettings.BuildInfo.Version, logger: createSettings.Logger, telemetrySettings: createSettings.TelemetrySettings, }, nil @@ -188,7 +191,7 @@ func (se *signalfxExporter) startLogs(_ context.Context, host component.Host) er return err } - headers := buildHeaders(se.config) + headers := buildHeaders(se.config, se.version) client, err := se.createClient(host) if err != nil { return err @@ -242,11 +245,11 @@ func (se *signalfxExporter) pushMetadata(metadata []*metadata.MetadataUpdate) er return se.dimClient.PushMetadata(metadata) } -func buildHeaders(config *Config) map[string]string { +func buildHeaders(config *Config, version string) map[string]string { headers := map[string]string{ "Connection": "keep-alive", "Content-Type": "application/x-protobuf", - "User-Agent": "OpenTelemetry-Collector SignalFx Exporter/v0.0.1", + "User-Agent": fmt.Sprintf("OpenTelemetry-Collector SignalFx Exporter/%s", version), } if config.AccessToken != "" {