mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Grpc streaming apis preserve some headers when sending jobs to the queriers * changelog
32 lines
452 B
Go
32 lines
452 B
Go
package frontend
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"google.golang.org/grpc/metadata"
|
|
)
|
|
|
|
var copyHeaders = []string{
|
|
"Authorization",
|
|
"X-Scope-OrgID",
|
|
}
|
|
|
|
func headersFromGrpcContext(ctx context.Context) (hs http.Header) {
|
|
hs = http.Header{}
|
|
|
|
md, ok := metadata.FromIncomingContext(ctx)
|
|
if !ok {
|
|
// Tests may not have metadata so skip
|
|
return
|
|
}
|
|
|
|
for _, h := range copyHeaders {
|
|
if v := md.Get(h); len(v) > 0 {
|
|
hs[h] = v
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|