otel-active-support-subscriber 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +54 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.rubocop.yml +24 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +174 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +4 -0
- data/bin/console +8 -0
- data/bin/setup +6 -0
- data/lib/otel/active_support_subscriber/config.rb +23 -0
- data/lib/otel/active_support_subscriber/init.rb +28 -0
- data/lib/otel/active_support_subscriber/subscriber.rb +41 -0
- data/lib/otel/active_support_subscriber/version.rb +7 -0
- data/lib/otel/active_support_subscriber.rb +22 -0
- data/lib/otel-active-support-subscriber.rb +3 -0
- data/otel-active-support-subscriber.gemspec +42 -0
- metadata +246 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 811a48f6b98797b1d1f366f7443d9db57a44c76dbf2dfe9ee89a953e3ad3665b
|
4
|
+
data.tar.gz: 6df0434ef9ffb6969874cdc923af5bc5caca3cd59ddce8a48bf043c4eaa29e5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8b1c35f1f21ef70b928e35f5b78df24ea134d20f915561b7b3ca2f5d40ef856cd4abb8ef5d9fc53c682a599c9b65daaeed46f6b85684ca87032914dd4e14b06
|
7
|
+
data.tar.gz: 120d5e97ed3d2217cc6aa06e99abfdc9b4cd2820c774ce43bc13279d5e98d916346e974835f8b6ad316214970c568adc03d0c7ec5a2a609205b40d108fbb34dc
|
@@ -0,0 +1,54 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
env:
|
6
|
+
COVER: true
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
full-check:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
# We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
|
13
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'Cado-Labs/otel-active-support-subscriber'
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 3.0.1
|
20
|
+
bundler-cache: true
|
21
|
+
- name: Run Linter
|
22
|
+
run: bundle exec rubocop
|
23
|
+
- name: Run specs
|
24
|
+
run: bundle exec rspec
|
25
|
+
- name: Audit
|
26
|
+
run: bundle exec bundle-audit
|
27
|
+
- name: Coveralls
|
28
|
+
uses: coverallsapp/github-action@master
|
29
|
+
with:
|
30
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
31
|
+
specs:
|
32
|
+
runs-on: ubuntu-latest
|
33
|
+
continue-on-error: ${{ matrix.experimental }}
|
34
|
+
|
35
|
+
env:
|
36
|
+
COVER: false
|
37
|
+
|
38
|
+
# We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
|
39
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'Cado-Labs/otel-active-support-subscriber'
|
40
|
+
|
41
|
+
strategy:
|
42
|
+
fail-fast: false
|
43
|
+
matrix:
|
44
|
+
ruby: [2.7, 3.0, 3.1, 3.2]
|
45
|
+
experimental: [false]
|
46
|
+
|
47
|
+
steps:
|
48
|
+
- uses: actions/checkout@v2
|
49
|
+
- uses: ruby/setup-ruby@v1
|
50
|
+
with:
|
51
|
+
ruby-version: ${{ matrix.ruby }}
|
52
|
+
bundler-cache: true
|
53
|
+
- name: Run specs
|
54
|
+
run: bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-config-umbrellio: lib/rubocop.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
DisplayCopNames: true
|
6
|
+
TargetRubyVersion: 3.0.0
|
7
|
+
|
8
|
+
RSpec/EmptyLineAfterHook:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Naming/RescuedExceptionsVariableName:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/CaseEquality:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/HashConversion:
|
18
|
+
Exclude:
|
19
|
+
- spec/**/*_spec.rb
|
20
|
+
|
21
|
+
# NOTE: gem-specific limitation of commonly used gem-code-loading practices
|
22
|
+
Naming/FileName:
|
23
|
+
Exclude:
|
24
|
+
- lib/otel-active-support-subscriber.rb
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.1
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at aleksandr.sta@okwork.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
otel-active-support-subscriber (0.0.1)
|
5
|
+
activesupport (>= 5.0)
|
6
|
+
opentelemetry-api (~> 1.1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (7.0.4.2)
|
12
|
+
actionview (= 7.0.4.2)
|
13
|
+
activesupport (= 7.0.4.2)
|
14
|
+
rack (~> 2.0, >= 2.2.0)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
+
actionview (7.0.4.2)
|
19
|
+
activesupport (= 7.0.4.2)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
+
activesupport (7.0.4.2)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 1.6, < 2)
|
27
|
+
minitest (>= 5.1)
|
28
|
+
tzinfo (~> 2.0)
|
29
|
+
ast (2.4.2)
|
30
|
+
builder (3.2.4)
|
31
|
+
bundler-audit (0.9.1)
|
32
|
+
bundler (>= 1.2.0, < 3)
|
33
|
+
thor (~> 1.0)
|
34
|
+
coderay (1.1.3)
|
35
|
+
concurrent-ruby (1.2.0)
|
36
|
+
crass (1.0.6)
|
37
|
+
diff-lcs (1.5.0)
|
38
|
+
docile (1.4.0)
|
39
|
+
erubi (1.12.0)
|
40
|
+
i18n (1.12.0)
|
41
|
+
concurrent-ruby (~> 1.0)
|
42
|
+
json (2.6.3)
|
43
|
+
loofah (2.19.1)
|
44
|
+
crass (~> 1.0.2)
|
45
|
+
nokogiri (>= 1.5.9)
|
46
|
+
method_source (1.0.0)
|
47
|
+
mini_portile2 (2.8.1)
|
48
|
+
minitest (5.17.0)
|
49
|
+
nokogiri (1.14.2)
|
50
|
+
mini_portile2 (~> 2.8.0)
|
51
|
+
racc (~> 1.4)
|
52
|
+
nokogiri (1.14.2-arm64-darwin)
|
53
|
+
racc (~> 1.4)
|
54
|
+
nokogiri (1.14.2-x86_64-linux)
|
55
|
+
racc (~> 1.4)
|
56
|
+
opentelemetry-api (1.1.0)
|
57
|
+
opentelemetry-common (0.19.6)
|
58
|
+
opentelemetry-api (~> 1.0)
|
59
|
+
opentelemetry-registry (0.2.0)
|
60
|
+
opentelemetry-api (~> 1.1)
|
61
|
+
opentelemetry-sdk (1.2.0)
|
62
|
+
opentelemetry-api (~> 1.1)
|
63
|
+
opentelemetry-common (~> 0.19.3)
|
64
|
+
opentelemetry-registry (~> 0.2)
|
65
|
+
opentelemetry-semantic_conventions
|
66
|
+
opentelemetry-semantic_conventions (1.8.0)
|
67
|
+
opentelemetry-api (~> 1.0)
|
68
|
+
opentelemetry-test-helpers (0.3.0)
|
69
|
+
parallel (1.22.1)
|
70
|
+
parser (3.2.1.0)
|
71
|
+
ast (~> 2.4.1)
|
72
|
+
pry (0.14.2)
|
73
|
+
coderay (~> 1.1)
|
74
|
+
method_source (~> 1.0)
|
75
|
+
racc (1.6.2)
|
76
|
+
rack (2.2.6.2)
|
77
|
+
rack-test (2.0.2)
|
78
|
+
rack (>= 1.3)
|
79
|
+
rails-dom-testing (2.0.3)
|
80
|
+
activesupport (>= 4.2.0)
|
81
|
+
nokogiri (>= 1.6)
|
82
|
+
rails-html-sanitizer (1.5.0)
|
83
|
+
loofah (~> 2.19, >= 2.19.1)
|
84
|
+
railties (7.0.4.2)
|
85
|
+
actionpack (= 7.0.4.2)
|
86
|
+
activesupport (= 7.0.4.2)
|
87
|
+
method_source
|
88
|
+
rake (>= 12.2)
|
89
|
+
thor (~> 1.0)
|
90
|
+
zeitwerk (~> 2.5)
|
91
|
+
rainbow (3.1.1)
|
92
|
+
rake (13.0.6)
|
93
|
+
regexp_parser (2.7.0)
|
94
|
+
rexml (3.2.5)
|
95
|
+
rspec (3.12.0)
|
96
|
+
rspec-core (~> 3.12.0)
|
97
|
+
rspec-expectations (~> 3.12.0)
|
98
|
+
rspec-mocks (~> 3.12.0)
|
99
|
+
rspec-core (3.12.1)
|
100
|
+
rspec-support (~> 3.12.0)
|
101
|
+
rspec-expectations (3.12.2)
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
+
rspec-support (~> 3.12.0)
|
104
|
+
rspec-mocks (3.12.3)
|
105
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
106
|
+
rspec-support (~> 3.12.0)
|
107
|
+
rspec-support (3.12.0)
|
108
|
+
rubocop (1.43.0)
|
109
|
+
json (~> 2.3)
|
110
|
+
parallel (~> 1.10)
|
111
|
+
parser (>= 3.2.0.0)
|
112
|
+
rainbow (>= 2.2.2, < 4.0)
|
113
|
+
regexp_parser (>= 1.8, < 3.0)
|
114
|
+
rexml (>= 3.2.5, < 4.0)
|
115
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
116
|
+
ruby-progressbar (~> 1.7)
|
117
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
118
|
+
rubocop-ast (1.26.0)
|
119
|
+
parser (>= 3.2.1.0)
|
120
|
+
rubocop-config-umbrellio (1.43.0.81)
|
121
|
+
rubocop (~> 1.43.0)
|
122
|
+
rubocop-performance (~> 1.15.0)
|
123
|
+
rubocop-rails (~> 2.17.0)
|
124
|
+
rubocop-rake (~> 0.6.0)
|
125
|
+
rubocop-rspec (~> 2.16.0)
|
126
|
+
rubocop-sequel (~> 0.3.3)
|
127
|
+
rubocop-performance (1.15.2)
|
128
|
+
rubocop (>= 1.7.0, < 2.0)
|
129
|
+
rubocop-ast (>= 0.4.0)
|
130
|
+
rubocop-rails (2.17.4)
|
131
|
+
activesupport (>= 4.2.0)
|
132
|
+
rack (>= 1.1)
|
133
|
+
rubocop (>= 1.33.0, < 2.0)
|
134
|
+
rubocop-rake (0.6.0)
|
135
|
+
rubocop (~> 1.0)
|
136
|
+
rubocop-rspec (2.16.0)
|
137
|
+
rubocop (~> 1.33)
|
138
|
+
rubocop-sequel (0.3.4)
|
139
|
+
rubocop (~> 1.0)
|
140
|
+
ruby-progressbar (1.11.0)
|
141
|
+
simplecov (0.22.0)
|
142
|
+
docile (~> 1.1)
|
143
|
+
simplecov-html (~> 0.11)
|
144
|
+
simplecov_json_formatter (~> 0.1)
|
145
|
+
simplecov-html (0.12.3)
|
146
|
+
simplecov-lcov (0.8.0)
|
147
|
+
simplecov_json_formatter (0.1.4)
|
148
|
+
thor (1.2.1)
|
149
|
+
tzinfo (2.0.6)
|
150
|
+
concurrent-ruby (~> 1.0)
|
151
|
+
unicode-display_width (2.4.2)
|
152
|
+
zeitwerk (2.6.7)
|
153
|
+
|
154
|
+
PLATFORMS
|
155
|
+
arm64-darwin-21
|
156
|
+
ruby
|
157
|
+
x86_64-linux
|
158
|
+
|
159
|
+
DEPENDENCIES
|
160
|
+
bundler
|
161
|
+
bundler-audit
|
162
|
+
opentelemetry-sdk
|
163
|
+
opentelemetry-test-helpers
|
164
|
+
otel-active-support-subscriber!
|
165
|
+
pry
|
166
|
+
railties
|
167
|
+
rake
|
168
|
+
rspec
|
169
|
+
rubocop-config-umbrellio
|
170
|
+
simplecov
|
171
|
+
simplecov-lcov
|
172
|
+
|
173
|
+
BUNDLED WITH
|
174
|
+
2.3.18
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Aleksandr Starovojtov
|
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/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Active support subscriber for Opentelemetry
|
2
|
+
# · <a target="_blank" href="https://github.com/Cado-Labs"><img src="https://github.com/Cado-Labs/cado-labs-logos/raw/main/cado_labs_badge.svg" alt="Supported by Cado Labs" style="max-width: 100%; height: 20px"></a> · [![Coverage Status](https://coveralls.io/repos/github/Cado-Labs/otel-active-support-subscriber/badge.svg?branch=master)](https://coveralls.io/github/Cado-Labs/otel-active-support-subscriber?branch=master)
|
3
|
+
|
4
|
+
Helper for the gem "opentelemetry-ruby". Subscribe to active support events and add context active support events to current span.
|
5
|
+
|
6
|
+
---
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<a href="https://github.com/Cado-Labs">
|
10
|
+
<img src="https://github.com/Cado-Labs/cado-labs-resources/blob/main/cado_labs_supporting_rounded.svg" alt="Supported by Cado Labs" />
|
11
|
+
</a>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# --- from GitHub ---
|
20
|
+
gem 'otel-active-support-subscriber', github: "Cado-Labs/otel-active-support-subscriber"
|
21
|
+
# --- or ---
|
22
|
+
gem 'otel-active-support-subscriber'
|
23
|
+
```
|
24
|
+
|
25
|
+
```shell
|
26
|
+
bundle install
|
27
|
+
# --- or ---
|
28
|
+
gem install otel-active-support-subscriber
|
29
|
+
```
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'otel-active-support-subscriber'
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
::Otel::ActiveSupportSubscriber.configure do |config|
|
39
|
+
config.subscribe_to = [/.*/, "/sql/", "sql.sequel"]
|
40
|
+
end
|
41
|
+
```
|
42
|
+
* Array elements starting and ending with "/" are converted to a regular expression
|
43
|
+
|
44
|
+
### Contributing
|
45
|
+
|
46
|
+
- Fork it ( https://github.com/Cado-Labs/otel-active-support-subscriber )
|
47
|
+
- Create your feature branch (`git checkout -b feature/my-new-feature`)
|
48
|
+
- Commit your changes (`git commit -am '[feature_context] Add some feature'`)
|
49
|
+
- Push to the branch (`git push origin feature/my-new-feature`)
|
50
|
+
- Create new Pull Request
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
Released under MIT License.
|
55
|
+
|
56
|
+
## Supporting
|
57
|
+
|
58
|
+
<a href="https://github.com/Cado-Labs">
|
59
|
+
<img src="https://github.com/Cado-Labs/cado-labs-resources/blob/main/cado_labs_supporting_rounded.svg" alt="Supported by Cado Labs" />
|
60
|
+
</a>
|
61
|
+
|
62
|
+
## Authors
|
63
|
+
|
64
|
+
[Aleksandr Starovojtov](https://github.com/AS-AlStar)
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Otel
|
4
|
+
module ActiveSupportSubscriber
|
5
|
+
class Config
|
6
|
+
def subscribe_to
|
7
|
+
@subscribe_to ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def subscribe_to=(events)
|
11
|
+
@subscribe_to = Array(events).flat_map do |e|
|
12
|
+
case
|
13
|
+
when e.is_a?(Regexp) then e
|
14
|
+
when !e.is_a?(String)
|
15
|
+
when e[0] == "/" && e[-1] == "/" then Regexp.new(e[1...-1])
|
16
|
+
else
|
17
|
+
e.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Otel
|
4
|
+
module ActiveSupportSubscriber
|
5
|
+
class Init
|
6
|
+
class << self
|
7
|
+
def call
|
8
|
+
activate_subscribers
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def activate_subscribers
|
14
|
+
events = config.subscribe_to
|
15
|
+
return if events.blank?
|
16
|
+
|
17
|
+
events.each do |event|
|
18
|
+
Otel::ActiveSupportSubscriber::Subscriber.subscribe_to_event!(event)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def config
|
23
|
+
Otel::ActiveSupportSubscriber.config
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Otel
|
4
|
+
module ActiveSupportSubscriber
|
5
|
+
module Subscriber
|
6
|
+
extend self
|
7
|
+
|
8
|
+
IGNORED_PAYLOAD_KEYS = %i[request response headers exception exception_object].freeze
|
9
|
+
|
10
|
+
def subscribe_to_event!(event)
|
11
|
+
ActiveSupport::Notifications
|
12
|
+
.monotonic_subscribe(event) do |name, start, finish, _id, payload|
|
13
|
+
add(name, payload, finish - start)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(name, payload, duration)
|
18
|
+
# skip Rails internal events
|
19
|
+
return if name.start_with?("!")
|
20
|
+
|
21
|
+
span = OpenTelemetry::Trace.current_span
|
22
|
+
return unless span.context.valid?
|
23
|
+
|
24
|
+
if payload.is_a?(Hash)
|
25
|
+
# we should only mutate the copy of the payload
|
26
|
+
payload = payload.dup
|
27
|
+
IGNORED_PAYLOAD_KEYS.each { |key| payload.delete(key) if payload.key?(key) }
|
28
|
+
end
|
29
|
+
|
30
|
+
duration = format("%0.3fms", duration * 1000)
|
31
|
+
span.add_event(
|
32
|
+
name,
|
33
|
+
attributes: {
|
34
|
+
"context" => JSON.dump(payload),
|
35
|
+
"duration" => duration,
|
36
|
+
},
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support"
|
4
|
+
require_relative "active_support_subscriber/config"
|
5
|
+
|
6
|
+
module Otel
|
7
|
+
module ActiveSupportSubscriber
|
8
|
+
class << self
|
9
|
+
def config
|
10
|
+
@config ||= Config.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure
|
14
|
+
yield config
|
15
|
+
Init.call
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require_relative "active_support_subscriber/init"
|
22
|
+
require_relative "active_support_subscriber/subscriber"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/otel/active_support_subscriber/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "otel-active-support-subscriber"
|
7
|
+
spec.version = Otel::ActiveSupportSubscriber::VERSION
|
8
|
+
spec.authors = ["Alexander Starovojtov"]
|
9
|
+
spec.email = ["starovojtov.alexander@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Helper for opentelemetry-ruby"
|
12
|
+
spec.description = "Helper for the 'opentelemetry-ruby'."
|
13
|
+
spec.homepage = "https://github.com/Cado-Labs/otel-active-support-subscriber"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "activesupport", ">= 5.0"
|
26
|
+
spec.add_dependency "opentelemetry-api", "~> 1.1.0"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler"
|
29
|
+
spec.add_development_dependency "bundler-audit"
|
30
|
+
spec.add_development_dependency "opentelemetry-sdk"
|
31
|
+
spec.add_development_dependency "opentelemetry-test-helpers"
|
32
|
+
spec.add_development_dependency "pry"
|
33
|
+
spec.add_development_dependency "railties"
|
34
|
+
spec.add_development_dependency "rake"
|
35
|
+
spec.add_development_dependency "rspec"
|
36
|
+
spec.add_development_dependency "rubocop-config-umbrellio"
|
37
|
+
spec.add_development_dependency "simplecov"
|
38
|
+
spec.add_development_dependency "simplecov-lcov"
|
39
|
+
spec.metadata = {
|
40
|
+
"rubygems_mfa_required" => "true",
|
41
|
+
}
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,246 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: otel-active-support-subscriber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Starovojtov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opentelemetry-api
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler-audit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: opentelemetry-sdk
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: opentelemetry-test-helpers
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: railties
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-config-umbrellio
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: simplecov
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: simplecov-lcov
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
description: Helper for the 'opentelemetry-ruby'.
|
196
|
+
email:
|
197
|
+
- starovojtov.alexander@gmail.com
|
198
|
+
executables: []
|
199
|
+
extensions: []
|
200
|
+
extra_rdoc_files: []
|
201
|
+
files:
|
202
|
+
- ".github/workflows/test.yml"
|
203
|
+
- ".gitignore"
|
204
|
+
- ".rspec"
|
205
|
+
- ".rubocop.yml"
|
206
|
+
- ".ruby-version"
|
207
|
+
- CODE_OF_CONDUCT.md
|
208
|
+
- Gemfile
|
209
|
+
- Gemfile.lock
|
210
|
+
- LICENSE.txt
|
211
|
+
- README.md
|
212
|
+
- Rakefile
|
213
|
+
- bin/console
|
214
|
+
- bin/setup
|
215
|
+
- lib/otel-active-support-subscriber.rb
|
216
|
+
- lib/otel/active_support_subscriber.rb
|
217
|
+
- lib/otel/active_support_subscriber/config.rb
|
218
|
+
- lib/otel/active_support_subscriber/init.rb
|
219
|
+
- lib/otel/active_support_subscriber/subscriber.rb
|
220
|
+
- lib/otel/active_support_subscriber/version.rb
|
221
|
+
- otel-active-support-subscriber.gemspec
|
222
|
+
homepage: https://github.com/Cado-Labs/otel-active-support-subscriber
|
223
|
+
licenses:
|
224
|
+
- MIT
|
225
|
+
metadata:
|
226
|
+
rubygems_mfa_required: 'true'
|
227
|
+
post_install_message:
|
228
|
+
rdoc_options: []
|
229
|
+
require_paths:
|
230
|
+
- lib
|
231
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - ">="
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: 3.0.0
|
236
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
|
+
requirements:
|
238
|
+
- - ">="
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: '0'
|
241
|
+
requirements: []
|
242
|
+
rubygems_version: 3.3.7
|
243
|
+
signing_key:
|
244
|
+
specification_version: 4
|
245
|
+
summary: Helper for opentelemetry-ruby
|
246
|
+
test_files: []
|