apm_traceable-datadog 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6cad6c65c6bdc0865f8ecf3cf89a6b858abeb222e4e6ebbfc0f8eed0cb00fccb
4
+ data.tar.gz: 6a668366c9933e2856a59734c482c47715823f194e73b6333654cde4a8c98d15
5
+ SHA512:
6
+ metadata.gz: 402533775b87b1ebefc88d6a1501c63b1a15c476120145546dc4edaee11c5fab62a873cbddd7632106355200950a8e60e66b2dc3062eedc76d0d93d9e7bae539
7
+ data.tar.gz: 5379fa9861dc26226fbb1cfeab0ac51da6e84d111b9299b9a2813da7ed901fc3ac3613a2dd2956b721693024b135d0cf96b5242f23c013455fdc1aec716f5325
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 3.0
7
+ NewCops: enable
8
+ Style/StringLiterals:
9
+ Enabled: true
10
+ EnforcedStyle: single_quotes
11
+
12
+ Style/StringLiteralsInInterpolation:
13
+ Enabled: true
14
+ EnforcedStyle: single_quotes
15
+
16
+ Layout/LineLength:
17
+ Max: 120
18
+
19
+ Metrics/BlockLength:
20
+ Exclude:
21
+ - 'spec/**/*'
22
+ - 'apm_traceable.gemspec'
23
+
24
+ RSpec/MultipleExpectations:
25
+ Enabled: false
26
+ RSpec/ExampleLength:
27
+ Max: 20
28
+ RSpec/NamedSubject:
29
+ Enabled: false
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.2.2
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in apm_traceable-datadog.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 1.21'
11
+ gem 'rubocop-rake', '~> 0.6.0'
12
+ gem 'rubocop-rspec', '~> 2.24.0'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 kokuyouwind
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,46 @@
1
+ # ApmTraceable::Datadog
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/apm_traceable-datadog.svg)](https://badge.fury.io/rb/apm_traceable-datadog)
4
+ [![Build Status](https://github.com/kokuyouwind/apm_traceable-datadog/actions/workflows/main.yml/badge.svg)](https://github.com/kokuyouwind/apm_traceable-datadog/actions/workflows/main.yml)
5
+
6
+ [APM Traceable gem](https://github.com/kokuyouwind/apm_traceable) の [Datadog APM](https://docs.datadoghq.com/ja/tracing/) 用アダプターです。
7
+
8
+ ## Installation
9
+
10
+ APM Traceable とこのgemの2つを Gemfile に記述します。
11
+
12
+
13
+ ```ruby
14
+ gem 'apm_traceable'
15
+ gem 'apm_traceable-datadog' # Datadogの場合
16
+ ```
17
+
18
+ その後、以下を実行してください。
19
+
20
+ $ bundle install
21
+
22
+ アダプタを設定する際、Datadog APM のサービス名を `service_name` に指定してください。
23
+
24
+ ```ruby
25
+ ApmTraceable.configure do |config|
26
+ config.adapter = 'datadog', { service_name: 'test_service' }
27
+ end
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ 利用方法は [APM Traceable の README](https://github.com/kokuyouwind/apm_traceable#usage) を参照してください。
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kokuyouwind/apm_traceable-datadog.
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/apm_traceable/datadog/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'apm_traceable-datadog'
7
+ spec.version = ApmTraceable::Datadog::VERSION
8
+ spec.authors = ['kokuyouwind']
9
+ spec.email = ['kokuyouwind@gmail.com']
10
+
11
+ spec.summary = 'APM Traceable gem Plugin for Datadog'
12
+ spec.description = 'APM Traceable gem Plugin for Datadog'
13
+ spec.homepage = 'https://github.com/kokuyouwind/apm_traceable-datadog'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.0.0'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/kokuyouwind/apm_traceable-datadog'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/kokuyouwind/apm_traceable-datadog'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_dependency 'activesupport', '>= 7.0.0'
33
+ spec.add_dependency 'apm_traceable', '>= 1.0.0'
34
+ spec.add_dependency 'ddtrace', '~> 1.14.0'
35
+ spec.metadata['rubygems_mfa_required'] = 'true'
36
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'apm_traceable/datadog'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/inflector'
4
+ require 'datadog/tracing'
5
+
6
+ module ApmTraceable
7
+ module Adapters
8
+ # Datadogへトレース結果を送るためのアダプター
9
+ class DatadogAdapter
10
+ def initialize(service_name:)
11
+ super()
12
+
13
+ @service_name = service_name
14
+ end
15
+
16
+ def trace(trace_name, context_class:, **options, &block)
17
+ ::Datadog::Tracing.trace(
18
+ trace_name,
19
+ **options.merge(service: service_name, resource: resource_name(context_class)),
20
+ &block
21
+ )
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :service_name
27
+
28
+ def resource_name(context_class)
29
+ # include 先のクラス名を利用して `admin.users_controller` のような文字列を作る
30
+ context_class.name.underscore&.tr('/', '.')
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApmTraceable
4
+ module Datadog
5
+ VERSION = '1.0.0'
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'apm_traceable'
4
+
5
+ require_relative 'adapters/datadog_adapter'
6
+ require_relative 'datadog/version'
7
+
8
+ module ApmTraceable
9
+ # ApmTraceable::Datadog 全体のモジュール
10
+ module Datadog
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apm_traceable-datadog
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - kokuyouwind
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-10-16 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: 7.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 7.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: apm_traceable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.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.0.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.14.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.14.0
55
+ description: APM Traceable gem Plugin for Datadog
56
+ email:
57
+ - kokuyouwind@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rspec"
63
+ - ".rubocop.yml"
64
+ - ".tool-versions"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - apm_traceable-datadog.gemspec
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/apm_traceable/adapters/datadog_adapter.rb
73
+ - lib/apm_traceable/datadog.rb
74
+ - lib/apm_traceable/datadog/version.rb
75
+ homepage: https://github.com/kokuyouwind/apm_traceable-datadog
76
+ licenses:
77
+ - MIT
78
+ metadata:
79
+ homepage_uri: https://github.com/kokuyouwind/apm_traceable-datadog
80
+ source_code_uri: https://github.com/kokuyouwind/apm_traceable-datadog
81
+ changelog_uri: https://github.com/kokuyouwind/apm_traceable-datadog
82
+ rubygems_mfa_required: 'true'
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 3.0.0
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubygems_version: 3.4.10
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: APM Traceable gem Plugin for Datadog
102
+ test_files: []