Skip to content

Commit

Permalink
[exporter/signalfx] expose build version in user agent string (open-t…
Browse files Browse the repository at this point in the history
…elemetry#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 open-telemetry#16841
  • Loading branch information
atoulme authored and JaredTan95 committed Oct 18, 2023
1 parent 10bba48 commit edd5d3a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .chloggen/signalfxexporter-user-agent.yaml
Original file line number Diff line number Diff line change
@@ -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: []
11 changes: 7 additions & 4 deletions exporter/signalfxexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -90,6 +91,7 @@ func newSignalFxExporter(

return &signalfxExporter{
config: config,
version: createSettings.BuildInfo.Version,
logger: createSettings.Logger,
telemetrySettings: createSettings.TelemetrySettings,
converter: converter,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 != "" {
Expand Down

0 comments on commit edd5d3a

Please sign in to comment.