5
5
"encoding/json"
6
6
"fmt"
7
7
"reflect"
8
- "strings"
9
8
"time"
10
9
11
10
"github.com/cloudquery/plugin-sdk/v4/plugin"
@@ -41,23 +40,9 @@ func newResource(p *plugin.Plugin) *resource.Resource {
41
40
return r
42
41
}
43
42
44
- func parseOtelHeaders (headers []string ) map [string ]string {
45
- headerMap := make (map [string ]string , len (headers ))
46
- for _ , h := range headers {
47
- parts := strings .SplitN (h , ":" , 2 )
48
- if len (parts ) != 2 {
49
- continue
50
- }
51
- headerMap [strings .TrimSpace (parts [0 ])] = strings .TrimSpace (parts [1 ])
52
- }
53
- return headerMap
54
- }
55
-
56
43
type otelConfig struct {
57
44
endpoint string
58
45
insecure bool
59
- headers []string
60
- urlPath string
61
46
}
62
47
63
48
func getTraceExporter (ctx context.Context , opts otelConfig ) (* otlptrace.Exporter , error ) {
@@ -73,15 +58,6 @@ func getTraceExporter(ctx context.Context, opts otelConfig) (*otlptrace.Exporter
73
58
traceOptions = append (traceOptions , otlptracehttp .WithInsecure ())
74
59
}
75
60
76
- if len (opts .headers ) > 0 {
77
- headers := parseOtelHeaders (opts .headers )
78
- traceOptions = append (traceOptions , otlptracehttp .WithHeaders (headers ))
79
- }
80
-
81
- if opts .urlPath != "" {
82
- traceOptions = append (traceOptions , otlptracehttp .WithURLPath (opts .urlPath ))
83
- }
84
-
85
61
traceClient := otlptracehttp .NewClient (traceOptions ... )
86
62
traceExporter , err := otlptrace .New (ctx , traceClient )
87
63
if err != nil {
@@ -104,15 +80,6 @@ func getMetricReader(ctx context.Context, opts otelConfig) (*metric.PeriodicRead
104
80
metricOptions = append (metricOptions , otlpmetrichttp .WithInsecure ())
105
81
}
106
82
107
- if len (opts .headers ) > 0 {
108
- headers := parseOtelHeaders (opts .headers )
109
- metricOptions = append (metricOptions , otlpmetrichttp .WithHeaders (headers ))
110
- }
111
-
112
- if opts .urlPath != "" {
113
- metricOptions = append (metricOptions , otlpmetrichttp .WithURLPath (opts .urlPath ))
114
- }
115
-
116
83
metricExporter , err := otlpmetrichttp .New (ctx , metricOptions ... )
117
84
if err != nil {
118
85
return nil , fmt .Errorf ("creating OTLP metric exporter: %w" , err )
@@ -136,15 +103,6 @@ func getLogsProcessor(ctx context.Context, opts otelConfig) (*log.BatchProcessor
136
103
logOptions = append (logOptions , otlploghttp .WithInsecure ())
137
104
}
138
105
139
- if len (opts .headers ) > 0 {
140
- headers := parseOtelHeaders (opts .headers )
141
- logOptions = append (logOptions , otlploghttp .WithHeaders (headers ))
142
- }
143
-
144
- if opts .urlPath != "" {
145
- logOptions = append (logOptions , otlploghttp .WithURLPath (opts .urlPath ))
146
- }
147
-
148
106
exporter , err := otlploghttp .New (ctx , logOptions ... )
149
107
if err != nil {
150
108
return nil , fmt .Errorf ("creating OTLP log exporter: %w" , err )
@@ -154,15 +112,13 @@ func getLogsProcessor(ctx context.Context, opts otelConfig) (*log.BatchProcessor
154
112
return processor , nil
155
113
}
156
114
157
- func setupOtel (ctx context.Context , logger zerolog.Logger , p * plugin.Plugin , otelEndpoint string , otelEndpointInsecure bool , otelEndpointHeaders [] string , otelEndpointURLPath string ) (shutdown func (), err error ) {
115
+ func setupOtel (ctx context.Context , logger zerolog.Logger , p * plugin.Plugin , otelEndpoint string , otelEndpointInsecure bool ) (shutdown func (), err error ) {
158
116
if otelEndpoint == "" {
159
117
return nil , nil
160
118
}
161
119
opts := otelConfig {
162
120
endpoint : otelEndpoint ,
163
121
insecure : otelEndpointInsecure ,
164
- headers : otelEndpointHeaders ,
165
- urlPath : otelEndpointURLPath ,
166
122
}
167
123
traceExporter , err := getTraceExporter (ctx , opts )
168
124
if err != nil {
0 commit comments