datadog_notifier 1.0.2

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: 14ff80cbc6ef96b9c11645c8dcc1b677152a1037324abdac0419986a6fe46101
4
+ data.tar.gz: 3e7c6ec0b41bd032c2e938cf513315b6c0b196539586d73e67de74e10bfd3521
5
+ SHA512:
6
+ metadata.gz: 8cf93a28542fd650ec19d3cd7c599c15a476a66311539cd5f3e8e57e972c7e363575538c36ba2afb662c0093960061e9f080c0fbd3e27b3c7288843d81f75c22
7
+ data.tar.gz: 185a201ed12dea3a78e88ae7bf8680dcd2bd57f2b6a6bad4d703b2eb6740d657b108847e64ab409e98f1d6cca4940a18c1218fc4066802821ce97ce82882439e
@@ -0,0 +1,29 @@
1
+ name: Publish Datadog Notifier Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*' # Trigger on version tags, e.g., v1.0.0
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v2
14
+
15
+ - name: Setup Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.7
19
+
20
+ - name: Install dependencies
21
+ run: gem install bundler && bundle install --jobs 4 --retry 3
22
+
23
+ - name: Publish gem
24
+ if: github.ref == 'refs/tags/v*'
25
+ env:
26
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
27
+ run: |
28
+ gem build datadog_notifier.gemspec
29
+ gem push datadog_notifier-*.gem
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Evan McDaniel
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,49 @@
1
+ # Datadog Notifier
2
+ ### Send Custom Errors from Rails application to Dadatdog Error Tracking Dashboard
3
+
4
+ # Steps
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'datadog_notifier'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install datadog_notifier
21
+
22
+ ### Dependency
23
+ * [Datadog](https://github.com/DataDog/dd-trace-rb) must be integrated in the project before we use this gem
24
+
25
+ # Quick Use
26
+ ## Send notification to datadog(Traces to add errors in Datadog)
27
+ ```DatadogNotifier.notify(exception, payload_json)```
28
+
29
+ Here `exception` is the error same as we send for Airbrake i.e `ErrorTracking.notify(exception)` and `payload_json` is an optional parameter where we can pass the payload(json value) to share extra details in datadog error tracking
30
+
31
+ ## Error Tracking Dashboard link
32
+ - [Error Tracking](https://app.datadoghq.com/apm/error-tracking)
33
+ - We can filter out these custom errors using `@custom_dd_notifier:true` as we are passing this custom_dd_notifier while sending custom errors to datadog.
34
+
35
+
36
+ ## Replace existing custom ErrorTracking with DatadogNotifier
37
+ We have kept DatadogNotifier signature same as other ErrorTracking services. This will help us to just search and replace all occurences.
38
+ Just replace **ErrorTracking.notify** with **DatadogNotifier.notify**
39
+ ```
40
+ Before: ErrorTracking.notify("ProductErrorForm: Error while scraping new product", error_params_json)
41
+ After: DatadogNotifier.notify("ProductErrorForm: Error while scraping new product", error_params_json)
42
+ ```
43
+
44
+ ## Contributing
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/patterninc/datadog_notifier
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'datadog_notifier'
4
+ require "datadog_notifier/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'datadog_notifier'
8
+ spec.version = DatadogNotifier::VERSION
9
+ spec.authors = ['Patterninc']
10
+ spec.email = ['amol.udage@pattern.com']
11
+ spec.summary = 'Datadog notifier to send custom errors with ddtrace'
12
+ spec.description = 'Datadog notifier to send custom errors in Datadog error tracking dashboard'
13
+ spec.homepage = 'https://github.com/patterninc/datadog_notifier'
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+ spec.required_ruby_version = ">= 2.7.0"
25
+
26
+ spec.add_development_dependency "bundler", "~> 2.2.3"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
+
29
+ spec.add_dependency 'ddtrace', '>= 1.13.0'
30
+
31
+ # If needed, add development dependencies
32
+ spec.add_development_dependency 'rspec'
33
+ # ... (other development dependencies)
34
+ end
@@ -0,0 +1,3 @@
1
+ class DatadogNotifier
2
+ VERSION = "1.0.2"
3
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ddtrace'
4
+ require 'datadog_notifier_exception'
5
+ require "datadog_notifier/version"
6
+
7
+ # DatadogNotifier for custom error notification to datadog
8
+ class DatadogNotifier
9
+ def self.notify(exception, payload = {})
10
+ root_span = find_root_span(Datadog::Tracing.active_span)
11
+ if exception.is_a?(String)
12
+ exception = DatadogNotifierException.new exception
13
+ exception.set_backtrace(payload.inspect)
14
+ end
15
+ root_span.set_error(exception)
16
+ root_span.set_tag('custom_dd_notifier', true)
17
+ root_span.set_tag('payload', payload.to_json) if payload.present?
18
+ end
19
+
20
+ def self.find_root_span(child_span)
21
+ current_span = child_span
22
+ current_span = current_span.send(:parent) while current_span.send(:parent)
23
+ current_span
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DatadogNotifierException < StandardError
4
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: datadog_notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Patterninc
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-02-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.3
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ddtrace
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.13.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.13.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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
+ description: Datadog notifier to send custom errors in Datadog error tracking dashboard
70
+ email:
71
+ - amol.udage@pattern.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".github/workflows/publish.yml"
77
+ - LICENSE.txt
78
+ - README.md
79
+ - datadog_notifier.gemspec
80
+ - lib/datadog_notifier.rb
81
+ - lib/datadog_notifier/version.rb
82
+ - lib/datadog_notifier_exception.rb
83
+ homepage: https://github.com/patterninc/datadog_notifier
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.7.0
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubygems_version: 3.2.3
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Datadog notifier to send custom errors with ddtrace
106
+ test_files: []