Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(agent): return correct cors headers for ingestion endpoint #3976

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
var (
Version = "dev"
Env = "dev"
DefaultCloudEndpoint = "http://app.tracetest.io"
DefaultCloudEndpoint = "https://app.tracetest.io"
DefaultCloudDomain = "tracetest.io"
DefaultCloudPath = "/"
)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ require (
github.com/prometheus/prometheus v1.8.2-0.20211217191541-41f1a8125e66
github.com/pterm/pterm v0.12.69
github.com/rivo/tview v0.0.0-20240122063236-8526c9fe1b54
github.com/rs/cors v1.8.0
github.com/segmentio/analytics-go/v3 v3.2.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so=
github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
Expand Down
15 changes: 14 additions & 1 deletion server/otlp/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/rs/cors"
"go.uber.org/zap"

"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp"
Expand Down Expand Up @@ -51,9 +52,21 @@ func (s *httpServer) Start() error {
r := mux.NewRouter()
r.HandleFunc("/v1/traces", s.Export).Methods("POST")

h := decompressBodyHandler(
s.logger,
handlers.ContentTypeHandler(r, protoBufContentType, jsonContentType),
)
h = handlers.CompressHandler(h)
h = cors.New(cors.Options{
AllowOriginFunc: func(origin string) bool {
return true
},
AllowCredentials: true,
}).Handler(h)

s.hServer = &http.Server{
Addr: s.addr,
Handler: handlers.CompressHandler(decompressBodyHandler(s.logger, handlers.ContentTypeHandler(r, protoBufContentType, jsonContentType))),
Handler: h,
}
listener, err := net.Listen("tcp", s.addr)
if err != nil {
Expand Down
Loading