Debian Codegraph @

instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/config.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package otelaws // import "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws"
5
6 import (
7 "go.opentelemetry.io/otel/propagation"
8 "go.opentelemetry.io/otel/trace"
9 )
10
11 type config struct {
12 TracerProvider trace.TracerProvider
13 TextMapPropagator propagation.TextMapPropagator
14 AttributeBuilders []AttributeBuilder
15 }
16
17 // Option applies an option value.
18 type Option interface {
19 apply(*config)
20 }
21
22 // optionFunc provides a convenience wrapper for simple Options
23 // that can be represented as functions.
24 type optionFunc func(*config)
25
26 func (o optionFunc) apply(c *config) {
27 o(c)
28 }
29
30 // WithTracerProvider specifies a tracer provider to use for creating a tracer.
31 // If none is specified, the global TracerProvider is used.
32 func WithTracerProvider(provider trace.TracerProvider) Option {
33 return optionFunc(func(cfg *config) {
34 if provider != nil {
35 cfg.TracerProvider = provider
36 }
37 })
38 }
39
40 // WithTextMapPropagator specifies a Text Map Propagator to use when propagating context.
41 // If none is specified, the global TextMapPropagator is used.
42 func WithTextMapPropagator(propagator propagation.TextMapPropagator) Option {
43 return optionFunc(func(cfg *config) {
44 if propagator != nil {
45 cfg.TextMapPropagator = propagator
46 }
47 })
48 }
49
50 // WithAttributeBuilder specifies an attribute setter function for setting service specific attributes.
51 // If none is specified, the service will be determined by the DefaultAttributeBuilder function and the corresponding attributes will be included.
52 func WithAttributeBuilder(attributeBuilders ...AttributeBuilder) Option {
53 return optionFunc(func(cfg *config) {
54 cfg.AttributeBuilders = append(cfg.AttributeBuilders, attributeBuilders...)
55 })
56 }