Class: CloseYourIt::JobMetricEvent
- Defined in:
- lib/closeyourit/events/job_metric_event.rb
Overview
Metrica kind=performance_issue per un background job che ha superato una soglia di DURATA
(subtype=slow_job) o di ATTESA in coda (subtype=job_queue_latency). Spedita sulla pipeline
metriche (/api/v1/projects/:id/metrics), come slow_query/slow_method e i verdetti performance.
label è il nome della CLASSE del job — mai gli argomenti (privacy: come slow_method invia solo
label/durata). attempt rende visibili i retry; trace_id (= job_id ActiveJob / jid Sidekiq)
correla la metrica a log ed errori dello stesso job. duration_ms è il valore misurato del subtype
(durata del perform per slow_job, attesa in coda per job_queue_latency) — stessa convenzione del
Rollup. I campi nil vengono omessi.
Instance Method Summary collapse
- #ingest_path(project_id) ⇒ Object
-
#initialize(attrs, configuration) ⇒ JobMetricEvent
constructor
A new instance of JobMetricEvent.
- #to_h ⇒ Object
Constructor Details
#initialize(attrs, configuration) ⇒ JobMetricEvent
Returns a new instance of JobMetricEvent.
17 18 19 20 |
# File 'lib/closeyourit/events/job_metric_event.rb', line 17 def initialize(attrs, configuration) super(configuration) @attrs = attrs end |
Instance Method Details
#ingest_path(project_id) ⇒ Object
40 41 42 |
# File 'lib/closeyourit/events/job_metric_event.rb', line 40 def ingest_path(project_id) "/api/v1/projects/#{project_id}/metrics" end |
#to_h ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/closeyourit/events/job_metric_event.rb', line 22 def to_h compact( "kind" => "performance_issue", "subtype" => @attrs[:subtype], "sample_id" => SecureRandom.uuid, "duration_ms" => @attrs[:duration_ms]&.round(2), "occurred_at" => @occurred_at, "environment" => environment, "release" => @configuration.release, "trace_id" => @attrs[:trace_id], "label" => @attrs[:job_class], "queue" => @attrs[:queue], "adapter" => @attrs[:adapter], "attempt" => @attrs[:attempt], "sdk" => sdk ) end |