@@ -19,7 +19,7 @@ import (
19
19
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension/internal/source"
20
20
)
21
21
22
- type Header struct {
22
+ type header struct {
23
23
action action.Action
24
24
source source.Source
25
25
}
@@ -34,7 +34,7 @@ type headerSetterExtension struct {
34
34
component.StartFunc
35
35
component.ShutdownFunc
36
36
37
- headers []Header
37
+ headers []header
38
38
}
39
39
40
40
// PerRPCCredentials implements extensionauth.GRPCClient.
@@ -55,50 +55,50 @@ func newHeadersSetterExtension(cfg *Config, logger *zap.Logger) (*headerSetterEx
55
55
return nil , errors .New ("extension configuration is not provided" )
56
56
}
57
57
58
- headers := make ([]Header , 0 , len (cfg .HeadersConfig ))
59
- for _ , header := range cfg .HeadersConfig {
58
+ headers := make ([]header , 0 , len (cfg .HeadersConfig ))
59
+ for _ , h := range cfg .HeadersConfig {
60
60
var s source.Source
61
61
switch {
62
- case header .Value != nil :
62
+ case h .Value != nil :
63
63
s = & source.StaticSource {
64
- Value : * header .Value ,
64
+ Value : * h .Value ,
65
65
}
66
- case header .FromAttribute != nil :
66
+ case h .FromAttribute != nil :
67
67
defaultValue := ""
68
- if header .DefaultValue != nil {
69
- defaultValue = string (* header .DefaultValue )
68
+ if h .DefaultValue != nil {
69
+ defaultValue = string (* h .DefaultValue )
70
70
}
71
71
s = & source.AttributeSource {
72
- Key : * header .FromAttribute ,
72
+ Key : * h .FromAttribute ,
73
73
DefaultValue : defaultValue ,
74
74
}
75
- case header .FromContext != nil :
75
+ case h .FromContext != nil :
76
76
defaultValue := ""
77
- if header .DefaultValue != nil {
78
- defaultValue = string (* header .DefaultValue )
77
+ if h .DefaultValue != nil {
78
+ defaultValue = string (* h .DefaultValue )
79
79
}
80
80
s = & source.ContextSource {
81
- Key : * header .FromContext ,
81
+ Key : * h .FromContext ,
82
82
DefaultValue : defaultValue ,
83
83
}
84
84
}
85
85
86
86
var a action.Action
87
- switch header .Action {
87
+ switch h .Action {
88
88
case INSERT :
89
- a = action.Insert {Key : * header .Key }
89
+ a = action.Insert {Key : * h .Key }
90
90
case UPSERT :
91
- a = action.Upsert {Key : * header .Key }
91
+ a = action.Upsert {Key : * h .Key }
92
92
case UPDATE :
93
- a = action.Update {Key : * header .Key }
93
+ a = action.Update {Key : * h .Key }
94
94
case DELETE :
95
- a = action.Delete {Key : * header .Key }
95
+ a = action.Delete {Key : * h .Key }
96
96
default :
97
- a = action.Upsert {Key : * header .Key }
97
+ a = action.Upsert {Key : * h .Key }
98
98
logger .Warn ("The action was not provided, using 'upsert'." +
99
99
" In future versions, we'll require this to be explicitly set" )
100
100
}
101
- headers = append (headers , Header {action : a , source : s })
101
+ headers = append (headers , header {action : a , source : s })
102
102
}
103
103
104
104
return & headerSetterExtension {headers : headers }, nil
@@ -107,7 +107,7 @@ func newHeadersSetterExtension(cfg *Config, logger *zap.Logger) (*headerSetterEx
107
107
// headersPerRPC is a gRPC credentials.PerRPCCredentials implementation sets
108
108
// headers with values extracted from provided sources.
109
109
type headersPerRPC struct {
110
- headers []Header
110
+ headers []header
111
111
}
112
112
113
113
// GetRequestMetadata returns the request metadata to be used with the RPC.
@@ -137,7 +137,7 @@ func (h *headersPerRPC) RequireTransportSecurity() bool {
137
137
// values extracted from configured sources.
138
138
type headersRoundTripper struct {
139
139
base http.RoundTripper
140
- headers []Header
140
+ headers []header
141
141
}
142
142
143
143
// RoundTrip copies the original request and sets headers of the new requests
0 commit comments