O11y (O11y v0.1.0)

A module to help with OpenTelemetry tracing.

Summary

Functions

Sets the given attribute on the current span. If the value is not a valid OTLP type, it will be converted to a string with inspect.

Adds the given attributes as a list, map, or struct to the current span. If the value is a maps or struct, it will be converted to a list of key-value pairs. If the struct derives the O11y.SpanAttributes protocol, it will honor the except and only options.

Same as set_attributes/1, but with a prefix for all keys.

Functions

Link to this function

set_attribute(key, value)

Sets the given attribute on the current span. If the value is not a valid OTLP type, it will be converted to a string with inspect.

This method does not support structs to maps, regardless of whether the struct implements the O11y.SpanAttributes protocol. You need to use set_attributes/1 for that.

Example:

iex> set_attribute("key", "value")

Link to this function

set_attributes(values)

Adds the given attributes as a list, map, or struct to the current span. If the value is a maps or struct, it will be converted to a list of key-value pairs. If the struct derives the O11y.SpanAttributes protocol, it will honor the except and only options.

Example:

iex> set_attributes(%{key: "value"})

Link to this function

set_attributes(prefix, values)

Same as set_attributes/1, but with a prefix for all keys.

Example:

iex> set_attributes("my_prefix", %{key: "value"})