tracing

package
v1.69.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package tracing implements the OpenTelemetry carrier for context propagation in gRPC tracing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IncomingCarrier

type IncomingCarrier struct {
	// contains filtered or unexported fields
}

IncomingCarrier is a TextMapCarrier that uses incoming `context.Context` to retrieve any propagated key-value pairs in text format.

func NewIncomingCarrier

func NewIncomingCarrier(ctx context.Context) *IncomingCarrier

NewIncomingCarrier creates a new `IncomingCarrier` with the given context. The incoming carrier should be used with propagator's `Extract()` method in the incoming rpc path.

func (*IncomingCarrier) Context

func (c *IncomingCarrier) Context() context.Context

Context returns the underlying context associated with the `IncomingCarrier“.

func (*IncomingCarrier) Get

func (c *IncomingCarrier) Get(key string) string

Get returns the string value associated with the passed key from the carrier's incoming context metadata.

It returns an empty string if the key is not present in the carrier's context or if the value associated with the key is empty.

If multiple values are present for a key, it returns the last one.

func (*IncomingCarrier) Keys

func (c *IncomingCarrier) Keys() []string

Keys returns the keys stored in the carrier's context metadata. It returns keys from incoming context metadata.

func (*IncomingCarrier) Set

func (c *IncomingCarrier) Set(string, string)

Set just logs an error. It implements the `TextMapCarrier` interface but should not be used with `IncomingCarrier`.

type OutgoingCarrier

type OutgoingCarrier struct {
	// contains filtered or unexported fields
}

OutgoingCarrier is a TextMapCarrier that uses outgoing `context.Context` to store any propagated key-value pairs in text format.

func NewOutgoingCarrier

func NewOutgoingCarrier(ctx context.Context) *OutgoingCarrier

NewOutgoingCarrier creates a new Carrier with the given context. The outgoing carrier should be used with propagator's `Inject()` method in the outgoing rpc path.

func (*OutgoingCarrier) Context

func (c *OutgoingCarrier) Context() context.Context

Context returns the underlying context associated with the `OutgoingCarrier“.

func (*OutgoingCarrier) Get

func (c *OutgoingCarrier) Get(string) string

Get just logs an error and returns an empty string. It implements the `TextMapCarrier` interface but should not be used with `OutgoingCarrier`.

func (*OutgoingCarrier) Keys

func (c *OutgoingCarrier) Keys() []string

Keys returns the keys stored in the carrier's context metadata. It returns keys from outgoing context metadata.

func (*OutgoingCarrier) Set

func (c *OutgoingCarrier) Set(key, value string)

Set stores the key-value pair in the carrier's outgoing context metadata.

If the key already exists, given value is appended to the last.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL