View Source opentelemetry (opentelemetry_api v1.0.3)

The types defined here, and referencing records in opentelemetry.hrl are used to store trace information while being collected on the Erlang node.

Thus, while the types are based on protos found in the opentelemetry-proto repo: src/opentelemetry/proto/trace/v1/trace.proto, they are not exact translations because further processing is done after the span has finished and can be vendor specific. For example, there is no count of the number of dropped attributes in the span record. And an attribute's value can be a function to only evaluate the value if it is actually used (at the time of exporting). And the stacktrace is a regular Erlang stack trace.

Link to this section Summary

Functions

Convert a native monotonic timestamp to POSIX time of any erlang:time_unit(). Meaning the time since Epoch. Epoch is defined to be 00:00:00 UTC, 1970-01-01.
A monotonically increasing time provided by the Erlang runtime system in the native time unit. This value is the most accurate and precise timestamp available from the Erlang runtime and should be used for finding durations or any timestamp that can be converted to a system time before being sent to another system.
Convert a native monotonic timestamp to nanosecond POSIX time. Meaning the time since Epoch. Epoch is defined to be 00:00:00 UTC, 1970-01-01.

Link to this section Types

Specs

attribute() :: {attribute_key(), attribute_value()}.

Specs

attribute_key() :: unicode:unicode_binary() | atom().

Specs

attribute_value() ::
    unicode:unicode_binary() |
    atom() |
    number() |
    boolean() |
    [unicode:unicode_binary() | atom() | float() | integer() | boolean()] |
    {unicode:unicode_binary() | atom() | float() | integer() | boolean()}.

Specs

attributes_map() :: #{attribute_key() => attribute_value()} | [attribute()].

Specs

event() ::
    #{system_time_nano => non_neg_integer(), name := event_name(), attributes := attributes_map()}.

Specs

event_name() :: unicode:unicode_binary() | atom().

Specs

hex_span_id() :: binary().

Specs

hex_trace_id() :: binary().
Link to this type

instrumentation_library/0

View Source

Specs

instrumentation_library() :: #instrumentation_library{}.

Specs

link() ::
    #{trace_id := trace_id(),
      span_id := span_id(),
      attributes := attributes_map(),
      tracestate := tracestate()}.

Specs

Specs

span() :: term().

Specs

span_ctx() :: #span_ctx{}.

Specs

span_id() :: non_neg_integer().

Specs

span_kind() :: internal | server | client | producer | consumer.

Specs

span_name() :: unicode:unicode_binary() | atom().

Specs

status() :: #status{}.

Specs

status_code() :: unset | ok | error.

Specs

Specs

timestamp() :: integer().

Specs

trace_flags() :: non_neg_integer().

Specs

trace_id() :: non_neg_integer().

Specs

tracer() :: {module(), term()}.

Specs

Link to this section Functions

Link to this function

convert_timestamp(Timestamp, Unit)

View Source

Specs

convert_timestamp(timestamp(), erlang:time_unit()) -> integer().
Convert a native monotonic timestamp to POSIX time of any erlang:time_unit(). Meaning the time since Epoch. Epoch is defined to be 00:00:00 UTC, 1970-01-01.
Link to this function

create_application_tracers(Applications)

View Source

Specs

create_application_tracers([{Application, Description, Vsn}]) -> ok
                              when Application :: atom(), Description :: string(), Vsn :: string().

Specs

event(Name, Attributes) -> event() | undefined
         when Name :: event_name(), Attributes :: attributes_map().
Link to this function

event(Timestamp, Name, Attributes)

View Source

Specs

event(Timestamp, Name, Attributes) -> event() | undefined
         when Timestamp :: non_neg_integer(), Name :: event_name(), Attributes :: attributes_map().
Link to this function

get_application(ModuleName)

View Source

Specs

get_application(module()) -> ApplicationTuple
                   when
                       ApplicationTuple :: {Name, Vsn, SchemaUrl} | atom(),
                       Name :: atom(),
                       Vsn :: unicode:unicode_binary() | undefined,
                       SchemaUrl :: uri_string:uri_string() | undefined.
Link to this function

get_application_tracer(ModuleName)

View Source

Specs

get_application_tracer(module()) -> tracer().
Link to this function

get_text_map_extractor()

View Source

Specs

get_tracer() -> tracer().

Specs

get_tracer(Name) -> Tracer
              when
                  Name :: atom() | {Name, Vsn, SchemaUrl},
                  Vsn :: unicode:chardata() | undefined,
                  SchemaUrl :: uri_string:uri_string() | undefined,
                  Tracer :: opentelemetry:tracer().
Link to this function

get_tracer(Name, Vsn, SchemaUrl)

View Source

Specs

get_tracer(Name, Vsn, SchemaUrl) -> Tracer
              when
                  Name :: atom(),
                  Vsn :: unicode:chardata() | undefined,
                  SchemaUrl :: uri_string:uri_string() | undefined,
                  Tracer :: opentelemetry:tracer().
Link to this function

instrumentation_library(Name, Vsn, SchemaUrl)

View Source

Specs

link(span_ctx() | undefined) -> link().
Link to this function

link(Span_ctx, Attributes)

View Source

Specs

link(span_ctx() | undefined, attributes_map()) -> link().
Link to this function

link(TraceId, SpanId, Attributes, TraceState)

View Source

Specs

link(TraceId, SpanId, Attributes, TraceState) -> link() | undefined
        when
            TraceId :: trace_id(),
            SpanId :: span_id(),
            Attributes :: attributes_map(),
            TraceState :: tracestate().

Specs

links([{TraceId, SpanId, Attributes, TraceState} | span_ctx() | {span_ctx(), Attributes}]) ->
         [link()]
         when
             TraceId :: trace_id(),
             SpanId :: span_id(),
             Attributes :: attributes_map(),
             TraceState :: tracestate().
Link to this function

set_default_tracer(Tracer)

View Source

Specs

set_default_tracer(tracer()) -> boolean().
Link to this function

set_text_map_extractor(Propagator)

View Source
Link to this function

set_text_map_injector(Propagator)

View Source
Link to this function

set_text_map_propagator(Propagator)

View Source
Link to this function

set_tracer(Name, Tracer)

View Source

Specs

set_tracer(atom(), tracer()) -> boolean().

Specs

status(Code) -> status() | undefined when Code :: status_code().

Specs

status(Code, Message) -> status() | undefined
          when Code :: status_code(), Message :: unicode:unicode_binary().

Specs

timestamp() -> integer().
A monotonically increasing time provided by the Erlang runtime system in the native time unit. This value is the most accurate and precise timestamp available from the Erlang runtime and should be used for finding durations or any timestamp that can be converted to a system time before being sent to another system.
Link to this function

timestamp_to_nano(Timestamp)

View Source

Specs

timestamp_to_nano(timestamp()) -> integer().
Convert a native monotonic timestamp to nanosecond POSIX time. Meaning the time since Epoch. Epoch is defined to be 00:00:00 UTC, 1970-01-01.
Link to this function

verify_and_set_term(Module, TermKey, Behaviour)

View Source

Specs

verify_and_set_term(module() | {module(), term()}, term(), atom()) -> boolean().