opencensus_honeycomb v0.3.0 Opencensus.Honeycomb.Event
Event structure.
Honeycomb events bind a timestamp to data as described in t/0
below. The data
corresponds
to Opencensus span attributes, with limitations dictated by the intersection of OpenCensus' and
Honeycomb's data models.
Supported Value Types
Honeycomb
Honeycomb supports events (spans, when strung together in a trace) with dozens or hundreds of attributes. Keys MUST be strings, like in OpenCensus. Values MUST be JSON encodable, but MAY include objects (Elixir maps) and arrays -- neither of which are supported by OpenCensus.
Honeycomb makes no distinction between measurements and metadata, unlike :telemetry
.
Honeycomb's keys for trace handling can be configured on a per-dataset basis, but default to:
duration_ms
name
service_name
trace.parent_id
trace.span_id
trace.trace_id
OpenCensus
To be compatible with the OpenCensus protobuf protocol, attribute values MUST be one of:
TruncatableString
int64
bool_value
double_value
Opencensus.Honeycomb
The data models being quite similar, the Jason.Encoder
implementation for
Opencensus.Honeycomb.Event.t/0
:
- Flattens map values as described below
- Converts atom keys and values to strings
- Drops any other values not compatible with the OpenCensus protobuf definition
- Over-writes any keys that clash with the default trace handling keys
Flattening
Map flattening uses periods (.
) to delimit keys from nested maps, much like can be configured
on a dataset basis at the Honeycomb end. These span attributes before flattening:
%{
http: %{
host: "localhost",
method: "POST",
path: "/api"
}
}
... becomes this event after flattening:
%{
"http.host" => "localhost",
"http.method" => "POST",
"http.path" => "/api",
}
Link to this section Summary
Functions
Convert one OpenCensus span to an event suitable for POSTing to the Honeycomb Events API.
The current UTC time in ISO 8601 format, e.g. "2019-05-17T09:55:12.622658Z"
Link to this section Types
Span attributes after flattening.
See attribute limitations for important detail on span attribute names and values.
t()
t() :: %Opencensus.Honeycomb.Event{ data: event_data(), samplerate: pos_integer(), time: String.t() }
Honeycomb event suitable for POSTing to their batch API.
time
: ms since epoch; MUST be in ISO 8601 format, e.g."2019-05-17T09:55:12.622658Z"
data
:event_data/0
after flattening.samplerate
: Sample rate expressed as 1/N, so 4 means 1/4 events made it to HC.
Link to this section Functions
from_oc_span(record, service_name, samplerate_key)
from_oc_span(:opencensus.span(), String.t(), String.t()) :: t()
Convert one OpenCensus span to an event suitable for POSTing to the Honeycomb Events API.
See attribute limitations for important detail on span attribute names and values.
The current UTC time in ISO 8601 format, e.g. "2019-05-17T09:55:12.622658Z"
Useful when creating events manually.