dd_post_gauge 0.1.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: 86d3db28dc0132b3448caced037d2a34d16fb12e620b9a1e5d2de2a545b5df6f
4
+ data.tar.gz: f7d0479e08082a9f717563fab6741a193a6f907febe1ac58a5f6b8cc06291502
5
+ SHA512:
6
+ metadata.gz: 4fed6fda52b431da547ad7388034fabb97aae5fca87d3fd1a08209211373959c15debad34a070d792edff90c89e929250a4b48333d3051b88d88ce391a632d28
7
+ data.tar.gz: 5a3047aa3833b10e6f74076713417f97b5694d44e8608385465000be53160fe168bf41210d8590518cdce2d216006138b9fee689a090b9184aabd0d2d070e680
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ NewCops: enable
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Style/StringLiteralsInInterpolation:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Layout/LineLength:
14
+ Max: 120
15
+
16
+ Style/Documentation:
17
+ Enabled: false
data/.sample.env ADDED
@@ -0,0 +1,2 @@
1
+ DATADOG_API_KEY=
2
+ DATADOG_SITE=datadoghq.com
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-12-04
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jun5araki@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
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 dd_post_gauge.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dd_post_gauge (0.1.0)
5
+ datadog_api_client
6
+ dotenv
7
+ thor
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ datadog_api_client (2.4.0)
14
+ httparty (~> 0.20, >= 0.20.0)
15
+ zeitwerk (~> 2.6, >= 2.6.0)
16
+ diff-lcs (1.5.0)
17
+ dotenv (2.8.1)
18
+ httparty (0.20.0)
19
+ mime-types (~> 3.0)
20
+ multi_xml (>= 0.5.2)
21
+ json (2.6.2)
22
+ mime-types (3.4.1)
23
+ mime-types-data (~> 3.2015)
24
+ mime-types-data (3.2022.0105)
25
+ multi_xml (0.6.0)
26
+ parallel (1.22.1)
27
+ parser (3.1.3.0)
28
+ ast (~> 2.4.1)
29
+ rainbow (3.1.1)
30
+ rake (13.0.6)
31
+ regexp_parser (2.6.1)
32
+ rexml (3.2.5)
33
+ rspec (3.11.0)
34
+ rspec-core (~> 3.11.0)
35
+ rspec-expectations (~> 3.11.0)
36
+ rspec-mocks (~> 3.11.0)
37
+ rspec-core (3.11.0)
38
+ rspec-support (~> 3.11.0)
39
+ rspec-expectations (3.11.1)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.11.0)
42
+ rspec-mocks (3.11.1)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-support (3.11.1)
46
+ rubocop (1.39.0)
47
+ json (~> 2.3)
48
+ parallel (~> 1.10)
49
+ parser (>= 3.1.2.1)
50
+ rainbow (>= 2.2.2, < 4.0)
51
+ regexp_parser (>= 1.8, < 3.0)
52
+ rexml (>= 3.2.5, < 4.0)
53
+ rubocop-ast (>= 1.23.0, < 2.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 1.4.0, < 3.0)
56
+ rubocop-ast (1.24.0)
57
+ parser (>= 3.1.1.0)
58
+ ruby-progressbar (1.11.0)
59
+ thor (1.2.1)
60
+ unicode-display_width (2.3.0)
61
+ zeitwerk (2.6.6)
62
+
63
+ PLATFORMS
64
+ arm64-darwin-21
65
+ x86_64-linux
66
+
67
+ DEPENDENCIES
68
+ dd_post_gauge!
69
+ rake (~> 13.0)
70
+ rspec (~> 3.0)
71
+ rubocop (~> 1.21)
72
+
73
+ BUNDLED WITH
74
+ 2.3.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 junara
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,108 @@
1
+ # DdPostGauge
2
+
3
+ CLI for posting [gauge](https://docs.datadoghq.com/ja/metrics/types/?tab=gauge) of custom [metrics](https://docs.datadoghq.com/ja/metrics/) by using [DataDog/datadog-api-client-ruby](https://github.com/DataDog/datadog-api-client-ruby) for [Datadog](https://www.datadoghq.com/ja/).
4
+
5
+ ## Example
6
+ Install this Gem. See [Installation](#installation).
7
+
8
+ Get Datadog API key from `Organaization Settings > API Keys`. See [api key and datadog site](#api-key-and-datadog-site).
9
+
10
+ Confirm Datadog site. See [api key and datadog site](#api-key-and-datadog-site).
11
+
12
+ Prepare `./.env` and replace dummy data.
13
+
14
+ ```shell
15
+ $ cp .env.sample .env
16
+ ```
17
+
18
+ `.env` file
19
+
20
+ ```.env
21
+ DATADOG_API_KEY=XXXXXXXX
22
+ DATADOG_SITE=us5.datadoghq.com
23
+ ```
24
+
25
+ Post 4 points of the gauge to Datadog.
26
+
27
+ ```
28
+ Metrics namae -> hoge.test.ping
29
+ Metrics value -> 10, 50, 20, 70 (4 points)
30
+ Tag -> host
31
+ Tag value -> my.favoite.site.com
32
+ ```
33
+
34
+ ```shell
35
+ $ dd_post_gauge -m hoge.test.ping -v 10 -t host -r my.favoite.site.com
36
+ $ dd_post_gauge -m hoge.test.ping -v 50 -t host -r my.favoite.site.com
37
+ $ dd_post_gauge -m hoge.test.ping -v 20 -t host -r my.favoite.site.com
38
+ $ dd_post_gauge -m hoge.test.ping -v 70 -t host -r my.favoite.site.com
39
+ ```
40
+
41
+ Confirming the posted result in Datadog.
42
+
43
+ * Metrics > Summary
44
+ ![img_metrics](images/img_metrics.png)
45
+
46
+ You can use posted your metrics in the dashboard like other metrics.
47
+
48
+ * `Dashboards > YOUR DASHBOARD` and `Add Widgets > Timeseries`
49
+ ![img.png](lib/dd_post_gauge/img_edit_dashboard.png)
50
+ ![img.png](images/img_dashboard.png)
51
+
52
+ ## Installation
53
+
54
+ Install the gem and add to the application's Gemfile by executing:
55
+
56
+ ```shell
57
+ $ bundle add dd_post_gauge
58
+ ```
59
+
60
+ If bundler is not being used to manage dependencies, install the gem by executing:
61
+
62
+ ```shell
63
+ $ gem install dd_post_gauge
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ ```shell
69
+ $ dd_post_gauge -m <metric_name> -v <metric_value> -r <metric_resource_name> -t <metric_resource_type> -k <api_key> -s <datadog site>
70
+ ```
71
+
72
+ `metric_name` and `metric_value` are required.
73
+
74
+ `metric_resource_name` and `metric_resource_type` are optional.
75
+
76
+ if you have `.env` in the directory and set following variables, you can omit the `api_key` and `datadog site` options.
77
+
78
+ ```.env
79
+ DATADOG_API_KEY=XXXXXXXXXXXXXXXXXXXX
80
+ DATADOG_SITE=datadoghq.com
81
+ ```
82
+
83
+ See `.sample.env`.
84
+
85
+ ### api key and datadog site
86
+ * API key is referred from following page.
87
+ ![img_api_key.png](images/img_api_key.png)
88
+ * https://docs.datadoghq.com/ja/account_management/api-app-keys/
89
+ * Datadog site is referred from following page.
90
+ * https://docs.datadoghq.com/ja/getting_started/site/
91
+
92
+ ## Development
93
+
94
+ 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.
95
+
96
+ 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).
97
+
98
+ ## Contributing
99
+
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/junara/dd_post_gauge. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/dd_post_gauge/blob/main/CODE_OF_CONDUCT.md).
101
+
102
+ ## License
103
+
104
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
105
+
106
+ ## Code of Conduct
107
+
108
+ Everyone interacting in the DdPostGauge project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/dd_post_gauge/blob/main/CODE_OF_CONDUCT.md).
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,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/dd_post_gauge/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "dd_post_gauge"
7
+ spec.version = DdPostGauge::VERSION
8
+ spec.authors = ["junara"]
9
+ spec.email = ["jun5araki@gmail.com"]
10
+
11
+ spec.summary = "Datadog post gauge"
12
+ spec.description = "Datadog post gauge by wrapping datadog api"
13
+ spec.homepage = "https://github.com/junara/dd_post_gauge"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = spec.homepage
20
+ spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/#{spec.name}"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ spec.add_dependency "datadog_api_client"
35
+ spec.add_dependency "dotenv"
36
+ spec.add_dependency "thor"
37
+
38
+ # For more information and examples about making a new gem, check out our
39
+ # guide at: https://bundler.io/guides/creating_gem.html
40
+ spec.metadata["rubygems_mfa_required"] = "true"
41
+ end
data/exe/dd_post_gauge ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "dd_post_gauge"
5
+
6
+ DdPostGauge::Cli.start(ARGV)
Binary file
Binary file
Binary file
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ module DdPostGauge
6
+ class Cli < Thor
7
+ default_command :call
8
+
9
+ desc "version", "Show version"
10
+ def version
11
+ puts DdPostGauge::VERSION
12
+ end
13
+
14
+ desc "call", "Call"
15
+ option :metric_name, required: true, type: :string, aliases: "-m", desc: "Metric name"
16
+ option :value, required: true, type: :numeric, aliases: "-v", desc: "Value"
17
+ option :resource_name, type: :string, aliases: "-r", desc: "Resource name"
18
+ option :type_name, type: :string, aliases: "-t", desc: "Type name. Ex. host"
19
+ option :api_key, type: :string, aliases: "-k", desc: "Datadog API key"
20
+ option :site, type: :string, aliases: "-s", desc: "Datadog Site"
21
+
22
+ def call
23
+ client = DdPostGauge::Client.new(api_key: options[:api_key], site: options[:site])
24
+ client.call(
25
+ options[:metric_name],
26
+ options[:value],
27
+ resource_name: options[:resource_name],
28
+ type_name: options[:type_name]
29
+ )
30
+ end
31
+
32
+ def self.exit_on_failure?
33
+ pp "Exit on failure"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "datadog_api_client"
4
+ require_relative "./gauge_body"
5
+
6
+ module DdPostGauge
7
+ class Client
8
+ # @param [String] api_key
9
+ # @param [String] site
10
+ def initialize(api_key: nil, site: nil)
11
+ Dotenv.load
12
+ @api_key = api_key || ENV.fetch("DATADOG_API_KEY", nil)
13
+ @site = site || ENV.fetch("DATADOG_SITE", "datadoghq.com")
14
+ configure
15
+ end
16
+
17
+ # @param [String] metric_name
18
+ # @param [Integer, Float] value
19
+ # @param [nil, Time] timestamp
20
+ # @param [String, nil] resource_name
21
+ # @param [String, nil] type_name
22
+ # @return [void]
23
+ def call(metric_name, value, timestamp: nil, resource_name: nil, type_name: nil)
24
+ api_instance.submit_metrics(
25
+ body(
26
+ metric_name,
27
+ value,
28
+ unix_timestamp(timestamp),
29
+ resource_name,
30
+ type_name
31
+ )
32
+ )
33
+ end
34
+
35
+ private
36
+
37
+ # @param [Time] timestamp
38
+ # @return [Integer]
39
+ def unix_timestamp(timestamp)
40
+ if timestamp
41
+ timestamp.to_i
42
+ else
43
+ Time.now.to_i
44
+ end
45
+ end
46
+
47
+ def api_instance
48
+ return @api_instance if @api_instance
49
+
50
+ @api_instance = DatadogAPIClient::V2::MetricsAPI.new
51
+ end
52
+
53
+ # @param [String] metric_name
54
+ # @param [Integer, Float] value
55
+ # @param [Integer] timestamp
56
+ # @param [String, nil] resource_name
57
+ # @param [String, nil] type_name
58
+ # @return [DatadogAPIClient::V2::MetricPayload]
59
+ def body(metric_name, value, timestamp, resource_name, type_name)
60
+ DdPostGauge::GaugeBody.new(
61
+ metric_name,
62
+ value,
63
+ timestamp,
64
+ resource_name: resource_name,
65
+ type_name: type_name
66
+ ).payload
67
+ end
68
+
69
+ def configure
70
+ DatadogAPIClient.configure do |config|
71
+ config.server_variables[:site] = @site
72
+ config.api_key = @api_key
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DdPostGauge
4
+ class GaugeBody
5
+ # @param [String] metric_name
6
+ # @param [Integer, Float] value
7
+ # @param [Integer] unix_timestamp
8
+ # @param [String, nil] resource_name
9
+ # @param [String, nil] type_name
10
+ def initialize(metric_name, value, unix_timestamp, resource_name: nil, type_name: nil)
11
+ @metric_name = metric_name
12
+ @value = value
13
+ @unix_timestamp = unix_timestamp
14
+ @resource_name = resource_name
15
+ @type_name = type_name
16
+ end
17
+
18
+ def payload
19
+ DatadogAPIClient::V2::MetricPayload.new(
20
+ {
21
+ series: series
22
+ }
23
+ )
24
+ end
25
+
26
+ private
27
+
28
+ # @return [Array<DatadogAPIClient::V2::MetricSeries>]
29
+ def series
30
+ [
31
+ DatadogAPIClient::V2::MetricSeries.new(
32
+ {
33
+ metric: @metric_name,
34
+ type: type,
35
+ points: points,
36
+ resources: resources
37
+ }
38
+ )
39
+ ]
40
+ end
41
+
42
+ # @return [Array<DatadogAPIClient::V2::MetricPoint>]
43
+ def points
44
+ [
45
+ DatadogAPIClient::V2::MetricPoint.new(
46
+ {
47
+ timestamp: @unix_timestamp,
48
+ value: @value
49
+ }
50
+ )
51
+ ]
52
+ end
53
+
54
+ # @return [Array<DatadogAPIClient::V2::MetricResource>]
55
+ def resources
56
+ [
57
+ DatadogAPIClient::V2::MetricResource.new(
58
+ {
59
+ name: @resource_name,
60
+ type: @type_name
61
+ }
62
+ )
63
+ ]
64
+ end
65
+
66
+ # @return [Object]
67
+ def type
68
+ DatadogAPIClient::V2::MetricIntakeType::GAUGE
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DdPostGauge
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "datadog_api_client"
4
+ require "dotenv"
5
+ require_relative "dd_post_gauge/version"
6
+ require_relative "dd_post_gauge/client"
7
+ require_relative "dd_post_gauge/cli"
8
+ module DdPostGauge
9
+ Dotenv.load
10
+
11
+ class Error < StandardError; end
12
+ end
@@ -0,0 +1,9 @@
1
+ module DdPostGauge
2
+ class Cli
3
+ def self.exit_on_failure?: -> untyped
4
+
5
+ def call: -> untyped
6
+
7
+ def version: -> untyped
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ module DdPostGauge
2
+ class Client
3
+ @api_instance: untyped
4
+ @api_key: String
5
+ @site: String
6
+
7
+ def call: -> void
8
+
9
+ private
10
+
11
+ def api_instance: -> untyped
12
+
13
+ def body: -> untyped
14
+
15
+ def configure: -> untyped
16
+
17
+ def unix_timestamp: -> Integer
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ module DdPostGauge
2
+ class GaugeBody
3
+ @metric_name: String
4
+ @resource_name: String | nil
5
+ @type_name: String | nil
6
+ @value: Integer | Float
7
+ @unix_timestamp: Integer
8
+
9
+ def payload: -> untyped
10
+
11
+ private
12
+
13
+ def points: -> untyped
14
+
15
+ def resources: -> untyped
16
+
17
+ def series: -> untyped
18
+
19
+ def type: -> untyped
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module DdPostGauge
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dd_post_gauge
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - junara
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: datadog_api_client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Datadog post gauge by wrapping datadog api
56
+ email:
57
+ - jun5araki@gmail.com
58
+ executables:
59
+ - dd_post_gauge
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - ".sample.env"
66
+ - CHANGELOG.md
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - dd_post_gauge.gemspec
74
+ - exe/dd_post_gauge
75
+ - images/img_api_key.png
76
+ - images/img_dashboard.png
77
+ - images/img_metrics.png
78
+ - lib/dd_post_gauge.rb
79
+ - lib/dd_post_gauge/cli.rb
80
+ - lib/dd_post_gauge/client.rb
81
+ - lib/dd_post_gauge/gauge_body.rb
82
+ - lib/dd_post_gauge/img_edit_dashboard.png
83
+ - lib/dd_post_gauge/version.rb
84
+ - sig/dd_post_gauge.rbs
85
+ - sig/dd_post_gauge/cli.rbs
86
+ - sig/dd_post_gauge/client.rbs
87
+ - sig/dd_post_gauge/gauge_body.rbs
88
+ homepage: https://github.com/junara/dd_post_gauge
89
+ licenses:
90
+ - MIT
91
+ metadata:
92
+ homepage_uri: https://github.com/junara/dd_post_gauge
93
+ source_code_uri: https://github.com/junara/dd_post_gauge
94
+ changelog_uri: https://github.com/junara/dd_post_gauge
95
+ documentation_uri: https://rubydoc.info/gems/dd_post_gauge
96
+ rubygems_mfa_required: 'true'
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 2.7.0
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubygems_version: 3.3.7
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Datadog post gauge
116
+ test_files: []