Documentation

Overview

    Package propagation provides support for propagating context over HTTP.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func ExtractHTTP

    func ExtractHTTP(ctx context.Context, props Propagators, supplier HTTPSupplier) context.Context

      ExtractHTTP applies props.HTTPExtractors() to the passed context and the supplier and returns the combined result context.

      func InjectHTTP

      func InjectHTTP(ctx context.Context, props Propagators, supplier HTTPSupplier)

        InjectHTTP applies props.HTTPInjectors() to the passed context and the supplier.

        Types

        type Config

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

          Config contains the current set of extractors and injectors.

          type HTTPExtractor

          type HTTPExtractor interface {
          	// Extract method retrieves encoded information using supplier
          	// from the associated carrier, decodes it and creates a new
          	// context containing the decoded information.
          	//
          	// Information can be a correlation context or a remote span
          	// context. In case of span context, the propagator should
          	// store it in the context using
          	// trace.ContextWithRemoteSpanContext. In case of correlation
          	// context, the propagator should use correlation.WithMap to
          	// store it in the context.
          	Extract(ctx context.Context, supplier HTTPSupplier) context.Context
          }

            HTTPExtractor extracts information from a HTTPSupplier into a context.

            type HTTPInjector

            type HTTPInjector interface {
            	// Inject method retrieves information from the context,
            	// encodes it into propagator specific format and then injects
            	// the encoded information using supplier into an associated
            	// carrier.
            	Inject(ctx context.Context, supplier HTTPSupplier)
            }

              HTTPInjector injects information into a HTTPSupplier.

              type HTTPPropagator

              type HTTPPropagator interface {
              	HTTPInjector
              	HTTPExtractor
              
              	// GetAllKeys returns the HTTP header names used.
              	GetAllKeys() []string
              }

                HTTPPropagator is the interface to inject to and extract from HTTPSupplier.

                type HTTPSupplier

                type HTTPSupplier interface {
                	// Get method retrieves a single value for a given key.
                	Get(key string) string
                	// Set method stores a single value for a given key. Note that
                	// this should not be appending a value to some array, but
                	// rather overwrite the old value.
                	Set(key string, value string)
                }

                  HTTPSupplier is an interface that specifies methods to retrieve and store a single value for a key to an associated carrier. It is implemented by http.Headers.

                  type Option

                  type Option func(*Config)

                    Option support passing configuration parameters to New().

                    func WithExtractors

                    func WithExtractors(ext ...HTTPExtractor) Option

                      WithExtractors appends to the optional extractor set.

                      func WithInjectors

                      func WithInjectors(inj ...HTTPInjector) Option

                        WithInjectors appends to the optional injector set.

                        type Propagators

                        type Propagators interface {
                        	// HTTPExtractors returns the configured extractors.
                        	HTTPExtractors() []HTTPExtractor
                        
                        	// HTTPInjectors returns the configured injectors.
                        	HTTPInjectors() []HTTPInjector
                        }

                          Propagators is the interface to a set of injectors and extractors for all supported carrier formats. It can be used to chain multiple propagators into a single entity.

                          func New

                          func New(options ...Option) Propagators

                            New returns a standard Propagators implementation.