View Source otel_span (opentelemetry_api v1.3.0)

Span behaviour.

Link to this section Summary

Types

Start options for a span.

Functions

Adds an event to the given span context.

Same as add_event/3, but takes a list of events.

Ends the given span context.

Ends the given span context with the given timestamp.

Returns whether the span is recording.
Returns whether the span context is valid.
Returns the span ID of the given span context.
Returns the trace ID of the given span context.

Updates the name of the given span context to Name.

Validates the start options for a span and fills in defaults.

Link to this section Types

-type start_opts() ::
    #{attributes := opentelemetry:attributes_map(),
      links := [opentelemetry:link()],
      is_recording := boolean(),
      start_time := opentelemetry:timestamp(),
      kind := opentelemetry:span_kind()}.
Start options for a span.

Link to this section Functions

Link to this function

add_event(SpanCtx, Name, Attributes)

View Source
-spec add_event(SpanCtx, Name, Attributes) -> boolean()
             when
                 Name :: opentelemetry:event_name(),
                 Attributes :: opentelemetry:attributes_map(),
                 SpanCtx :: opentelemetry:span_ctx().

Adds an event to the given span context.

Returns false if the given span context is not recording, or if the event Name is not valid.
Link to this function

add_events(SpanCtx, Events)

View Source
-spec add_events(SpanCtx, Events) -> boolean()
              when Events :: [opentelemetry:event()], SpanCtx :: opentelemetry:span_ctx().

Same as add_event/3, but takes a list of events.

Returns false if the given span context is not recording.
-spec end_span(SpanCtx) -> SpanCtx when SpanCtx :: opentelemetry:span_ctx().

Ends the given span context.

If SpanCtx is not recording, this function doesn't do anything. Returns the updated span context.
Link to this function

end_span(SpanCtx, Timestamp)

View Source
-spec end_span(SpanCtx, Timestamp) -> SpanCtx
            when SpanCtx :: opentelemetry:span_ctx(), Timestamp :: integer() | undefined.

Ends the given span context with the given timestamp.

If SpanCtx is not recording, this function doesn't do anything. If Timestamp is undefined, this is equivalent to end_span/1. Returns the updated span context.
-spec hex_span_ctx(opentelemetry:span_ctx() | undefined) ->
                #{otel_trace_id := unicode:charlist(),
                  otel_span_id := unicode:charlist(),
                  otel_trace_flags := unicode:charlist()} |
                #{}.
-spec is_recording(SpanCtx) -> boolean() when SpanCtx :: opentelemetry:span_ctx() | undefined.
Returns whether the span is recording.
-spec is_valid(SpanCtx) -> boolean() when SpanCtx :: opentelemetry:span_ctx().
Returns whether the span context is valid.
Link to this function

record_exception(SpanCtx, Class, Term, Stacktrace, Attributes)

View Source
-spec record_exception(SpanCtx, Class, Term, Stacktrace, Attributes) -> boolean()
                    when
                        SpanCtx :: opentelemetry:span_ctx(),
                        Class :: atom(),
                        Term :: term(),
                        Stacktrace :: [any()],
                        Attributes :: opentelemetry:attributes_map().
Link to this function

record_exception(SpanCtx, Class, Term, Message, Stacktrace, Attributes)

View Source
-spec record_exception(SpanCtx, Class, Term, Message, Stacktrace, Attributes) -> boolean()
                    when
                        SpanCtx :: opentelemetry:span_ctx(),
                        Class :: atom(),
                        Term :: term(),
                        Message :: unicode:unicode_binary(),
                        Stacktrace :: [any()],
                        Attributes :: opentelemetry:attributes_map().
Link to this function

set_attribute(SpanCtx, Key, Value)

View Source
-spec set_attribute(SpanCtx, Key, Value) -> boolean()
                 when
                     Key :: opentelemetry:attribute_key(),
                     Value :: opentelemetry:attribute_value(),
                     SpanCtx :: opentelemetry:span_ctx().
Link to this function

set_attributes(SpanCtx, Attributes)

View Source
-spec set_attributes(SpanCtx, Attributes) -> boolean()
                  when
                      Attributes :: opentelemetry:attributes_map(),
                      SpanCtx :: opentelemetry:span_ctx().
Link to this function

set_status(SpanCtx, StatusOrCode)

View Source
-spec set_status(SpanCtx, StatusOrCode) -> boolean()
              when
                  StatusOrCode :: opentelemetry:status() | undefined | opentelemetry:status_code(),
                  SpanCtx :: opentelemetry:span_ctx().
Link to this function

set_status(SpanCtx, Code, Message)

View Source
-spec set_status(SpanCtx, Code, Message) -> boolean()
              when
                  Code :: opentelemetry:status_code(),
                  Message :: unicode:unicode_binary(),
                  SpanCtx :: opentelemetry:span_ctx().
Returns the span ID of the given span context.
Returns the trace ID of the given span context.
-spec tracestate(opentelemetry:span_ctx() | undefined) -> otel_tracestate:t().
Link to this function

update_name(SpanCtx, Name)

View Source
-spec update_name(SpanCtx, Name) -> boolean()
               when Name :: opentelemetry:span_name(), SpanCtx :: opentelemetry:span_ctx().

Updates the name of the given span context to Name.

Returns false if the given span context is not recording, or if the name Name is not valid.
Link to this function

validate_start_opts(Opts)

View Source
-spec validate_start_opts(start_opts()) -> start_opts().
Validates the start options for a span and fills in defaults.