Module: Sentry::Integrable

Defined in:
lib/sentry/integrable.rb

Instance Method Summary collapse

Instance Method Details

#capture_check_in(slug, status, **options, &block) ⇒ Object



30
31
32
33
34
# File 'lib/sentry/integrable.rb', line 30

def capture_check_in(slug, status, **options, &block)
  options[:hint] ||= {}
  options[:hint][:integration] = integration_name
  Sentry.capture_check_in(slug, status, **options, &block)
end

#capture_exception(exception, **options, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/sentry/integrable.rb', line 14

def capture_exception(exception, **options, &block)
  options[:hint] ||= {}
  options[:hint][:integration] = integration_name

  # within an integration, we usually intercept uncaught exceptions so we set handled to false.
  options[:hint][:mechanism] ||= Sentry::Mechanism.new(type: integration_name, handled: false)

  Sentry.capture_exception(exception, **options, &block)
end

#capture_message(message, **options, &block) ⇒ Object



24
25
26
27
28
# File 'lib/sentry/integrable.rb', line 24

def capture_message(message, **options, &block)
  options[:hint] ||= {}
  options[:hint][:integration] = integration_name
  Sentry.capture_message(message, **options, &block)
end

#count(name, value: 1, attributes: nil) ⇒ Object



36
37
38
# File 'lib/sentry/integrable.rb', line 36

def count(name, value: 1, attributes: nil)
  Sentry.metrics.count(name, value: value, attributes: attributes, integration: integration_name)
end

#distribution(name, value, unit: nil, attributes: nil) ⇒ Object



44
45
46
# File 'lib/sentry/integrable.rb', line 44

def distribution(name, value, unit: nil, attributes: nil)
  Sentry.metrics.distribution(name, value, unit: unit, attributes: attributes, integration: integration_name)
end

#gauge(name, value, unit: nil, attributes: nil) ⇒ Object



40
41
42
# File 'lib/sentry/integrable.rb', line 40

def gauge(name, value, unit: nil, attributes: nil)
  Sentry.metrics.gauge(name, value, unit: unit, attributes: attributes, integration: integration_name)
end

#integration_name ⇒ Object



10
11
12
# File 'lib/sentry/integrable.rb', line 10

def integration_name
  @integration_name
end

#register_integration(name:, version:) ⇒ Object



5
6
7
8
# File 'lib/sentry/integrable.rb', line 5

def register_integration(name:, version:)
  Sentry.register_integration(name, version)
  @integration_name = name
end