Skip to content

Commit

Permalink
[chore] add headers to request
Browse files Browse the repository at this point in the history
  • Loading branch information
EOjeah committed Jan 19, 2024
1 parent d8a5384 commit bfc803c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions exporter/zipkinexporter/zipkin.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func (ze *zipkinExporter) pushTraces(ctx context.Context, td ptrace.Traces) erro
if err != nil {
return fmt.Errorf("failed to push trace data via Zipkin exporter: %w", err)
}
for k, v := range ze.clientSettings.Headers {
req.Header.Set(k, string(v))
}
req.Header.Set("Content-Type", ze.serializer.ContentType())

resp, err := ze.client.Do(req)
Expand Down
3 changes: 2 additions & 1 deletion exporter/zipkinexporter/zipkin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"context"
"fmt"
"go.opentelemetry.io/collector/config/configopaque"
"io"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -43,13 +44,13 @@ func TestZipkinExporter_roundtripJSON(t *testing.T) {
cst := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
s, _ := io.Copy(buf, r.Body)
sizes = append(sizes, s)
r.Body.Close()
}))
defer cst.Close()

cfg := &Config{
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: cst.URL,
Headers: map[string]configopaque.String{"extra-header": "header-value"},
},
Format: "json",
}
Expand Down

0 comments on commit bfc803c

Please sign in to comment.