headerssetter

package module
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Headers Setter extension

Status
Stability alpha
Distributions contrib

Deprecated: module github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetter is deprecated, use github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension instead.

The headers_setter extension implements ClientAuthenticator and is used to set requests headers in gRPC / HTTP exporters with values provided via extension configurations or requests metadata (context).

Use cases include but are not limited to enabling multi-tenancy for observability backends such as Tempo, Mimir, Loki and others by setting the X-Scope-OrgID header to the value extracted from the context.

Configuration

The following settings are required:

  • headers: a list of header configuration objects that specify headers and their value sources. Each configuration object has the following properties:
    • key: the header name
    • value: the header value is looked up from the value property of the extension configuration
    • from_context: the header value is looked up from the request metadata, such as HTTP headers, using the property value as the key (likely a header name)

The value and from_context properties are mutually exclusive.

Configuration Example
extensions:
  headers_setter:
    headers:
      - key: X-Scope-OrgID
        from_context: tenant_id
      - key: User-ID
        value: user_id

receivers:
  otlp:
    protocols:
      http:
        include_metadata: true

processors:
  nop:

exporters:
  loki:
    labels:
      resource:
        container_id: ""
        container_name: ""
    endpoint: https://localhost:<port>/loki/api/v1/push
    auth:
      authenticator: headers_setter

service:
  extensions: [ headers_setter ]
  pipelines:
    traces:
      receivers: [ otlp ]
      processors: [ nop ]
      exporters: [ loki ]

Limitations

At the moment, it is not possible to use the from_context option to ge the header value if Collector's pipeline contains the batch processor. See #4544.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() component.ExtensionFactory

NewFactory creates a factory for the headers setter extension.

Types

type Config

type Config struct {
	config.ExtensionSettings `mapstructure:",squash"`
	HeadersConfig            []HeaderConfig `mapstructure:"headers"`
}

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks if the extension configuration is valid

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

type HeaderConfig

type HeaderConfig struct {
	Key         *string `mapstructure:"key"`
	Value       *string `mapstructure:"value"`
	FromContext *string `mapstructure:"from_context"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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