yabeda-datadog 0.3.5 → 0.3.6.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 31d775a877dc27ec2cfce2991fbf4d4bbdd2ecaf
4
- data.tar.gz: 3b651b67542d2ea0e0394a2454fd21f0570e02c8
2
+ SHA256:
3
+ metadata.gz: a82892703914a5bced4bd2b46116f60cb75c769a55f117cc075b1d052116b5f2
4
+ data.tar.gz: a5f010a0d3424e40edeff64b3a7d89f0cdb58536e394a015c3182428f1ca2b32
5
5
  SHA512:
6
- metadata.gz: 6af936114f046252dca8a4ab1bb5319e5a8fd948816c9833ccd9f1d7e822ae69369f0cd1d631c9ecc93587b2a367d6c959720587350bd77cc8fbb12c952cbe2c
7
- data.tar.gz: da49180f719d2ff003e74443522e257a857610779064224d916c7113138738a27278de035102e642c7edda33a51e7b523dc8b61573308f0e11723f3b32a9b2db
6
+ metadata.gz: c76169f5b4f78c5fa7ca28ebf079c1b6998932dd50e88135c85e0d06c58fece45f3c5034d943ecef4eaf208cc48df23546fc73432998d9f31fe05a860079dbcf
7
+ data.tar.gz: a7da62fda23e9b72487d1204cd86dbedf7f4142516fd05c9afd59dec54d9b3a79f9485e3d0801ac94156ebf74f2b760929ddbf76f4cd312c55612a2cccb69101
@@ -0,0 +1,8 @@
1
+ DD_API_KEY=<your Datadog API key>
2
+ DD_SITE=<your Datadog region site> # e.g. datadoghq.eu
3
+ DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
4
+ DD_HOSTNAME=development-computer
5
+ DD_AC_EXCLUDE=image:.*
6
+ DD_CONTAINER_EXCLUDE=image:.*
7
+ DD_APM_ENABLED=false
8
+ DD_LOGS_ENABLED=false
@@ -0,0 +1,82 @@
1
+ name: Build and release gem to RubyGems
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.7
18
+ - name: "Extract data from tag: version, message, body"
19
+ id: tag
20
+ run: |
21
+ git fetch --tags --force # Really fetch annotated tag. See https://github.com/actions/checkout/issues/290#issuecomment-680260080
22
+ echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
23
+ echo ::set-output name=subject::$(git for-each-ref $GITHUB_REF --format='%(contents:subject)')
24
+ BODY="$(git for-each-ref $GITHUB_REF --format='%(contents:body)')"
25
+ # Extract changelog entries between this and previous version headers
26
+ escaped_version=$(echo ${GITHUB_REF#refs/tags/v} | sed -e 's/[]\/$*.^[]/\\&/g')
27
+ changelog=$(awk "BEGIN{inrelease=0} /## ${escaped_version}/{inrelease=1;next} /## [0-9]+\.[0-9]+\.[0-9]+/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md)
28
+ # Multiline body for release. See https://github.community/t/set-output-truncates-multiline-strings/16852/5
29
+ BODY="${BODY}"$'\n'"${changelog}"
30
+ BODY="${BODY//'%'/'%25'}"
31
+ BODY="${BODY//$'\n'/'%0A'}"
32
+ BODY="${BODY//$'\r'/'%0D'}"
33
+ echo "::set-output name=body::$BODY"
34
+ # Add pre-release option if tag name has any suffix after vMAJOR.MINOR.PATCH
35
+ if [[ ${GITHUB_REF#refs/tags/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
36
+ echo ::set-output name=prerelease::true
37
+ fi
38
+ - name: Build gem
39
+ run: gem build
40
+ - name: Calculate checksums
41
+ run: sha256sum yabeda-datadog-${{ steps.tag.outputs.version }}.gem > SHA256SUM
42
+ - name: Check version
43
+ run: ls -l yabeda-datadog-${{ steps.tag.outputs.version }}.gem
44
+ - name: Create Release
45
+ id: create_release
46
+ uses: actions/create-release@v1
47
+ env:
48
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49
+ with:
50
+ tag_name: ${{ github.ref }}
51
+ release_name: ${{ steps.tag.outputs.subject }}
52
+ body: ${{ steps.tag.outputs.body }}
53
+ draft: false
54
+ prerelease: ${{ steps.tag.outputs.prerelease }}
55
+ - name: Upload built gem as release asset
56
+ uses: actions/upload-release-asset@v1
57
+ env:
58
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
+ with:
60
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
61
+ asset_path: yabeda-datadog-${{ steps.tag.outputs.version }}.gem
62
+ asset_name: yabeda-datadog-${{ steps.tag.outputs.version }}.gem
63
+ asset_content_type: application/x-tar
64
+ - name: Upload checksums as release asset
65
+ uses: actions/upload-release-asset@v1
66
+ env:
67
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68
+ with:
69
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
70
+ asset_path: SHA256SUM
71
+ asset_name: SHA256SUM
72
+ asset_content_type: text/plain
73
+ - name: Publish to GitHub packages
74
+ env:
75
+ GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
76
+ run: |
77
+ gem push yabeda-datadog-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
78
+ - name: Publish to RubyGems
79
+ env:
80
+ GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
81
+ run: |
82
+ gem push yabeda-datadog-${{ steps.tag.outputs.version }}.gem
@@ -0,0 +1,45 @@
1
+ name: Run tests
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - '**'
8
+ tags-ignore:
9
+ - 'v*'
10
+
11
+ jobs:
12
+ test:
13
+ name: "Run tests"
14
+ if: "!contains(github.event.head_commit.message, '[ci skip]')"
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby:
20
+ - 3.0
21
+ - 2.7
22
+ - 2.6
23
+ - 2.5
24
+ container:
25
+ image: ruby:${{ matrix.ruby }}
26
+ env:
27
+ CI: true
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ - uses: actions/cache@v2
31
+ with:
32
+ path: vendor/bundle
33
+ key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
34
+ restore-keys: |
35
+ bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
36
+ bundle-${{ matrix.ruby }}-
37
+ - name: Upgrade Bundler to 2.0 (for older Rubies)
38
+ run: gem install bundler -v '~> 2.0'
39
+ - name: Bundle install
40
+ run: |
41
+ bundle config path vendor/bundle
42
+ bundle install
43
+ bundle update
44
+ - name: Run RSpec
45
+ run: bundle exec rspec
data/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## 0.3.6 - TBD
9
+
10
+ ### Fixed
11
+
12
+ - Compatibility with dogstatsd v5
13
+
14
+ ## 0.3.5 - 2019-05-22
15
+
16
+ ### Fixed
17
+
18
+ - Relaxed anyway_config dependency constraint as there is no breaking changes in anyway_config 2.0. [@palkan]
19
+
20
+ ## 0.3.4 - 2019-03-12
21
+
22
+ ### Fixed
23
+
24
+ - Problem with Gemfile.lock introduced in 0.3.3. [@dmshvetsov]
25
+
26
+ ## 0.3.3 - 2019-03-12
27
+
28
+ ### Fixed
29
+
30
+ - Counters displayed with decimal values in Datadog dashboards. [@dmshvetsov], [#18](https://github.com/yabeda-rb/yabeda-datadog/pull/18)
31
+
32
+ ## 0.3.2 - 2019-02-14
33
+
34
+ ### Fixed
35
+
36
+ - Convert unit names from plural form to singular as Datadog accepts only singular names. [@dmshvetsov], [#16](https://github.com/yabeda-rb/yabeda-datadog/pull/16)
37
+
38
+ ## 0.3.1 - 2019-01-17
39
+
40
+ ### Fixed
41
+
42
+ - Relaxed Ruby version constraint. [@palkan], [#14](https://github.com/yabeda-rb/yabeda-datadog/pull/14)
43
+
44
+ ## 0.3.0 - 2019-01-11
45
+
46
+ First known version by [@dmshvetsov] and [@Neyaz].
47
+
48
+ [@palkan]: https://github.com/palkan "Vladimir Dementyev"
49
+ [@dmshvetsov]: https://github.com/dmshvetsov "Dmitry Shvetsov"
50
+ [@Neyaz]: https://github.com/Neyaz "Nikolay Malinin"
data/README.md CHANGED
@@ -130,6 +130,38 @@ Please see [CONTRIBUTING guide](/CONTRIBUTING.md).
130
130
 
131
131
  Bug reports and pull requests are welcome on GitHub at [https://github.com/shvetsovdm/yabeda-datadog](https://github.com/shvetsovdm/yabeda-datadog).
132
132
 
133
+ ### Releasing
134
+
135
+ 1. Bump version number in `lib/yabeda/datadog/version.rb`
136
+
137
+ In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(Yabeda::Datadog::VERSION).to_s`
138
+
139
+ 2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
140
+
141
+ 3. Make a commit:
142
+
143
+ ```sh
144
+ git add lib/yabeda/datadog/version.rb CHANGELOG.md
145
+ version=$(ruby -r ./lib/yabeda/datadog/version.rb -e "puts Gem::Version.new(Yabeda::Datadog::VERSION)")
146
+ git commit --message="${version}: " --edit
147
+ ```
148
+
149
+ 4. Create annotated tag:
150
+
151
+ ```sh
152
+ git tag v${version} --annotate --message="${version}: " --edit --sign
153
+ ```
154
+
155
+ 5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)
156
+
157
+ 6. Push it:
158
+
159
+ ```sh
160
+ git push --follow-tags
161
+ ```
162
+
163
+ 7. GitHub Actions will create a new release, build and push gem into RubyGems! You're done!
164
+
133
165
  ## License
134
166
 
135
167
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/bin/dev CHANGED
@@ -2,10 +2,21 @@
2
2
 
3
3
  set -e
4
4
 
5
- docker run --rm \
6
- --env-file .datadog-agent.env \
5
+ echo "Starting datadog/agent docker container"
6
+
7
+ ENV_FILE=".datadog-agent.env"
8
+
9
+ if ! test -f "$ENV_FILE"; then
10
+ echo "$ENV_FILE does not exists."
11
+ echo "You can use $ENV_FILE.example to create $ENV_FILE file for datadog agent container."
12
+ exit 1
13
+ fi
14
+
15
+ docker run --name dd-agent \
16
+ --rm \
17
+ --env-file $ENV_FILE \
7
18
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
8
19
  -v /proc/:/host/proc/:ro \
9
20
  -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
10
21
  -p 8125:8125/udp \
11
- datadog/agent:latest
22
+ gcr.io/datadoghq/agent:7
data/examples/script.rb CHANGED
@@ -22,19 +22,22 @@ yabeda_datadog = Yabeda::Datadog.start
22
22
  #
23
23
 
24
24
  Yabeda.configure do
25
- group :yabeda_datadog_gem_examples_script
26
- counter :run_count, comment: "The total number of times the script was executed", unit: "time"
27
- gauge :run_time, comment: "Script execution time", unit: "second"
28
- histogram :rand_num, comment: "Random number", buckets: [0, 20, 40, 60, 80, 100]
25
+ group :yabeda_datadog_gem_examples_script do
26
+ counter :run_count, comment: "The total number of times the script was executed", unit: "time"
27
+ gauge :run_time, comment: "Script execution time", unit: "second"
28
+ histogram :rand_num, comment: "Random number", buckets: [0, 20, 40, 60, 80, 100]
29
+ end
29
30
  end
30
31
 
32
+ Yabeda.configure!
33
+
31
34
  start_time = Time.now
32
- Yabeda.yabeda_datadog_gem_examples_script_run_count.increment(host: "dev_machine")
33
- Yabeda.yabeda_datadog_gem_examples_script_rand_num.measure({ host: "dev_machine", rand: true }, rand(100))
34
- Yabeda.yabeda_datadog_gem_examples_script_rand_num.measure({ host: "dev_machine", rand: true }, rand(100))
35
- Yabeda.yabeda_datadog_gem_examples_script_rand_num.measure({ host: "dev_machine", rand: true }, rand(100))
35
+ Yabeda.yabeda_datadog_gem_examples_script.run_count.increment({ host: "dev_machine" }, by: 1)
36
+ Yabeda.yabeda_datadog_gem_examples_script.rand_num.measure({ host: "dev_machine", rand: true }, rand(100))
37
+ Yabeda.yabeda_datadog_gem_examples_script.rand_num.measure({ host: "dev_machine", rand: true }, rand(100))
38
+ Yabeda.yabeda_datadog_gem_examples_script.rand_num.measure({ host: "dev_machine", rand: true }, rand(100))
36
39
  finish_time = Time.now
37
- Yabeda.yabeda_datadog_gem_examples_script_run_time.set({ host: "dev_machine" }, finish_time - start_time)
40
+ Yabeda.yabeda_datadog_gem_examples_script.run_time.set({ host: "dev_machine" }, finish_time - start_time)
38
41
 
39
42
  puts "Type exit for exit the script" until gets.chomp =~ /^exit$/i
40
43
  puts "Stoping Yabeda::Datadog, please wait ..."
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Datadog
5
- VERSION = "0.3.5"
5
+ VERSION = "0.3.6.rc1"
6
6
  end
7
7
  end
@@ -4,24 +4,29 @@ module Yabeda
4
4
  module Datadog
5
5
  class Worker
6
6
  SEND = proc do |accumulated_payload|
7
- dogstatsd = ::Datadog::Statsd.new(
8
- Yabeda::Datadog.config.agent_host,
9
- Yabeda::Datadog.config.agent_port,
10
- )
11
-
12
- Logging.instance.debug("sending batch of #{accumulated_payload.size} metrics")
13
7
  begin
14
- dogstatsd.batch do |stats|
15
- accumulated_payload.each do |payload|
16
- metric = payload.fetch(:metric)
17
- value = payload.fetch(:value)
18
- tags = payload.fetch(:tags)
8
+ dogstatsd = ::Datadog::Statsd.new(
9
+ Yabeda::Datadog.config.agent_host,
10
+ Yabeda::Datadog.config.agent_port,
11
+ single_thread: true,
12
+ )
13
+
14
+ Logging.instance.debug("sending batch of #{accumulated_payload.size} metrics")
15
+ begin
16
+ dogstatsd.batch do |stats|
17
+ accumulated_payload.each do |payload|
18
+ metric = payload.fetch(:metric)
19
+ value = payload.fetch(:value)
20
+ tags = payload.fetch(:tags)
19
21
 
20
- stats.send(metric.type, metric.name, value, tags: tags)
22
+ stats.send(metric.type, metric.name, value, tags: tags)
23
+ end
21
24
  end
25
+ rescue StandardError => err
26
+ Logging.instance.error("metric sending failed: #{err.message}")
22
27
  end
23
- rescue StandardError => err
24
- Logging.instance.error("metric sending failed: #{err.message}")
28
+ ensure
29
+ dogstatsd.close
25
30
  end
26
31
  end
27
32
  end
@@ -31,11 +31,11 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency "anyway_config", ">= 1.0"
33
33
  spec.add_dependency "dogapi"
34
- spec.add_dependency "dogstatsd-ruby"
34
+ spec.add_dependency "dogstatsd-ruby", "~> 5.2"
35
35
  spec.add_dependency "yabeda"
36
36
 
37
- spec.add_development_dependency "bundler", "~> 1.17"
38
- spec.add_development_dependency "pry", "~> 0.12.2"
39
- spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "bundler", "~> 2.0"
38
+ spec.add_development_dependency "pry", "~> 0.13"
39
+ spec.add_development_dependency "rake", "~> 13.0"
40
40
  spec.add_development_dependency "rspec", "~> 3.0"
41
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-datadog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Shvetsov <@shvetsovdm>
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: dogstatsd-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '5.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '5.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yabeda
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,42 +72,42 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.17'
75
+ version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.17'
82
+ version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.12.2
89
+ version: '0.13'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.12.2
96
+ version: '0.13'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '10.0'
103
+ version: '13.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '10.0'
110
+ version: '13.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -124,17 +124,20 @@ dependencies:
124
124
  version: '3.0'
125
125
  description: 'Adapter for reporting custom metrics from Yabeda to DataDog.
126
126
 
127
- '
127
+ '
128
128
  email:
129
129
  - shvetsovdm@gmail.com
130
130
  executables: []
131
131
  extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
+ - ".datadog-agent.env.example"
135
+ - ".github/workflows/build-release.yml"
136
+ - ".github/workflows/test.yml"
134
137
  - ".gitignore"
135
138
  - ".rspec"
136
139
  - ".rubocop.yml"
137
- - ".travis.yml"
140
+ - CHANGELOG.md
138
141
  - CONTRIBUTING.md
139
142
  - Gemfile
140
143
  - LICENSE.txt
@@ -175,12 +178,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
178
  version: 2.3.0
176
179
  required_rubygems_version: !ruby/object:Gem::Requirement
177
180
  requirements:
178
- - - ">="
181
+ - - ">"
179
182
  - !ruby/object:Gem::Version
180
- version: '0'
183
+ version: 1.3.1
181
184
  requirements: []
182
- rubyforge_project:
183
- rubygems_version: 2.6.13
185
+ rubygems_version: 3.1.6
184
186
  signing_key:
185
187
  specification_version: 4
186
188
  summary: DataDog adapter for reporting metrics from Yabeda suite
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.0
6
- - 2.5.3
7
- - 2.4.2
8
- - 2.3.0
9
- before_install: gem install bundler -v 1.17.3