Class: Karafka::Instrumentation::Callbacks::ConsumerGroups::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/instrumentation/callbacks/consumer_groups/error.rb

Overview

Callback that kicks in when consumer error occurs and is published in a background thread

Instance Method Summary collapse

Constructor Details

#initialize(subscription_group_id, group_id, client_name) ⇒ Error

Returns a new instance of Error.

Parameters:

  • subscription_group_id (String)
  • group_id (String)

    id of the owning group (consumer group today)

  • client_name (String)

    rdkafka client name



18
19
20
21
22
# File 'lib/karafka/instrumentation/callbacks/consumer_groups/error.rb', line 18

def initialize(subscription_group_id, group_id, client_name)
  @subscription_group_id = subscription_group_id
  @group_id = group_id
  @client_name = client_name
end

Instance Method Details

#call(client_name, error) ⇒ Object

Note:

It will only instrument on errors of the client of our consumer

Runs the instrumentation monitor with error

Parameters:

  • client_name (String)

    rdkafka client name

  • error (Rdkafka::Error)

    error that occurred



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/karafka/instrumentation/callbacks/consumer_groups/error.rb', line 28

def call(client_name, error)
  # Emit only errors related to our client Same as with statistics (mor explanation there)
  return unless @client_name == client_name

  monitor.instrument(
    "error.occurred",
    caller: self,
    subscription_group_id: @subscription_group_id,
    consumer_group_id: @group_id,
    group_id: @group_id,
    type: "librdkafka.error",
    error: error
  )
rescue => e
  monitor.instrument(
    "error.occurred",
    caller: self,
    subscription_group_id: @subscription_group_id,
    consumer_group_id: @group_id,
    group_id: @group_id,
    type: "callbacks.error.error",
    error: e
  )
end