blipit 0.1.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 +7 -0
- data/README.md +51 -0
- data/lib/blipit/version.rb +3 -0
- data/lib/blipit.rb +80 -0
- metadata +103 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3f949d1c6a29c26aea5036c4cb3298cd599f14f2ca5019946e72003fb9a53e87
|
|
4
|
+
data.tar.gz: b1e38bd23ac52d4fe74f5ec0b44e3b5c2f0d6b30a5ad6e092af833f49bbc006c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 601637f0986ab8b4da74b5d6c7b656da8cb9c47193da167510c587185d66fa138610db8273fdf13e39bf886e5392c28ddd55f6fdfe21b32786c13d6ce8d5e7f0
|
|
7
|
+
data.tar.gz: 4ec6d0bafe9bd2dc3c186b43ee4a9c63becbe4351bf5bd30cd447b8abc5f94224d2cba1fe6812bb188aa32ede4f0e246a99459b39a0e2b4847e0df69514153a9
|
data/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# blipit
|
|
2
|
+
|
|
3
|
+
Blipit error monitoring for Ruby. Know your app broke before your users tell you.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
gem install blipit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or add `gem "blipit"` to your Gemfile.
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
Call `Blipit.init` once at startup, before the app starts serving requests.
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
require "blipit"
|
|
19
|
+
|
|
20
|
+
Blipit.init(key: "<public key>", project: <project id>, environment: "production", release: "myapp@1.4.2")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Both values are on the project's Keys page at app.blipit.io. Unhandled exceptions are reported on their own.
|
|
24
|
+
|
|
25
|
+
## Rails
|
|
26
|
+
|
|
27
|
+
Put the `Blipit.init` call in `config/initializers/blipit.rb`. If you want the Rails integration (controller and job context, ActiveRecord breadcrumbs), add `gem "sentry-rails"` instead and set `config.dsn = "https://<public key>@in.blipit.io/<project id>"` in its initializer.
|
|
28
|
+
|
|
29
|
+
## Manual capture
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
Blipit.capture_exception(error)
|
|
33
|
+
Blipit.capture_message("cache miss rate above 50%", level: :warning)
|
|
34
|
+
Blipit.set_user(id: "42", email: "ana@example.com")
|
|
35
|
+
Blipit.set_tag("region", "ap-southeast-1")
|
|
36
|
+
Blipit.add_breadcrumb("cache cleared", category: "cache")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Login attempts
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
Blipit.capture_security("login_failed", email, outcome: "wrong password", ip: request.remote_ip, user_agent: request.user_agent)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`kind` is one of `login_failed`, `login_blocked`, `login_succeeded`, `password_reset` or any short name you choose. Failed and blocked logins are reported as warnings.
|
|
46
|
+
|
|
47
|
+
## Performance
|
|
48
|
+
|
|
49
|
+
Pass `traces_sample_rate: 0.2` to `init` and requests show up on the Performance page.
|
|
50
|
+
|
|
51
|
+
Docs: https://docs.blipit.io/ruby
|
data/lib/blipit.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require "sentry-ruby"
|
|
2
|
+
require_relative "blipit/version"
|
|
3
|
+
|
|
4
|
+
module Blipit
|
|
5
|
+
DEFAULT_ENDPOINT = "https://in.blipit.io"
|
|
6
|
+
WARNING_KINDS = %w[login_failed login_blocked].freeze
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def dsn(key, project, endpoint = DEFAULT_ENDPOINT)
|
|
10
|
+
scheme = endpoint.start_with?("http://") ? "http" : "https"
|
|
11
|
+
host = endpoint.sub(%r{\A[a-z]+://}i, "").chomp("/")
|
|
12
|
+
"#{scheme}://#{key}@#{host}/#{project}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def init(key:, project:, environment: nil, release: nil, traces_sample_rate: 0.0, endpoint: DEFAULT_ENDPOINT, **options)
|
|
16
|
+
raise ArgumentError, "Blipit.init needs the project's public key" if key.nil? || key.to_s.empty?
|
|
17
|
+
raise ArgumentError, "Blipit.init needs the project id" if project.nil? || project.to_s.empty?
|
|
18
|
+
|
|
19
|
+
Sentry.init do |config|
|
|
20
|
+
config.dsn = dsn(key, project, endpoint)
|
|
21
|
+
config.environment = environment if environment
|
|
22
|
+
config.release = release if release
|
|
23
|
+
config.traces_sample_rate = traces_sample_rate
|
|
24
|
+
config.send_default_pii = false
|
|
25
|
+
options.each { |name, value| config.public_send("#{name}=", value) }
|
|
26
|
+
yield config if block_given?
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def capture_exception(error, **options)
|
|
31
|
+
Sentry.capture_exception(error, **options)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def capture_message(message, level: :info, **options)
|
|
35
|
+
Sentry.capture_message(message, level: level, **options)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def set_user(user)
|
|
39
|
+
Sentry.set_user(user)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def set_tag(key, value)
|
|
43
|
+
Sentry.set_tags(key => value)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def add_breadcrumb(message, category: nil, level: :info, data: {})
|
|
47
|
+
Sentry.add_breadcrumb(Sentry::Breadcrumb.new(message: message, category: category, level: level, data: data))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def capture_security(kind, actor, outcome: nil, actor_id: nil, ip: nil, user_agent: nil, target: nil)
|
|
51
|
+
payload = {
|
|
52
|
+
kind: kind,
|
|
53
|
+
actor: actor,
|
|
54
|
+
outcome: outcome,
|
|
55
|
+
actor_id: actor_id,
|
|
56
|
+
ip: ip,
|
|
57
|
+
user_agent: user_agent,
|
|
58
|
+
target: target
|
|
59
|
+
}.compact
|
|
60
|
+
level = WARNING_KINDS.include?(kind.to_s) ? :warning : :info
|
|
61
|
+
Sentry.with_scope do |scope|
|
|
62
|
+
scope.set_context("security", payload)
|
|
63
|
+
scope.set_tag("security.kind", kind)
|
|
64
|
+
Sentry.capture_message("#{kind} for #{actor}", level: level)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def flush(timeout = 2)
|
|
69
|
+
client = Sentry.get_current_client
|
|
70
|
+
return unless client
|
|
71
|
+
|
|
72
|
+
executor = Sentry.background_worker&.instance_variable_get(:@executor)
|
|
73
|
+
if executor.respond_to?(:scheduled_task_count)
|
|
74
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout
|
|
75
|
+
sleep 0.01 while executor.scheduled_task_count > executor.completed_task_count && Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline
|
|
76
|
+
end
|
|
77
|
+
client.flush
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: blipit
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Louward Labs
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: logger
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: sentry-ruby
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '5.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '5.0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: minitest
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '5.0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '5.0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: webrick
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '1.8'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '1.8'
|
|
68
|
+
description: 'Blipit error monitoring for Ruby: Rails, Sinatra, Sidekiq and scripts.
|
|
69
|
+
Know your app broke before your users tell you.'
|
|
70
|
+
email: support@blipit.io
|
|
71
|
+
executables: []
|
|
72
|
+
extensions: []
|
|
73
|
+
extra_rdoc_files: []
|
|
74
|
+
files:
|
|
75
|
+
- README.md
|
|
76
|
+
- lib/blipit.rb
|
|
77
|
+
- lib/blipit/version.rb
|
|
78
|
+
homepage: https://blipit.io
|
|
79
|
+
licenses:
|
|
80
|
+
- MIT
|
|
81
|
+
metadata:
|
|
82
|
+
homepage_uri: https://blipit.io
|
|
83
|
+
documentation_uri: https://docs.blipit.io/ruby
|
|
84
|
+
changelog_uri: https://blipit.io/changelog
|
|
85
|
+
rubygems_mfa_required: 'true'
|
|
86
|
+
rdoc_options: []
|
|
87
|
+
require_paths:
|
|
88
|
+
- lib
|
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '2.7'
|
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
requirements: []
|
|
100
|
+
rubygems_version: 4.0.20
|
|
101
|
+
specification_version: 4
|
|
102
|
+
summary: Blipit error monitoring for Ruby and Rails
|
|
103
|
+
test_files: []
|