View Source opentelemetry (opentelemetry_api v1.2.0)

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

-type attribute() :: {attribute_key(), attribute_value()}.
-type attribute_key() :: unicode:unicode_binary() | atom().
-type attribute_value() ::
    unicode:unicode_binary() |
    atom() |
    number() |
    boolean() |
    [unicode:unicode_binary() | atom() | float() | integer() | boolean()] |
    {unicode:unicode_binary() | atom() | float() | integer() | boolean()}.
-type attributes_map() :: #{attribute_key() => attribute_value()} | [attribute()].
-type event() ::
    #{system_time_native => integer(), name := event_name(), attributes := attributes_map()}.
-type event_name() :: unicode:unicode_binary() | atom().
-type hex_span_id() :: binary().
-type hex_trace_id() :: binary().
Link to this type

instrumentation_scope/0

View Source
-type instrumentation_scope() :: #instrumentation_scope{}.
-type link() ::
    #{trace_id := trace_id(),
      span_id := span_id(),
      attributes := attributes_map(),
      tracestate := tracestate()}.
-type resource() :: #{unicode:unicode_binary() => unicode:unicode_binary()}.
-type span() :: term().
-type span_ctx() :: #span_ctx{}.
-type span_id() :: non_neg_integer().
-type span_kind() :: internal | server | client | producer | consumer.
-type span_name() :: unicode:unicode_binary() | atom().
-type status() :: #status{}.
-type status_code() :: unset | ok | error.
-type text_map() :: [{unicode:unicode_binary(), unicode:unicode_binary()}].
-type timestamp() :: integer().
-type trace_flags() :: non_neg_integer().
-type trace_id() :: non_neg_integer().
-type tracer() :: {module(), term()}.
-type tracestate() :: [{unicode:latin1_chardata(), unicode:latin1_chardata()}].

Link to this section Functions

Link to this function

convert_timestamp(Timestamp, Unit)

View Source
-spec 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
-spec create_application_tracers([{Application, Description, Vsn}]) -> ok
                              when Application :: atom(), Description :: string(), Vsn :: string().
-spec event(Name, Attributes) -> event() | undefined
         when Name :: event_name(), Attributes :: attributes_map().
Link to this function

event(Timestamp, Name, Attributes)

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

get_application(ModuleName)

View Source
-spec 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_scope(ModuleName)

View Source
-spec get_application_scope(module()) -> instrumentation_scope() | undefined.
Link to this function

get_application_tracer(ModuleName)

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

get_text_map_extractor()

View Source
-spec get_tracer() -> tracer().
-spec get_tracer(Name) -> Tracer
              when
                  Name :: atom() | {atom(), 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
-spec 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
Link to this function

instrumentation_scope(Name, Vsn, SchemaUrl)

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

link(Span_ctx, Attributes)

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

link(TraceId, SpanId, Attributes, TraceState)

View Source
-spec link(TraceId, SpanId, Attributes, TraceState) -> link() | undefined
        when
            TraceId :: trace_id(),
            SpanId :: span_id(),
            Attributes :: attributes_map(),
            TraceState :: tracestate().
-spec 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
-spec set_default_tracer(tracer()) -> boolean().
Link to this function

set_default_tracer(TracerProvider, Tracer)

View Source
-spec set_default_tracer(atom(), 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
-spec set_tracer(atom(), tracer()) -> boolean().
Link to this function

start_tracer_provider(Name, Config)

View Source
-spec start_tracer_provider(atom(), map()) -> {ok, pid() | undefined} | {error, term()}.
-spec status(Code) -> status() | undefined when Code :: status_code().
-spec status(Code, Message) -> status() | undefined
          when Code :: status_code(), Message :: unicode:unicode_binary().
-spec 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
-spec timestamp_to_nano(timestamp()) -> pos_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
-spec verify_and_set_term(module() | {module(), term()}, term(), atom()) -> boolean().