Skip to content

Commit 0a1f310

Browse files
[exporter/signalfxexporter] Make sending tags from the SignalFx Exporter configurable (#43799)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description New optional configuration flag `drop_tags` has been added to SignalFx Exporter to allow users to disable tags metadata sending. This feature has been introduced due to a common issue among Splunk Observability customers when they're receiving more tags than allowed limit. <!--Describe what testing was performed and which tests were added.--> #### Testing - added unit test to check if `drop_tags` flag is working <!--Describe the documentation added.--> #### Documentation - added new config option description in README file <!--Please delete paragraphs that you did not use before submitting.-->
1 parent b1892b0 commit 0a1f310

File tree

7 files changed

+83
-2
lines changed

7 files changed

+83
-2
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: exporter/signalfx
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Makes sending tags from SignalFx Exporter configurable"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [43799]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
New optional configuration flag `drop_tags` has been added to SignalFx Exporter to allow users to disable tag metadata sending.
20+
This feature has been introduced due to a common issue among Splunk Observability customers when they're receiving more tags
21+
than allowed limit.
22+
23+
24+
25+
# If your change doesn't affect end users or the exported elements of any package,
26+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
27+
# Optional: The change log or logs in which this entry should be included.
28+
# e.g. '[user]' or '[user, api]'
29+
# Include 'user' if the change is relevant to end users.
30+
# Include 'api' if there is a change to a library API.
31+
# Default: '[user]'
32+
change_logs: [user]

exporter/signalfxexporter/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ The following configuration options are required:
2626

2727
- `access_token` (no default): The access token is the [authentication token
2828
provided by Splunk Observability
29-
Cloud](https://docs.splunk.com/observability/en/admin/authentication/authentication-tokens/manage-usage.html).
29+
Cloud](https://help.splunk.com/en/splunk-observability-cloud/administer/authentication-and-security/authentication-tokens/manage-usage-with-access-tokens).
3030
The access token can be obtained from the web app.
3131
- Either `realm` or both `api_url` and `ingest_url`. Both `api_url` and
3232
`ingest_url` take precedence over `realm`.
3333
- `realm` (no default): SignalFx realm where the data will be received.
3434
- `api_url` (no default): Destination to which [properties and
35-
tags](https://docs.splunk.com/observability/en/metrics-and-metadata/metrics-finder-metadata-catalog.html)
35+
tags](https://help.splunk.com/en/splunk-observability-cloud/data-tools/metric-finder-and-metadata-catalogue)
3636
are sent. If `realm` is set, this option is derived and will be
3737
`https://api.{realm}.signalfx.com`. If a value is explicitly set, the
3838
value of `realm` will not be used in determining `api_url`. The explicit
@@ -128,6 +128,7 @@ The following configuration options can also be configured:
128128
- `max_conns_per_host` (default = 20): The maximum total number of connections the client can keep open per host.
129129
- `idle_conn_timeout` (default = 30s): The maximum amount of time an idle connection will remain open before closing itself.
130130
- `timeout` (default = 10s): Amount of time to wait for the dimension HTTP request to complete.
131+
- `drop_tags` (default = false): Flag that indicates whether to drop the tags from the metadata sent to Splunk Observability Cloud by the exporter.
131132
- `nonalphanumeric_dimension_chars`: (default = `"_-."`) A string of characters
132133
that are allowed to be used as a dimension key in addition to alphanumeric
133134
characters. Each nonalphanumeric dimension key character that isn't in this string

exporter/signalfxexporter/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ type DimensionClientConfig struct {
156156
MaxConnsPerHost int `mapstructure:"max_conns_per_host"`
157157
IdleConnTimeout time.Duration `mapstructure:"idle_conn_timeout"`
158158
Timeout time.Duration `mapstructure:"timeout"`
159+
DropTags bool `mapstructure:"drop_tags"`
159160
}
160161

161162
func (cfg *Config) getMetricTranslator(done chan struct{}) (*translation.MetricTranslator, error) {

exporter/signalfxexporter/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func TestLoadConfig(t *testing.T) {
8484
MaxConnsPerHost: 20,
8585
IdleConnTimeout: 30 * time.Second,
8686
Timeout: 10 * time.Second,
87+
DropTags: false,
8788
},
8889
ExcludeMetrics: nil,
8990
IncludeMetrics: nil,
@@ -163,6 +164,7 @@ func TestLoadConfig(t *testing.T) {
163164
MaxConnsPerHost: 10000,
164165
IdleConnTimeout: 2 * time.Hour,
165166
Timeout: 20 * time.Second,
167+
DropTags: false,
166168
},
167169
ExcludeMetrics: []dpfilters.MetricFilter{
168170
{

exporter/signalfxexporter/exporter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func (se *signalfxExporter) start(ctx context.Context, host component.Host) (err
153153
MaxIdleConnsPerHost: se.config.DimensionClient.MaxIdleConnsPerHost,
154154
IdleConnTimeout: se.config.DimensionClient.IdleConnTimeout,
155155
Timeout: se.config.DimensionClient.Timeout,
156+
DropTags: se.config.DimensionClient.DropTags,
156157
})
157158
dimClient.Start()
158159

exporter/signalfxexporter/internal/dimensions/dimclient.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ type DimensionClient struct {
5858
metricsConverter translation.MetricsConverter
5959
// ExcludeProperties will filter DimensionUpdate content to not submit undesired metadata.
6060
ExcludeProperties []dpfilters.PropertyFilter
61+
// dropTags specifies whether tags should be omitted or not. Default value is false.
62+
dropTags bool
6163
}
6264

6365
type queuedDimension struct {
@@ -82,6 +84,7 @@ type DimensionClientOptions struct {
8284
MaxIdleConnsPerHost int
8385
IdleConnTimeout time.Duration
8486
Timeout time.Duration
87+
DropTags bool
8588
}
8689

8790
// NewDimensionClient returns a new client
@@ -118,6 +121,7 @@ func NewDimensionClient(options DimensionClientOptions) *DimensionClient {
118121
logUpdates: options.LogUpdates,
119122
metricsConverter: options.MetricsConverter,
120123
ExcludeProperties: options.ExcludeProperties,
124+
dropTags: options.DropTags,
121125
}
122126
}
123127

@@ -342,6 +346,11 @@ func (dc *DimensionClient) makePatchRequest(ctx context.Context, dim *DimensionU
342346
}
343347

344348
func (dc *DimensionClient) filterDimensionUpdate(update *DimensionUpdate) *DimensionUpdate {
349+
// clear tags list if dropTags option is set
350+
if dc.dropTags {
351+
update.Tags = nil
352+
}
353+
345354
for _, excludeRule := range dc.ExcludeProperties {
346355
if excludeRule.DimensionName.Matches(update.Name) && excludeRule.DimensionValue.Matches(update.Value) {
347356
for k, v := range update.Properties {

exporter/signalfxexporter/internal/dimensions/dimclient_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,41 @@ func TestDimensionClient(t *testing.T) {
186186
require.EqualValues(t, 1, server.requestCount.Load())
187187
})
188188

189+
t.Run("send dimension without tags if dropTags option is set", func(t *testing.T) {
190+
server.reset()
191+
// set dropTags option
192+
client.dropTags = true
193+
defer func() { client.dropTags = false }()
194+
195+
require.NoError(t, client.acceptDimension(&DimensionUpdate{
196+
Name: "host",
197+
Value: "test-box",
198+
Properties: map[string]*string{
199+
"a": newString("b"),
200+
"c": newString("d"),
201+
"e": nil,
202+
},
203+
Tags: map[string]bool{
204+
"active": true,
205+
"terminated": false,
206+
},
207+
}))
208+
209+
server.handleRequest()
210+
require.Equal(t, []dim{
211+
{
212+
Key: "host",
213+
Value: "test-box",
214+
Properties: map[string]*string{
215+
"a": newString("b"),
216+
"c": newString("d"),
217+
"e": nil,
218+
},
219+
},
220+
}, server.acceptedDims)
221+
require.EqualValues(t, 1, server.requestCount.Load())
222+
})
223+
189224
t.Run("send a distinct prop/tag set for existing dim with server error", func(t *testing.T) {
190225
server.reset()
191226
server.respCode = http.StatusInternalServerError

0 commit comments

Comments
 (0)