Skip to content

Commit

Permalink
Remove tenant_header_key from config (#2414)
Browse files Browse the repository at this point in the history
* Remove tenant_header_key from config

* Add changelog entry

* Update changelog entry from enhancement to change
  • Loading branch information
kousikmitra authored May 5, 2023
1 parent 3f562c6 commit affcf7c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## main / unreleased

* [CHANGE] Remove `tenant_header_key` option from `tempo-query` config [#2414](https://github.com/grafana/tempo/pull/2414) (@kousikmitra)
* [ENHANCEMENT] Add `prefix` configuration option to `storage.trace.azure` and `storage.trace.gcs` [#2362](https://github.com/grafana/tempo/pull/2386) (@kousikmitra)
* [CHANGE] **Breaking Change** Remove support tolerate_failed_blocks. [#2416](https://github.com/grafana/tempo/pull/2416) (@joe-elliott)
Removed config option:
```
Expand Down
14 changes: 3 additions & 11 deletions cmd/tempo-query/tempo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ package tempo

import (
"github.com/grafana/dskit/crypto/tls"
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared"
"github.com/spf13/viper"
)

// Config holds the configuration for redbull.
type Config struct {
Backend string `yaml:"backend"`
TLSEnabled bool `yaml:"tls_enabled" category:"advanced"`
TLS tls.ClientConfig `yaml:",inline"`
TenantHeaderKey string `yaml:"tenant_header_key"`
Backend string `yaml:"backend"`
TLSEnabled bool `yaml:"tls_enabled" category:"advanced"`
TLS tls.ClientConfig `yaml:",inline"`
}

// InitFromViper initializes the options struct with values from Viper
Expand All @@ -25,10 +23,4 @@ func (c *Config) InitFromViper(v *viper.Viper) {
c.TLS.InsecureSkipVerify = v.GetBool("tls_insecure_skip_verify")
c.TLS.CipherSuites = v.GetString("tls_cipher_suites")
c.TLS.MinVersion = v.GetString("tls_min_version")

tenantHeader := v.GetString("tenant_header_key")
if tenantHeader == "" {
tenantHeader = shared.BearerTokenKey
}
c.TenantHeaderKey = tenantHeader
}
25 changes: 12 additions & 13 deletions cmd/tempo-query/tempo/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"google.golang.org/grpc/metadata"

jaeger "github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared"
jaeger_spanstore "github.com/jaegertracing/jaeger/storage/spanstore"

ot_jaeger "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger"
Expand Down Expand Up @@ -53,11 +54,10 @@ var tlsVersions = map[string]uint16{
}

type Backend struct {
tempoBackend string
tlsEnabled bool
tls tlsCfg.ClientConfig
httpClient *http.Client
tenantHeaderKey string
tempoBackend string
tlsEnabled bool
tls tlsCfg.ClientConfig
httpClient *http.Client
}

func New(cfg *Config) (*Backend, error) {
Expand All @@ -66,11 +66,10 @@ func New(cfg *Config) (*Backend, error) {
return nil, err
}
return &Backend{
tempoBackend: cfg.Backend,
tlsEnabled: cfg.TLSEnabled,
tls: cfg.TLS,
httpClient: httpClient,
tenantHeaderKey: cfg.TenantHeaderKey,
tempoBackend: cfg.Backend,
tlsEnabled: cfg.TLSEnabled,
tls: cfg.TLS,
httpClient: httpClient,
}, nil
}

Expand Down Expand Up @@ -438,17 +437,17 @@ func (b *Backend) newGetRequest(ctx context.Context, url string, span opentracin

// currently Jaeger Query will only propagate bearer token to the grpc backend and no other headers
// so we are going to extract the tenant id from the header, if it exists and use it
tenantID, found := extractBearerToken(ctx, b.tenantHeaderKey)
tenantID, found := extractBearerToken(ctx)
if found {
req.Header.Set(user.OrgIDHeaderName, tenantID)
}

return req, nil
}

func extractBearerToken(ctx context.Context, tenantHeader string) (string, bool) {
func extractBearerToken(ctx context.Context) (string, bool) {
if md, ok := metadata.FromIncomingContext(ctx); ok {
values := md.Get(tenantHeader)
values := md.Get(shared.BearerTokenKey)
if len(values) > 0 {
return values[0], true
}
Expand Down

0 comments on commit affcf7c

Please sign in to comment.