sentry-yabeda 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 240d26d6fb3fd640846c0012d52573e1ef8d52f8ee196ccdae1f48847986f6dd
4
+ data.tar.gz: ae115213024349ce83a753c66e113a31d3bd12e61f5359cb273998f74fd7db77
5
+ SHA512:
6
+ metadata.gz: 76b1256442c8eded36f5c6b34790b11e0bb7acc8fe72e55ac4661292fe971ced5f633d4ce13a4ce11bef222be44942f0a1e45a686316f38e53cf9fac58e0647e
7
+ data.tar.gz: d3541d062a739013e80be0ded8eacdc7ece9766032d96a13a59e0fd182113669172e1f19840fb6fede5c061c4d6f333a93c53202e7f2d870d476613e3f3abe88
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ git_source(:github) { |name| "https://github.com/#{name}.git" }
5
+
6
+ eval_gemfile "../Gemfile.dev"
7
+
8
+ # Specify your gem's dependencies in sentry-yabeda.gemspec
9
+ gemspec
10
+
11
+ gem "sentry-ruby", path: "../sentry-ruby"
12
+
13
+ gem "timecop"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Sentry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,3 @@
1
+ build:
2
+ bundle install
3
+ gem build sentry-yabeda.gemspec
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ <p align="center">
2
+ <a href="https://sentry.io" target="_blank" align="center">
3
+ <img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
4
+ </a>
5
+ <br>
6
+ </p>
7
+
8
+ # sentry-yabeda, the Yabeda integration for Sentry's Ruby client
9
+
10
+ ---
11
+
12
+ [![Gem Version](https://img.shields.io/gem/v/sentry-yabeda.svg)](https://rubygems.org/gems/sentry-yabeda)
13
+ ![Build Status](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_yabeda_test.yml/badge.svg)
14
+ [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master)
15
+ [![Gem](https://img.shields.io/gem/dt/sentry-yabeda.svg)](https://rubygems.org/gems/sentry-yabeda/)
16
+
17
+
18
+ [Documentation](https://docs.sentry.io/platforms/ruby/) | [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
19
+
20
+ The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
21
+
22
+
23
+ ## Getting Started
24
+
25
+ ### Install
26
+
27
+ ```ruby
28
+ gem "sentry-ruby"
29
+ gem "sentry-yabeda"
30
+ ```
31
+
32
+ Then initialize Sentry with metrics enabled:
33
+
34
+ ```ruby
35
+ Sentry.init do |config|
36
+ config.dsn = ENV["SENTRY_DSN"]
37
+ config.enable_metrics = true
38
+ end
39
+ ```
40
+
41
+ That's it! All Yabeda metrics will automatically flow to Sentry.
42
+
43
+ ## How it works
44
+
45
+ Counters, histograms, summaries, and directly-set gauges all forward to Sentry inline when your app calls them. Yabeda summaries map to Sentry distributions, as Sentry has no summary type.
46
+
47
+ Collector blocks (`Yabeda.configure { collect { ... } }`) are Yabeda's pull hook — in Prometheus they're triggered by a scrape request. Since Sentry is push-based, `sentry-yabeda` runs a background thread that calls `Yabeda.collect!` every 15 seconds. Metrics populated this way (typically gauges for GC stats, thread counts, etc.) won't carry trace context.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require_relative "../lib/sentry/test/rake_tasks"
5
+
6
+ Sentry::Test::RakeTasks.define_spec_tasks(
7
+ spec_pattern: "spec/sentry/**/*_spec.rb",
8
+ spec_rspec_opts: "--order rand --format progress"
9
+ )
10
+
11
+ task default: :spec
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yabeda/base_adapter"
4
+
5
+ module Sentry
6
+ module Yabeda
7
+ class Adapter < ::Yabeda::BaseAdapter
8
+ # Sentry does not require pre-registration of metrics
9
+ def register_counter!(_metric); end
10
+ def register_gauge!(_metric); end
11
+ def register_histogram!(_metric); end
12
+ def register_summary!(_metric); end
13
+
14
+ def perform_counter_increment!(counter, tags, increment)
15
+ return unless enabled?
16
+
17
+ Sentry.metrics.count(
18
+ metric_name(counter),
19
+ value: increment,
20
+ attributes: attributes_for(tags)
21
+ )
22
+ end
23
+
24
+ def perform_gauge_set!(gauge, tags, value)
25
+ return unless enabled?
26
+
27
+ Sentry.metrics.gauge(
28
+ metric_name(gauge),
29
+ value,
30
+ unit: unit_for(gauge),
31
+ attributes: attributes_for(tags)
32
+ )
33
+ end
34
+
35
+ def perform_histogram_measure!(histogram, tags, value)
36
+ return unless enabled?
37
+
38
+ Sentry.metrics.distribution(
39
+ metric_name(histogram),
40
+ value,
41
+ unit: unit_for(histogram),
42
+ attributes: attributes_for(tags)
43
+ )
44
+ end
45
+
46
+ def perform_summary_observe!(summary, tags, value)
47
+ return unless enabled?
48
+
49
+ Sentry.metrics.distribution(
50
+ metric_name(summary),
51
+ value,
52
+ unit: unit_for(summary),
53
+ attributes: attributes_for(tags)
54
+ )
55
+ end
56
+
57
+ private
58
+
59
+ def enabled?
60
+ Sentry.initialized? && Sentry.configuration.enable_metrics
61
+ end
62
+
63
+ def attributes_for(tags)
64
+ tags.empty? ? nil : tags
65
+ end
66
+
67
+ def metric_name(metric)
68
+ [metric.group, metric.name].compact.join(".")
69
+ end
70
+
71
+ def unit_for(metric)
72
+ metric.unit&.to_s&.chomp("s")
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sentry/threaded_periodic_worker"
4
+
5
+ module Sentry
6
+ module Yabeda
7
+ # Periodically calls Yabeda.collect! to trigger gauge collection blocks
8
+ # registered by plugins like yabeda-puma-plugin, yabeda-gc, and
9
+ # yabeda-gvl_metrics.
10
+ #
11
+ # In a pull-based system (Prometheus), the scrape request triggers
12
+ # collection. In a push-based system (Sentry), we need this periodic
13
+ # worker to drive the collect → gauge.set → adapter.perform_gauge_set!
14
+ # pipeline.
15
+ class Collector < Sentry::ThreadedPeriodicWorker
16
+ DEFAULT_INTERVAL = 15 # seconds
17
+
18
+ def initialize(configuration, interval: DEFAULT_INTERVAL)
19
+ super(configuration.sdk_logger, interval)
20
+ ensure_thread
21
+ end
22
+
23
+ def run
24
+ ::Yabeda.collect!
25
+ rescue => e
26
+ log_warn("[Sentry::Yabeda::Collector] collection failed: #{e.message}")
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sentry
4
+ class Configuration
5
+ after(:configured) do
6
+ if enable_metrics
7
+ Sentry::Yabeda.collector&.kill
8
+ Sentry::Yabeda.collector = Sentry::Yabeda::Collector.new(self)
9
+ end
10
+ end
11
+
12
+ after(:closed) do
13
+ if (collector = Sentry::Yabeda.collector)
14
+ collector.run
15
+ collector.kill
16
+ Sentry::Yabeda.collector = nil
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sentry
4
+ module Yabeda
5
+ VERSION = "6.6.0"
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yabeda"
4
+ require "sentry-ruby"
5
+ require "sentry/integrable"
6
+ require "sentry/yabeda/version"
7
+ require "sentry/yabeda/adapter"
8
+ require "sentry/yabeda/collector"
9
+ require "sentry/yabeda/configuration"
10
+
11
+ module Sentry
12
+ module Yabeda
13
+ extend Sentry::Integrable
14
+
15
+ register_integration name: "yabeda", version: Sentry::Yabeda::VERSION
16
+
17
+ class << self
18
+ attr_accessor :collector
19
+ end
20
+ end
21
+ end
22
+
23
+ ::Yabeda.register_adapter(:sentry, Sentry::Yabeda::Adapter.new)
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/sentry/yabeda/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "sentry-yabeda"
7
+ spec.version = Sentry::Yabeda::VERSION
8
+ spec.authors = ["Sentry Team"]
9
+ spec.description = spec.summary = "A gem that provides Yabeda integration for the Sentry error logger"
10
+ spec.email = "accounts@sentry.io"
11
+ spec.license = 'MIT'
12
+
13
+ spec.platform = Gem::Platform::RUBY
14
+ spec.required_ruby_version = '>= 2.7'
15
+ spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
16
+ spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples|\.rubocop\.yml)'`.split("\n")
17
+
18
+ github_root_uri = 'https://github.com/getsentry/sentry-ruby'
19
+ spec.homepage = "#{github_root_uri}/tree/#{spec.version}/#{spec.name}"
20
+
21
+ spec.metadata = {
22
+ "homepage_uri" => spec.homepage,
23
+ "source_code_uri" => spec.homepage,
24
+ "changelog_uri" => "#{github_root_uri}/blob/#{spec.version}/CHANGELOG.md",
25
+ "bug_tracker_uri" => "#{github_root_uri}/issues",
26
+ "documentation_uri" => "http://www.rubydoc.info/gems/#{spec.name}/#{spec.version}"
27
+ }
28
+
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "sentry-ruby", "~> 6.6.0"
34
+ spec.add_dependency "yabeda", ">= 0.11"
35
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sentry-yabeda
3
+ version: !ruby/object:Gem::Version
4
+ version: 6.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Sentry Team
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: sentry-ruby
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 6.6.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 6.6.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: yabeda
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.11'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.11'
40
+ description: A gem that provides Yabeda integration for the Sentry error logger
41
+ email: accounts@sentry.io
42
+ executables: []
43
+ extensions: []
44
+ extra_rdoc_files:
45
+ - LICENSE.txt
46
+ - README.md
47
+ files:
48
+ - Gemfile
49
+ - LICENSE.txt
50
+ - Makefile
51
+ - README.md
52
+ - Rakefile
53
+ - lib/sentry-yabeda.rb
54
+ - lib/sentry/yabeda/adapter.rb
55
+ - lib/sentry/yabeda/collector.rb
56
+ - lib/sentry/yabeda/configuration.rb
57
+ - lib/sentry/yabeda/version.rb
58
+ - sentry-yabeda.gemspec
59
+ homepage: https://github.com/getsentry/sentry-ruby/tree/6.6.0/sentry-yabeda
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/6.6.0/sentry-yabeda
64
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/6.6.0/sentry-yabeda
65
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/6.6.0/CHANGELOG.md
66
+ bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
67
+ documentation_uri: http://www.rubydoc.info/gems/sentry-yabeda/6.6.0
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.6.9
83
+ specification_version: 4
84
+ summary: A gem that provides Yabeda integration for the Sentry error logger
85
+ test_files: []