Documentation
¶
Index ¶
- func ExtractFromBase64Carrier(ctx context.Context, carrier TextMapReader) (outCtx context.Context)
- func InjectToBase64Carrier(ctx context.Context, carrier TextMapWriter)
- func MergeContexts(ctxs ...context.Context) context.Context
- type Pathway
- type TextMapReader
- type TextMapReaderByKey
- type TextMapWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFromBase64Carrier ¶
func ExtractFromBase64Carrier(ctx context.Context, carrier TextMapReader) (outCtx context.Context)
ExtractFromBase64Carrier extracts the pathway context from a carrier to a context object
func InjectToBase64Carrier ¶
func InjectToBase64Carrier(ctx context.Context, carrier TextMapWriter)
InjectToBase64Carrier injects a pathway context from a context object inta a carrier
func MergeContexts ¶
MergeContexts returns the first context which includes the pathway resulting from merging the pathways contained in all contexts. This function should be used in fan-in situations. The current implementation keeps only 1 Pathway. A future implementation could merge multiple Pathways together and put the resulting Pathway in the context.
Types ¶
type Pathway ¶
type Pathway interface {
// GetHash returns the hash of the pathway, representing the upstream path of the data.
GetHash() uint64
}
type TextMapReader ¶
type TextMapReader interface {
// ForeachKey iterates over all keys that exist in the underlying
// carrier. It takes a callback function which will be called
// using all key/value pairs as arguments. ForeachKey will return
// the first error returned by the handler.
ForeachKey(handler func(key, val string) error) error
}
TextMapReader allows iterating over sets of key/value pairs. Carriers implementing TextMapReader are compatible to be used with Datadog's TextMapPropagator.
type TextMapReaderByKey ¶
type TextMapReaderByKey interface {
// Get returns the value for key, and whether it was present.
Get(key string) (val string, ok bool)
}
TextMapReaderByKey is an optional interface a carrier can implement to return a single key directly. Extraction only needs the pathway key (PropagationKeyBase64), but the generic ForeachKey contract forces the carrier to produce a string value for every entry it holds. Carriers backed by many/large entries (e.g. Kafka message headers) should implement this to avoid converting every entry's value to a string on the consume hot path when only the pathway key is used.
type TextMapWriter ¶
type TextMapWriter interface {
// Set sets the given key/value pair.
Set(key, val string)
}
TextMapWriter allows setting key/value pairs of strings on the underlying data structure. Carriers implementing TextMapWriter are compatible to be used with Datadog's TextMapPropagator.