Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automatic datadog instrumentation #152

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2
3.3.6
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 6.1.0 - 2024-07-04
### Changed
- Added support for automatic datadog integration
- Cleanup dev dependencies (dev dependencies go in Gemfile)

## 6.0.0 - 2024-07-04
### Changed
- **breaking changes** Removed support for Rollbar configuration. `config.rollbar` is no longer supported.
Expand Down
12 changes: 12 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@ group :development, :test do
gem 'bundler-audit', require: false
end

gem 'bundler'
gem 'git'
gem 'parse_a_changelog'
gem 'rake'
gem 'rspec'
gem 'rspec-collection_matchers'
gem 'rspec-its'
gem 'rspec_junit_formatter'
gem 'simplecov'
gem 'ws-style'
gem 'datadog'

gemspec
114 changes: 70 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
PATH
remote: .
specs:
pheme (6.0.0)
pheme (6.1.0)
activesupport (>= 4)
aws-sdk-sns (~> 1.1)
aws-sdk-sqs (~> 1.3)
nokogiri (~> 1.17)
resource-struct (~> 0.4)
smarter_csv (~> 1)

GEM
remote: https://rubygems.org/
specs:
activesupport (7.2.1)
activesupport (8.0.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
Expand All @@ -22,132 +24,151 @@ GEM
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
aws-eventstream (1.3.0)
aws-partitions (1.984.0)
aws-sdk-core (3.209.1)
aws-partitions (1.1024.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-sns (1.88.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-sns (1.92.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-sqs (1.86.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-sqs (1.89.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.0)
aws-sigv4 (1.10.1)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
bundler-audit (0.9.2)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
datadog (2.8.0)
datadog-ruby_core_source (~> 3.3)
libdatadog (~> 14.3.1.1.0)
libddwaf (~> 1.18.0.0.0)
msgpack
datadog-ruby_core_source (3.3.7)
diff-lcs (1.5.1)
docile (1.4.1)
drb (2.2.1)
git (2.3.0)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
git (2.3.3)
activesupport (>= 5.0)
addressable (~> 2.8)
process_executer (~> 1.1)
rchardet (~> 1.8)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
json (2.7.2)
json (2.9.1)
language_server-protocol (3.17.0.3)
libdatadog (14.3.1.1.0)
libdatadog (14.3.1.1.0-x86_64-linux)
libddwaf (1.18.0.0.0-arm64-darwin)
ffi (~> 1.0)
libddwaf (1.18.0.0.0-x86_64-linux)
ffi (~> 1.0)
lint_roller (1.1.0)
logger (1.6.1)
minitest (5.25.1)
logger (1.6.3)
minitest (5.25.4)
msgpack (1.7.5)
nokogiri (1.17.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.17.2-x86_64-linux)
racc (~> 1.4)
parallel (1.26.3)
parse_a_changelog (1.3.0)
parse_a_changelog (1.3.3)
treetop (~> 1.6)
parser (3.3.5.0)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
polyglot (0.3.5)
process_executer (1.1.2)
process_executer (1.2.0)
public_suffix (6.0.1)
racc (1.8.1)
rack (3.1.7)
rack (3.1.8)
rainbow (3.1.1)
rake (13.2.1)
rchardet (1.8.0)
regexp_parser (2.9.2)
regexp_parser (2.9.3)
resource-struct (0.4.0)
rexml (3.3.9)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-collection_matchers (1.2.1)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.13.1)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-its (1.3.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-its (2.0.0)
rspec-core (>= 3.13.0)
rspec-expectations (>= 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rspec-support (3.13.2)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.65.1)
rubocop (1.69.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-factory_bot (2.26.1)
rubocop (~> 1.61)
rubocop-performance (1.21.1)
rubocop-performance (1.23.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.26.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.1.0)
rubocop-rspec (3.3.0)
rubocop (~> 1.61)
rubocop-vendor (0.13.1)
rubocop-vendor (0.13.2)
rubocop
ruby-progressbar (1.13.0)
securerandom (0.3.1)
securerandom (0.4.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
smarter_csv (1.12.1)
standard (1.40.1)
smarter_csv (1.13.1)
standard (1.43.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.65.0)
rubocop (~> 1.69.1)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-performance (~> 1.6)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
standard-performance (1.6.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
rubocop-performance (~> 1.23.0)
standard-rails (1.2.0)
lint_roller (~> 1.0)
rubocop-rails (~> 2.26.0)
Expand All @@ -156,7 +177,10 @@ GEM
polyglot (~> 0.3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
unicode-display_width (3.1.2)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uri (1.0.2)
ws-style (7.6.1)
rubocop-factory_bot (>= 2.26.0)
rubocop-rspec (>= 3.0.0)
Expand All @@ -166,19 +190,21 @@ GEM
standard-rails (>= 0.1.0)

PLATFORMS
ruby
arm64-darwin-23
x86_64-linux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has given us trouble before, especially upgrading / devs having different darwin versions... imo would prefer to keep it as just ruby (or keep ruby as one of the platforms anyway)? i know including platform-specific variants means builds won't have to compile native extensions but nokogiri is such a common dependency anyway that 99% of the time im sure it's already going to be cached from a previous build, both in CI or local


DEPENDENCIES
bundler
bundler-audit
datadog
git
parse_a_changelog
pheme!
rake
rspec
rspec-collection_matchers
rspec-its
rspec_junit_formatter (~> 0.2)
rspec_junit_formatter
simplecov
ws-style

Expand Down
15 changes: 13 additions & 2 deletions lib/pheme/queue_poller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ def parse_json(message_contents)
end

def handle(message, metadata, message_attributes)
if defined?(Datadog::Tracing.trace)
handler_name = @message_handler&.name || "block"
Datadog::Tracing.trace('pheme.job', resource: handler_name) do |span|
_handle(message, metadata, message_attributes)
end
else
_handle(message, metadata, message_attributes)
end
end

private

def _handle(message, metadata, message_attributes)
if @message_handler
@message_handler.new(message: message, metadata: metadata, message_attributes: message_attributes).handle
elsif @block_message_handler
Expand All @@ -145,8 +158,6 @@ def handle(message, metadata, message_attributes)
end
end

private

def coerce_message_attribute(value)
case value['Type']
when 'Binary', 'String'
Expand Down
2 changes: 1 addition & 1 deletion lib/pheme/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Pheme
VERSION = '6.0.0'.freeze
VERSION = '6.1.0'.freeze
end
14 changes: 2 additions & 12 deletions pheme.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,12 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']
s.license = 'MIT'

s.required_ruby_version = '>= 3.1'
s.required_ruby_version = '>= 3.2'

s.add_dependency 'activesupport', '>= 4'
s.add_dependency 'aws-sdk-sns', '~> 1.1'
s.add_dependency 'aws-sdk-sqs', '~> 1.3'
s.add_dependency 'resource-struct', '~> 0.4'
s.add_dependency 'smarter_csv', '~> 1'

s.add_development_dependency 'bundler'
s.add_development_dependency 'git'
s.add_development_dependency "parse_a_changelog"
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rspec-collection_matchers'
s.add_development_dependency 'rspec-its'
s.add_development_dependency 'rspec_junit_formatter', '~> 0.2'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'ws-style'
s.add_dependency 'nokogiri', '~> 1.17'
end
Loading