View Source opentelemetry_exporter (opentelemetry_exporter v1.7.0)

This is the module providing the OpenTelemetry protocol for exporting traces. It can be configured through its application environment, the OS environment or directly through a map of options passed when setting up the exporter in the batch processor.

opentelemetry_exporter application environment options are:

  • otlp_endpoint: The URL to send traces and metrics to, for traces the path v1/traces is appended to the path in the URL.
  • otlp_traces_endpoint: URL to send only traces to. This takes precedence for exporting traces and the path of the URL is kept as is, no suffix is appended.
  • otlp_headers: List of additional headers ([{unicode:chardata(), unicode:chardata()}]) to add to export requests.
  • otlp_traces_headers: Additional headers ([{unicode:chardata(), unicode:chardata()}]) to add to only trace export requests.
  • otlp_protocol: The transport protocol, supported values: grpc and http_protobuf. Defaults to http_protobuf.
  • otlp_traces_protocol: The transport protocol to use for exporting traces, supported values: grpc and http_protobuf. Defaults to http_protobuf
  • otlp_compression: Compression type to use, supported values: gzip. Defaults to no compression.
  • otlp_traces_compression: Compression type to use for exporting traces, supported values: gzip. Defaults to no compression.

There also corresponding OS environment variables can also set those configuration values:

  • OTEL_EXPORTER_OTLP_ENDPOINT: The URL to send traces and metrics to, for traces the path v1/traces is appended to the path in the URL.
  • OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: URL to send only traces to. This takes precedence for exporting traces and the path of the URL is kept as is, no suffix is appended.
  • OTEL_EXPORTER_OTLP_HEADERS: List of additional headers to add to export requests.
  • OTEL_EXPORTER_OTLP_TRACES_HEADERS: Additional headers to add to only trace export requests.
  • OTEL_EXPORTER_OTLP_PROTOCOL: The transport protocol to use, supported values: grpc and http_protobuf. Defaults to http_protobuf.
  • OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: The transport protocol to use for exporting traces, supported values: grpc and http_protobuf. Defaults to http_protobuf.
  • OTEL_EXPORTER_OTLP_COMPRESSION: Compression to use, supported value: gzip. Defaults to no compression.
  • OTEL_EXPORTER_OTLP_TRACES_COMPRESSION: Compression to use when exporting traces, supported value: gzip. Defaults to no compression.
You can also set these configuration values in the map passed to the opentelemetry processor configuration.
  • endpoints: A list of endpoints to send traces to. Can take one of the forms described below. By default, exporter sends data to http://localhost:4318.
  • headers: List of additional headers to add to export requests.
  • protocol: The transport protocol to use, supported values: grpc and http_protobuf. Defaults to http_protobuf.
  • compression: Compression to use, supported value: gzip. Defaults to no compression.
  • ssl_options: a list of SSL options. See Erlang's SSL docs for what options are available.

Endpoints configuration

You can pass your collector endpoints in three forms:

  • As a string, i.e "https://localhost:4000".
  • As a map, with the following keys:
    • host => unicode:chardata()
    • path => unicode:chardata()
    • port => integer() >= 0 | undefined
    • scheme => unicode:chardata()
  • As a 4 element tuple in format {Scheme, Host, Port, SSLOptions}.
While using http_protobuf protocol, currently only the first endpoint in that list is used to export traces, the rest is effectively ignored. grpc supports multiple endpoints.

Link to this section Summary

Functions

Export OTLP protocol telemery data to the configured endpoints.
Initialize the exporter based on the provided configuration.
Shutdown the exporter.

Link to this section Types

-type compression() :: gzip.
-type endpoint() :: uri_string:uri_string() | uri_string:uri_map().
-type endpoint_map() ::
    #{scheme := unicode:chardata(),
      host := unicode:chardata(),
      path => unicode:chardata(),
      port => integer(),
      ssl_options => []}.
-type headers() :: [{unicode:chardata(), unicode:chardata()}].
-type host() :: unicode:chardata().
-type input_endpoint() :: uri_string:uri_string() | uri_string:uri_map() | input_endpoint_map().
-type input_endpoint_map() ::
    #{scheme := scheme(),
      host := host(),
      path => unicode:chardata(),
      port => integer(),
      ssl_options => []}.
-type opts() ::
    #{endpoints => [input_endpoint()],
      headers => headers(),
      protocol => protocol(),
      ssl_options => list()}.
-type protocol() :: grpc | http_protobuf | http_json.
-type scheme() :: http | https | string() | binary().

Link to this section Functions

Link to this function

export(_, Tab, Resource, State)

View Source
Export OTLP protocol telemery data to the configured endpoints.
-spec init(opts()) -> {ok, #state{}}.
Initialize the exporter based on the provided configuration.
Shutdown the exporter.