Skip to content

Commit 1b39e7e

Browse files
authored
Add new sentry-opentelemetry gem (#1948)
### Summary * new gem `sentry-opentelemetry` to be used as described [here](https://github.com/getsentry/sentry-ruby/blob/neel/otel-gem/sentry-opentelemetry/README.md#getting-started) * all sentry instrumentation will be disabled by a new `config.instrumeneter` option so that sentry and otel do not step on each other's toes * the 2 main things are * a [`SpanProcessor`](https://github.com/getsentry/sentry-ruby/blob/neel/otel-gem/sentry-opentelemetry/lib/sentry/opentelemetry/span_processor.rb) that hooks into `on_start/on_finish` whenever OpenTelemetry starts/finishes a span. This in turn creates sentry transactions/spans as necessary and keeps track of them in an internal `span_map` hash. * a [`Propagator`](https://github.com/getsentry/sentry-ruby/blob/neel/otel-gem/sentry-opentelemetry/lib/sentry/opentelemetry/propagator.rb) to make sure distributed tracing and dynamic sampling work by hooking into `inject/extract` for incoming/outgoing sentry-trace/baggage header management. --- ### Spec https://develop.sentry.dev/sdk/performance/opentelemetry/
1 parent 3567021 commit 1b39e7e

File tree

23 files changed

+1021
-3
lines changed

23 files changed

+1021
-3
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: sentry-opentelemetry Test
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- \d+-\d+
9+
pull_request:
10+
# Cancel in progress workflows on pull_requests.
11+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
jobs:
16+
test:
17+
defaults:
18+
run:
19+
working-directory: sentry-opentelemetry
20+
name: Ruby ${{ matrix.ruby_version }} & OpenTelemetry ${{ matrix.opentelemetry_version }}, options - ${{ toJson(matrix.options) }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
ruby_version: [2.6, 2.7, '3.0', head, jruby]
25+
# opentelemetry_version: [1.2.0]
26+
os: [ubuntu-latest]
27+
include:
28+
- { os: ubuntu-latest, ruby_version: 3.1, options: { rubyopt: "--enable-frozen-string-literal --debug=frozen-string-literal" } }
29+
- { os: ubuntu-latest, ruby_version: 3.1, options: { codecov: 1 } }
30+
steps:
31+
- uses: actions/checkout@v1
32+
33+
- name: Set up Ruby ${{ matrix.ruby_version }}
34+
uses: ruby/setup-ruby@8ddb7b3348b3951590db24c346e94ebafdabc926
35+
with:
36+
ruby-version: ${{ matrix.ruby_version }}
37+
38+
- name: Run specs
39+
env:
40+
RUBYOPT: ${{ matrix.options.rubyopt }}
41+
OPENTELEMETRY_VERSION: ${{ matrix.opentelemetry_version }}
42+
run: |
43+
bundle install --jobs 4 --retry 3
44+
bundle exec rake
45+
46+
- name: Upload Coverage
47+
if: ${{ matrix.options.codecov }}
48+
run: |
49+
curl -Os https://uploader.codecov.io/latest/linux/codecov
50+
chmod +x codecov
51+
./codecov -t ${CODECOV_TOKEN} -R `pwd` -f coverage/coverage.xml

.scripts/batch_build.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INTEGRATIONS = %w(sentry-rails sentry-sidekiq sentry-delayed_job sentry-resque)
1+
INTEGRATIONS = %w(sentry-rails sentry-sidekiq sentry-delayed_job sentry-resque sentry-opentelemetry)
22
GEMS = %w(sentry-ruby) + INTEGRATIONS
33

44
GEMS.each do |gem_name|

.scripts/batch_release.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INTEGRATIONS = %w(sentry-rails sentry-sidekiq sentry-delayed_job sentry-resque)
1+
INTEGRATIONS = %w(sentry-rails sentry-sidekiq sentry-delayed_job sentry-resque sentry-opentelemetry)
22
GEMS = %w(sentry-ruby) + INTEGRATIONS
33

44
def get_version_file_name(gem_name)

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Unreleased
1+
## 5.7.0
22

33
### Features
44

@@ -8,6 +8,8 @@
88
- Add OpenTelemetry support with new `sentry-opentelemetry` gem
99
- Add `config.instrumenter` to switch between `:sentry` and `:otel` instrumentation [#1944](https://github.com/getsentry/sentry-ruby/pull/1944)
1010

11+
The new `sentry-opentelemetry` gem adds support to automatically integrate OpenTelemetry performance tracing with Sentry. [Give it a try](https://github.com/getsentry/sentry-ruby/tree/neel/otel-gem/sentry-opentelemetry#getting-started) and let us know if you have any feedback or problems with using it.
12+
1113
## 5.6.0
1214

1315
### Features

sentry-opentelemetry/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
10+
# rspec failure tracking
11+
.rspec_status

sentry-opentelemetry/.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 [email protected]. 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/

sentry-opentelemetry/Gemfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
source "https://rubygems.org"
2+
git_source(:github) { |name| "https://github.com/#{name}.git" }
3+
4+
# Specify your gem's dependencies in sentry-ruby.gemspec
5+
gemspec
6+
7+
gem "rake", "~> 12.0"
8+
gem "rspec", "~> 3.0"
9+
gem 'simplecov'
10+
gem "simplecov-cobertura", "~> 1.4"
11+
gem "rexml"
12+
13+
# opentelemetry_version = ENV["OPENTELEMETRY_VERSION"]
14+
# opentelemetry_version = "1.2.0" if opentelemetry_version.nil?
15+
# gem "opentelemetry-sdk", "~> #{opentelemetry_version}"
16+
17+
gem "opentelemetry-sdk"
18+
gem "opentelemetry-instrumentation-rails"
19+
20+
gem "sentry-ruby", path: "../sentry-ruby"
21+
22+
gem "object_tracer"
23+
gem "debug", github: "ruby/debug", platform: :ruby if RUBY_VERSION.to_f >= 2.6
24+
gem "pry"

sentry-opentelemetry/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.

sentry-opentelemetry/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build:
2+
bundle install
3+
gem build sentry-opentelemetry.gemspec

0 commit comments

Comments
 (0)