MetaCredo.Check.Observability.MissingTelemetryInObanWorker (MetaCredo v0.4.0)

View Source

Detects background job processing functions (e.g. Oban worker perform/1) without telemetry instrumentation. Background jobs should emit metrics for monitoring, debugging, and alerting on job execution.

The check uses callback_for metadata produced by Metastatic's semantic enricher to identify actual behaviour callbacks. Only functions whose callback_for matches one of the configured job_behaviours are flagged.

When fallback_heuristic is true, functions without callback_for metadata are also checked using name-based job_indicators matching (the legacy behaviour). This is off by default.

Category: Observability / Priority: normal

Configuration

Accepts the following parameters via .metacredo.exs:

  • job_behaviours - Behaviour/base-class module names that identify job workers (matched against callback_for metadata on function_def nodes) (default: {:sigil_W, [delimiter: "[", line: 6, column: 23], [{:<<>>, [line: 6, column: 23], ["\n Oban.Worker\n Sidekiq::Worker\n Sidekiq::Job\n ActiveJob::Base\n celery.Task\n dramatiq.Actor\n Broadway\n "]}, []]})
  • telemetry_indicators - Function name fragments that indicate telemetry calls (default: {:sigil_W, [delimiter: "[", line: 15, column: 29], [{:<<>>, [line: 15, column: 29], ["telemetry emit log trace metric record measure monitor"]}, []]})
  • fallback_heuristic - When true, also flag functions matching job_indicators even without callback_for metadata (legacy name-based heuristic) (default: false)
  • job_indicators - Function name fragments for the fallback heuristic (only used when fallback_heuristic is true) (default: {:sigil_W, [delimiter: "[", line: 17, column: 23], [{:<<>>, [line: 17, column: 23], ["perform execute process run worker job task handler"]}, []]})