blob: 5da70351d91d043794a3f75383f0339564c1ebe1 [file] [log] [blame]
Girish Gowdra631ef3d2020-06-15 10:45:52 -07001// Copyright (c) 2017 Uber Technologies, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package jaeger
16
17// HeadersConfig contains the values for the header keys that Jaeger will use.
18// These values may be either custom or default depending on whether custom
19// values were provided via a configuration.
20type HeadersConfig struct {
21 // JaegerDebugHeader is the name of HTTP header or a TextMap carrier key which,
22 // if found in the carrier, forces the trace to be sampled as "debug" trace.
23 // The value of the header is recorded as the tag on the root span, so that the
24 // trace can be found in the UI using this value as a correlation ID.
25 JaegerDebugHeader string `yaml:"jaegerDebugHeader"`
26
27 // JaegerBaggageHeader is the name of the HTTP header that is used to submit baggage.
28 // It differs from TraceBaggageHeaderPrefix in that it can be used only in cases where
29 // a root span does not exist.
30 JaegerBaggageHeader string `yaml:"jaegerBaggageHeader"`
31
32 // TraceContextHeaderName is the http header name used to propagate tracing context.
33 // This must be in lower-case to avoid mismatches when decoding incoming headers.
34 TraceContextHeaderName string `yaml:"TraceContextHeaderName"`
35
36 // TraceBaggageHeaderPrefix is the prefix for http headers used to propagate baggage.
37 // This must be in lower-case to avoid mismatches when decoding incoming headers.
38 TraceBaggageHeaderPrefix string `yaml:"traceBaggageHeaderPrefix"`
39}
40
41// ApplyDefaults sets missing configuration keys to default values
42func (c *HeadersConfig) ApplyDefaults() *HeadersConfig {
43 if c.JaegerBaggageHeader == "" {
44 c.JaegerBaggageHeader = JaegerBaggageHeader
45 }
46 if c.JaegerDebugHeader == "" {
47 c.JaegerDebugHeader = JaegerDebugHeader
48 }
49 if c.TraceBaggageHeaderPrefix == "" {
50 c.TraceBaggageHeaderPrefix = TraceBaggageHeaderPrefix
51 }
52 if c.TraceContextHeaderName == "" {
53 c.TraceContextHeaderName = TraceContextHeaderName
54 }
55 return c
56}
57
58func getDefaultHeadersConfig() *HeadersConfig {
59 return &HeadersConfig{
60 JaegerDebugHeader: JaegerDebugHeader,
61 JaegerBaggageHeader: JaegerBaggageHeader,
62 TraceContextHeaderName: TraceContextHeaderName,
63 TraceBaggageHeaderPrefix: TraceBaggageHeaderPrefix,
64 }
65}