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