opentelemetry_honeycomb v0.5.0-rc.1 OpenTelemetry.Honeycomb View Source
opentelemetry_honeycomb provides an in-process OpenTelemetry exporter for Honeycomb.
Installation
Add opentelemetry, opentelemetry_api, and opentelemetry_honeycomb to your deps in
mix.exs:
{:opentelemetry, "~> 0.5.0"},
{:opentelemetry_api, "~> 0.5.0"},
{:opentelemetry_honeycomb, "~> 0.5.0-rc.1"},
If you're using the default back ends, you'll also need hackney and poison:
{:hackney, ">= 1.11.0"},
{:poison, ">= 1.5.0"},
Configuration
A compact config/config.exs for opentelemetry_honeycomb is:
use Config
# You can also supply opentelemetry resources using environment variables, eg.:
# OTEL_RESOURCE_ATTRIBUTES=service.name=name,service.namespace=namespace
config :opentelemetry, :resource,
service: [
name: "service-name",
namespace: "service-namespace"
]
config :opentelemetry,
processors: [
otel_batch_processor: %{
exporter:
{OpenTelemetry.Honeycomb.Exporter, write_key: System.get_env("HONEYCOMB_WRITEKEY")}
}
]
processors specifies otel_batch_processor, which specifies exporter, a 2-tuple of the
exporter's module name and options to be supplied to its init/1. Our exporter takes a list of
OpenTelemetry.Honeycomb.Config.config_opt/0 as its options.
Attribute Handling
OpenTelemetry supports a flat map of attribute keys to string, number, and boolean values (see
t.OpenTelemetry.attribute_value/0). The API does not enforce this, implicitly supporting other
attribute value types eg. maps until export time.
Honeycomb expects a flat JSON-serialisable object, but can be configured to flatten maps and stringify arrays at import time.
The data models being quite similar, we:
- Pass string, number, and boolean values through unmodified
- Flatten map values as described below
- Convert most other values to strings using
inspect/1with a shortlimit - Trim string values longer than 49127 bytes
When trimming strings, we replace the last 3-7 characters of the trimmed string or so with an
ellipsis ("...") of equal length. We choose the length of the ellipsis to avoid ending the
trimmed string with a high-bit character, eg. splitting a UTF-8 code point.
We drop:
- Entire attribute lists that don't start as a list or map
- Entire list members that don't resemble key/value pairs
When flattening maps, we use periods (.) to delimit keys, for example this input:
%{
http: %{
host: "localhost",
method: "POST",
path: "/api"
}
}
... to this output:
%{
"http.host" => "localhost",
"http.method" => "POST",
"http.path" => "/api",
}
Link to this section Summary
Link to this section Functions
Get the version string for the OpenTelemetry Honeycomb exporter.