@@ -6,6 +6,8 @@ package xconnector // import "go.opentelemetry.io/collector/connector/xconnector
6
6
import (
7
7
"context"
8
8
9
+ "go.opentelemetry.io/otel/attribute"
10
+
9
11
"go.opentelemetry.io/collector/component"
10
12
"go.opentelemetry.io/collector/connector"
11
13
"go.opentelemetry.io/collector/connector/internal"
@@ -213,6 +215,13 @@ func WithProfilesToLogs(createProfilesToLogs CreateProfilesToLogsFunc, sl compon
213
215
})
214
216
}
215
217
218
+ // WithTelemetryAttributes overrides the default component attributes setter to change the attributes to set on the component telemetry.
219
+ func WithTelemetryAttributes (attributesFunc func (set attribute.Set ) attribute.Set ) FactoryOption {
220
+ return factoryOptionFunc (func (o * factoryOpts ) {
221
+ o .attributesFunc = attributesFunc
222
+ })
223
+ }
224
+
216
225
// factory implements the Factory interface.
217
226
type factory struct {
218
227
connector.Factory
@@ -234,6 +243,8 @@ type factory struct {
234
243
profilesToTracesStabilityLevel component.StabilityLevel
235
244
profilesToMetricsStabilityLevel component.StabilityLevel
236
245
profilesToLogsStabilityLevel component.StabilityLevel
246
+
247
+ attributesFunc func (set attribute.Set ) attribute.Set
237
248
}
238
249
239
250
func (f * factory ) TracesToProfilesStability () component.StabilityLevel {
@@ -313,6 +324,13 @@ func (f *factory) CreateProfilesToLogs(ctx context.Context, set connector.Settin
313
324
return f .createProfilesToLogsFunc (ctx , set , cfg , next )
314
325
}
315
326
327
+ func (f * factory ) TelemetryAttributes (attributes attribute.Set ) attribute.Set {
328
+ if f .attributesFunc != nil {
329
+ return f .attributesFunc (attributes )
330
+ }
331
+ return attributes
332
+ }
333
+
316
334
// NewFactory returns a Factory.
317
335
func NewFactory (cfgType component.Type , createDefaultConfig component.CreateDefaultConfigFunc , options ... FactoryOption ) Factory {
318
336
opts := factoryOpts {factory : & factory {}}
0 commit comments