55 "encoding/json"
66 "fmt"
77 "reflect"
8- "strings"
98 "time"
109
1110 "github.com/cloudquery/plugin-sdk/v4/plugin"
@@ -41,23 +40,9 @@ func newResource(p *plugin.Plugin) *resource.Resource {
4140 return r
4241}
4342
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-
5643type otelConfig struct {
5744 endpoint string
5845 insecure bool
59- headers []string
60- urlPath string
6146}
6247
6348func getTraceExporter (ctx context.Context , opts otelConfig ) (* otlptrace.Exporter , error ) {
@@ -73,15 +58,6 @@ func getTraceExporter(ctx context.Context, opts otelConfig) (*otlptrace.Exporter
7358 traceOptions = append (traceOptions , otlptracehttp .WithInsecure ())
7459 }
7560
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-
8561 traceClient := otlptracehttp .NewClient (traceOptions ... )
8662 traceExporter , err := otlptrace .New (ctx , traceClient )
8763 if err != nil {
@@ -104,15 +80,6 @@ func getMetricReader(ctx context.Context, opts otelConfig) (*metric.PeriodicRead
10480 metricOptions = append (metricOptions , otlpmetrichttp .WithInsecure ())
10581 }
10682
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-
11683 metricExporter , err := otlpmetrichttp .New (ctx , metricOptions ... )
11784 if err != nil {
11885 return nil , fmt .Errorf ("creating OTLP metric exporter: %w" , err )
@@ -136,15 +103,6 @@ func getLogsProcessor(ctx context.Context, opts otelConfig) (*log.BatchProcessor
136103 logOptions = append (logOptions , otlploghttp .WithInsecure ())
137104 }
138105
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-
148106 exporter , err := otlploghttp .New (ctx , logOptions ... )
149107 if err != nil {
150108 return nil , fmt .Errorf ("creating OTLP log exporter: %w" , err )
@@ -154,15 +112,13 @@ func getLogsProcessor(ctx context.Context, opts otelConfig) (*log.BatchProcessor
154112 return processor , nil
155113}
156114
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 ) {
158116 if otelEndpoint == "" {
159117 return nil , nil
160118 }
161119 opts := otelConfig {
162120 endpoint : otelEndpoint ,
163121 insecure : otelEndpointInsecure ,
164- headers : otelEndpointHeaders ,
165- urlPath : otelEndpointURLPath ,
166122 }
167123 traceExporter , err := getTraceExporter (ctx , opts )
168124 if err != nil {
0 commit comments