View Source OtelMetricExporter (OTel Metric Exporter v0.2.2)
This is a telemetry
exporter that collects specified metrics
and then exports them to an OTel endpoint. It uses metric definitions
from :telemetry_metrics
library.
Example usage:
OtelMetricExporter.start_link(
otlp_protocol: :http_protobuf,
otlp_endpoint: otlp_endpoint,
otlp_headers: headers,
otlp_compression: :gzip,
export_period: :timer.seconds(30),
metrics: [
Telemetry.Metrics.counter("plug.request.stop.duration"),
Telemetry.Metrics.sum("plug.request.stop.duration"),
Telemetry.Metrics.last_value("plug.request.stop.duration"),
Telemetry.Metrics.distribution("plug.request.stop.duration",
reporter_options: [buckets: [0, 10, 100, 1000]] # Optional histogram buckets.
),
]
)
Default histogram buckets are [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000]
See all available options in start_link/2
documentation. Options provided to the start_link/2
function will be merged with the options provided via config :otel_metric_exporter
configuraiton.
Summary
Functions
Returns a specification to start this module under a supervisor.
Start the exporter. It maintains some pieces of global state: ets table and a :persistent_term
key.
This means that only one exporter instance can be started at a time.
Types
@type compression() :: :gzip | nil
@type option() :: {:metrics, [Telemetry.Metrics.t()]} | {:otlp_endpoint, binary()} | {:otlp_protocol, protocol()} | {:otlp_headers, %{optional(binary()) => binary()}} | {:otlp_compression, compression()} | {:resource, map()} | {:export_period, pos_integer()}
@type protocol() :: :http_protobuf | :http_json
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec start_link([option()]) :: Supervisor.on_start()
Start the exporter. It maintains some pieces of global state: ets table and a :persistent_term
key.
This means that only one exporter instance can be started at a time.
Options
Options can be provided directly or specified in the config :otel_metric_exporter
configuration. It's recommended
to configure global options in :otel_metric_exporter
config, and specify metrics where you add this module to the
supervision tree.
:metrics
- Required. List of telemetry metrics to track.:otlp_endpoint
(String.t/0
) - Required. Endpoint to send metrics to.:otlp_protocol
- Protocol to use for OTLP export. Currently only :http_protobuf and :http_json are supported. The default value is:http_protobuf
.:otlp_headers
(map ofString.t/0
keys andString.t/0
values) - Headers to send with OTLP requests. The default value is%{}
.:otlp_compression
- Compression to use for OTLP requests. Allowed values are:gzip
andnil
. The default value is:gzip
.:resource
(map/0
) - Resource attributes to send with metrics. The default value is%{}
.:export_period
(pos_integer/0
) - Period in milliseconds between metric exports. The default value is60000
.