instrument_exporter_console (instrument v1.0.0)

View Source

Console exporter for spans.

Exports spans to stdout for debugging and development.

Example Usage

  %% Register with default options
  instrument_exporter:register(instrument_exporter_console:new()),
 
  %% Register with options
  instrument_exporter:register(instrument_exporter_console:new(#{
      format => json,      %% json | text (default: text)
      output => standard_io %% standard_io | standard_error | {file, Path}
  })),

Summary

Functions

Exports spans to the console.

Forces a flush (no-op for console).

Initializes the exporter.

Creates a new console exporter configuration with defaults.

Creates a new console exporter configuration.

Shuts down the exporter.

Functions

export(Spans, State)

-spec export([#span{name :: binary(),
                    ctx ::
                        #span_ctx{trace_id :: <<_:128>> | undefined,
                                  span_id :: <<_:64>> | undefined,
                                  trace_flags :: 0 | 1,
                                  trace_state :: [{binary(), binary()}],
                                  is_remote :: boolean()},
                    parent_ctx ::
                        #span_ctx{trace_id :: <<_:128>> | undefined,
                                  span_id :: <<_:64>> | undefined,
                                  trace_flags :: 0 | 1,
                                  trace_state :: [{binary(), binary()}],
                                  is_remote :: boolean()} |
                        undefined,
                    tracer ::
                        #tracer{name :: binary(),
                                version :: binary() | undefined,
                                schema_url :: binary() | undefined,
                                resource ::
                                    #resource{attributes :: map(), schema_url :: binary() | undefined} |
                                    undefined} |
                        undefined,
                    kind :: client | server | producer | consumer | internal,
                    start_time :: integer(),
                    end_time :: integer() | undefined,
                    attributes :: map(),
                    events ::
                        [#span_event{name :: binary(),
                                     timestamp :: integer(),
                                     attributes :: map(),
                                     dropped_attributes_count :: non_neg_integer()}],
                    links ::
                        [#span_link{ctx ::
                                        #span_ctx{trace_id :: <<_:128>> | undefined,
                                                  span_id :: <<_:64>> | undefined,
                                                  trace_flags :: 0 | 1,
                                                  trace_state :: [{binary(), binary()}],
                                                  is_remote :: boolean()},
                                    attributes :: map(),
                                    dropped_attributes_count :: non_neg_integer()}],
                    status :: unset | ok | {error, binary()},
                    is_recording :: boolean(),
                    dropped_attributes_count :: non_neg_integer(),
                    dropped_events_count :: non_neg_integer(),
                    dropped_links_count :: non_neg_integer()}],
             #state{format :: text | json,
                    output :: standard_io | standard_error | {file, file:io_device()}}) ->
                {ok,
                 #state{format :: text | json,
                        output :: standard_io | standard_error | {file, file:io_device()}}} |
                {error,
                 term(),
                 #state{format :: text | json,
                        output :: standard_io | standard_error | {file, file:io_device()}}}.

Exports spans to the console.

force_flush(State)

-spec force_flush(#state{format :: text | json,
                         output :: standard_io | standard_error | {file, file:io_device()}}) ->
                     {ok,
                      #state{format :: text | json,
                             output :: standard_io | standard_error | {file, file:io_device()}}}.

Forces a flush (no-op for console).

init(Config)

-spec init(map()) ->
              {ok,
               #state{format :: text | json,
                      output :: standard_io | standard_error | {file, file:io_device()}}} |
              {error, term()}.

Initializes the exporter.

new()

-spec new() -> #{module := module(), config := map()}.

Creates a new console exporter configuration with defaults.

new(Config)

-spec new(map()) -> #{module := module(), config := map()}.

Creates a new console exporter configuration.

shutdown(State)

-spec shutdown(#state{format :: text | json,
                      output :: standard_io | standard_error | {file, file:io_device()}}) ->
                  ok.

Shuts down the exporter.