Skip to content

Commit 8f20a07

Browse files
authored
chore: Remove unused OTEL flags (#1896)
#### Summary `otel-endpoint-urlpath` and `otel-endpoint-headers` are not documented, cannot be used via a spec option like `otel-endpoint` and `otel-endpoint-insecure` (only via direct invocation of the plugin's binary), and make it harder to support multiple endpoints. This PR removes them until we actually need them ---
1 parent e1823f8 commit 8f20a07

File tree

2 files changed

+2
-50
lines changed

2 files changed

+2
-50
lines changed

serve/opentelemetry.go

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
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-
5643
type otelConfig struct {
5744
endpoint string
5845
insecure bool
59-
headers []string
60-
urlPath string
6146
}
6247

6348
func 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 {

serve/plugin.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ func (s *PluginServe) newCmdPluginServe() *cobra.Command {
106106
var network string
107107
var noSentry bool
108108
var otelEndpoint string
109-
var otelEndpointHeaders []string
110109
var otelEndpointInsecure bool
111-
var otelEndpointURLPath string
112110
var licenseFile string
113111
logLevel := newEnum([]string{"trace", "debug", "info", "warn", "error"}, "info")
114112
logFormat := newEnum([]string{"text", "json"}, "text")
@@ -136,7 +134,7 @@ func (s *PluginServe) newCmdPluginServe() *cobra.Command {
136134
logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout}).Level(zerologLevel)
137135
}
138136

139-
shutdown, err := setupOtel(cmd.Context(), logger, s.plugin, otelEndpoint, otelEndpointInsecure, otelEndpointHeaders, otelEndpointURLPath)
137+
shutdown, err := setupOtel(cmd.Context(), logger, s.plugin, otelEndpoint, otelEndpointInsecure)
140138
if err != nil {
141139
return fmt.Errorf("failed to setup OpenTelemetry: %w", err)
142140
}
@@ -234,8 +232,6 @@ func (s *PluginServe) newCmdPluginServe() *cobra.Command {
234232
cmd.Flags().Var(logLevel, "log-level", fmt.Sprintf("log level. one of: %s", strings.Join(logLevel.Allowed, ",")))
235233
cmd.Flags().Var(logFormat, "log-format", fmt.Sprintf("log format. one of: %s", strings.Join(logFormat.Allowed, ",")))
236234
cmd.Flags().StringVar(&otelEndpoint, "otel-endpoint", "", "Open Telemetry HTTP collector endpoint")
237-
cmd.Flags().StringVar(&otelEndpointURLPath, "otel-endpoint-urlpath", "", "Open Telemetry HTTP collector endpoint URL path")
238-
cmd.Flags().StringArrayVar(&otelEndpointHeaders, "otel-endpoint-headers", []string{}, "Open Telemetry HTTP collector endpoint headers")
239235
cmd.Flags().BoolVar(&otelEndpointInsecure, "otel-endpoint-insecure", false, "use Open Telemetry HTTP endpoint (for development only)")
240236
cmd.Flags().BoolVar(&noSentry, "no-sentry", false, "disable sentry")
241237
cmd.Flags().StringVar(&licenseFile, "license", "", "Path to offline license file or directory")

0 commit comments

Comments
 (0)