LightCDP.Telemetry (light_cdp v0.2.0)

Copy Markdown View Source

Telemetry events emitted by LightCDP.

All page operations and CDP commands emit :start, :stop, and :exception events via :telemetry.span/3.

Page events

Prefix: [:light_cdp, :page, <operation>]

Operations: navigate, evaluate, click, fill, submit, screenshot, content, url, wait_for_selector, wait_for_navigation

Measurements:

  • :start%{system_time: integer}
  • :stop%{duration: native_time}

Metadata varies by operation (see LightCDP.Page function docs).

Connection events

Prefix: [:light_cdp, :connection, :command]

Metadata: %{method: String.t(), session_id: String.t() | nil}

Step events

Multi-step operations (fill, click) emit point events at [:light_cdp, :page, :step] with %{step: atom} metadata. These are not spans — they annotate the parent span with what happened inside (focus, clear, insert, query, locate, etc.).

Observability options

By default, no handlers are attached (null sink). Opt in per environment:

# Logger output (no extra deps, good for dev)
LightCDP.Telemetry.attach_default_logger(level: :debug)

# OpenTelemetry spans (requires :opentelemetry in deps, good for staging/prod)
LightCDP.Telemetry.OtelBridge.setup()

Call either from your Application.start/2 callback or at script startup.

Summary

Functions

Attaches a default Logger handler for all LightCDP telemetry events, including step annotations for multi-step operations.

Detaches the default Logger handler.

Returns all telemetry event names emitted by LightCDP, including both span events and point events (step annotations).

Returns all span event names (:start, :stop, :exception) emitted by LightCDP.

Functions

attach_default_logger(opts \\ [])

Attaches a default Logger handler for all LightCDP telemetry events, including step annotations for multi-step operations.

Idempotent — safe to call multiple times.

Options

  • :level - log level (default: :debug)

Example output

[debug] navigate https://example.com
[debug] CDP Page.navigate
[debug] CDP Page.navigate in 657.2ms
[debug] navigate completed in 822.3ms
[debug] fill #email
[debug]   · focus
[debug]   · clear
[debug]   · insert (value_length=16)
[debug] fill completed in 3.1ms

detach_default_logger()

Detaches the default Logger handler.

events()

Returns all telemetry event names emitted by LightCDP, including both span events and point events (step annotations).

span_events()

Returns all span event names (:start, :stop, :exception) emitted by LightCDP.