Opencensus.Logger (opencensus_elixir v0.5.0)

Updates Elixir's Logger metadata to match Erlang's logger metadata.

set_logger_metadata/0 and set_logger_metadata/1 update the following attributes in Logger.metadata/0:

  • trace_id
  • span_id
  • trace_options

You won't need to use this module if you use the macros in Opencensus.Trace.

If you use Logging, or users of your framework might plausibly use Logging, you SHOULD call set_logger_metadata/0 after using functions in [:ocp] to manipulate the span context stored in the process dictionary.

We'll be able to deprecate these functions when Elixir unifies :logger and Logger metadata in 1.10 or whichever release first requires Erlang 21 or better. To check whether that has already happened, try this at the iex prompt:

:ocp.with_child_span("traced")
:logger.get_process_metadata()
Logger.metadata(()

If the metadata output from the second and third lines match, we can start deprecating.

Link to this section Summary

Functions

Sets the Logger metadata according to the current span context.

Sets the Logger metadata according to a supplied span context.

Link to this section Functions

Link to this function

set_logger_metadata()

Sets the Logger metadata according to the current span context.

Link to this function

set_logger_metadata(span_ctx)

@spec set_logger_metadata(:opencensus.span_ctx() | :undefined) :: :ok

Sets the Logger metadata according to a supplied span context.