diff --git a/exporters/otlp/otlptrace/otlptracehttp/client.go b/exporters/otlp/otlptrace/otlptracehttp/client.go index 3a3cfec0cde..b68386ec79b 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/client.go +++ b/exporters/otlp/otlptrace/otlptracehttp/client.go @@ -203,7 +203,7 @@ func (d *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc } func (d *client) newRequest(body []byte) (request, error) { - u := url.URL{Scheme: d.getScheme(), Host: d.cfg.Endpoint, Path: d.cfg.URLPath} + u := url.URL{Scheme: d.getScheme(), Host: d.cfg.Endpoint, Path: d.cfg.URLPath, RawQuery: d.getRawQuery()} r, err := http.NewRequest(http.MethodPost, u.String(), nil) if err != nil { return request{Request: r}, err @@ -339,3 +339,12 @@ func (d *client) contextWithStop(ctx context.Context) (context.Context, context. }(ctx, cancel) return ctx, cancel } + +func (d *client) getRawQuery() string { + values := url.Values{} + for k, v := range d.cfg.Query { + values[k] = v + } + + return values.Encode() +} diff --git a/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go b/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go index 9a595c36a62..96981af212f 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go +++ b/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go @@ -52,6 +52,7 @@ type ( Compression Compression Timeout time.Duration URLPath string + Query map[string][]string // gRPC configurations GRPCCredentials credentials.TransportCredentials @@ -326,3 +327,10 @@ func WithTimeout(duration time.Duration) GenericOption { return cfg }) } + +func WithQuery(query map[string][]string) GenericOption { + return newGenericOption(func(cfg Config) Config { + cfg.Traces.Query = query + return cfg + }) +} diff --git a/exporters/otlp/otlptrace/otlptracehttp/options.go b/exporters/otlp/otlptrace/otlptracehttp/options.go index e3ed6494c5d..bdc21681468 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/options.go +++ b/exporters/otlp/otlptrace/otlptracehttp/options.go @@ -114,3 +114,8 @@ func WithTimeout(duration time.Duration) Option { func WithRetry(rc RetryConfig) Option { return wrappedOption{otlpconfig.WithRetry(retry.Config(rc))} } + +// WithQuery allows one to tell the driver to send query values with the payloads. +func WithQuery(query map[string][]string) Option { + return wrappedOption{otlpconfig.WithQuery(query)} +}