Honeybadger.Insights.Ecto (Honeybadger v0.24.1)

View Source

Captures database query telemetry events from Ecto repositories.

Default Configuration

By default, this module listens for telemetry events from all configured Ecto repositories. It reads the :ecto_repos configuration to identify repositories and their telemetry prefixes.

Custom Configuration

You can customize this module's behavior with the following configuration options:

config :honeybadger, insights_config: %{
  ecto: %{
    # A list of strings or regex patterns of queries to exclude
    excluded_queries: [
      ~r/^(begin|commit)( immediate)?( transaction)?$/i,
      ~r/SELECT pg_notify/,
      ~r/schema_migrations/
    ],

    # Format & include the stacktrace with each query. You must also
    # update your repo config to enable:
    #
    #   config :my_app, MyApp.Repo,
    #     stacktrace: true
    #
    # Can be a boolean to enable for all or a list of sources to enable.
    include_stacktrace: true

    # Alternative source whitelist example:
    # include_stacktrace: ["source_a", "source_b"],

    # Format & include the query parameters with each query. Can be a
    # boolean to enable for all or a list of sources to enable.
    include_params: true

    # Alternative source whitelist example:
    # include_params:["source_a", "source_b"],

    # A list of table/source names to exclude
    excluded_sources: [
      "schema_migrations",
      "oban_jobs",
      "oban_peers"
    ]
  }
}

By default, transaction bookkeeping queries and schema migration checks are excluded, as well as queries to common background job tables.

Summary

Functions

Attaches telemetry handlers if all required dependencies are available.

Attaches a telemetry handler for a specific event.

Extracts metadata from the telemetry event. Child modules should override this for specific events.

Implementation of handle_telemetry that can be called by overriding methods.

Handles telemetry events and processes the data. This implementation forwards to handle_event_impl which can be overridden by child modules to customize behavior while still calling the parent implementation.

Determines if an event should be ignored based on its metadata. Child modules should override this for specific filtering logic. Note: this is the metadata before any transformations.

Process the event data. Child modules can override this for custom processing.

Functions

attach()

Attaches telemetry handlers if all required dependencies are available.

attach_event(event)

Attaches a telemetry handler for a specific event.

dependencies_available?()

event_filter(map, meta, event)

extract_metadata(meta, arg2)

Extracts metadata from the telemetry event. Child modules should override this for specific events.

get_insights_config(key, default)

get_telemetry_events()

handle_event_impl(event, measurements, metadata, opts)

Implementation of handle_telemetry that can be called by overriding methods.

handle_telemetry(event_name, measurements, metadata, opts)

Handles telemetry events and processes the data. This implementation forwards to handle_event_impl which can be overridden by child modules to customize behavior while still calling the parent implementation.

ignore?(arg1)

Determines if an event should be ignored based on its metadata. Child modules should override this for specific filtering logic. Note: this is the metadata before any transformations.

obfuscate(sql, adapter)

process_event(event_data)

Process the event data. Child modules can override this for custom processing.