Geometrics.OpenTelemetry.Handler (geometrics v1.0.4-rc.3) View Source
Configures OpenTelemetry to collect traces from Phoenix, Ecto, and LiveView.
Link to this section Summary
Functions
When crashes or exits occur, rather than exceptions, no telemetry fires to close open
spans. To get around this, we keep a list of open spans in the Logger.metadata
, and
cheOTLogger in a Geometrics.OpenTelemetry.Logger
.
Returns a specification to start this module under a supervisor.
Caught exits are cast to ourselves, so that we do not interrupt the logger.
Intended for exceptions that happen during spans that have been opened by OpentelemetryPhoenix or OpentelemetryEcto.
Those libraries do not put a high-level :status
key in the data, which we do for our spans to normalize across different
event types.
Catch message around exits and exceptions, to make sure that spans are marked with crash/exception status and closed.
Set status to :ok
when a :stop
event fires, which suggests that whatever happened
was successful, ie did not crash or raise.
Callback implementation for GenServer.init/1
.
Given a telemetry event signaling that an action has begun, open a new child span. Makes sure that a parent span is either created, or attached to, so that events appear as siblings in a single trace spanning the LiveView session.
Sets up telemetry attachments. Some bindings are registered via OpentelemetryPhoenix
and OpentelemetryEcto
, but since neither of those handle LiveView we attach our own
bindings for those events.
Link to this section Functions
When crashes or exits occur, rather than exceptions, no telemetry fires to close open
spans. To get around this, we keep a list of open spans in the Logger.metadata
, and
cheOTLogger in a Geometrics.OpenTelemetry.Logger
.
If a crash occurs where any :ot_spans
live in the metadata, a [:geometrics, :open_telemetry, :exit]
telemetry event is fired, which gets picked up by our handle_exception
binding.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Caught exits are cast to ourselves, so that we do not interrupt the logger.
Intended for exceptions that happen during spans that have been opened by OpentelemetryPhoenix or OpentelemetryEcto.
Those libraries do not put a high-level :status
key in the data, which we do for our spans to normalize across different
event types.
Catch message around exits and exceptions, to make sure that spans are marked with crash/exception status and closed.
Set status to :ok
when a :stop
event fires, which suggests that whatever happened
was successful, ie did not crash or raise.
Callback implementation for GenServer.init/1
.
Given a telemetry event signaling that an action has begun, open a new child span. Makes sure that a parent span is either created, or attached to, so that events appear as siblings in a single trace spanning the LiveView session.
Note that child spans pull attributes off of the socket that are only present if the
:connect_info
is configured to include them in the Endpoint:
socket "/live", Phoenix.LiveView.Socket,
websocket: [
connect_info: [
:peer_data,
:trace_context_headers,
:user_agent,
:x_headers,
session: @session_options
]
]
Sets up telemetry attachments. Some bindings are registered via OpentelemetryPhoenix
and OpentelemetryEcto
, but since neither of those handle LiveView we attach our own
bindings for those events.
Some bindings are attached before the library code, so that we can add some normalized attributes across most events.