twingly-metrics 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +16 -0
- data/lib/twingly/metrics/grafana_cloud_reporter.rb +15 -3
- data/lib/twingly/metrics/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be11bd1a0f91edf2ac37637732b5ed9452d9ac959354c7cd4cb2dac448e00939
|
4
|
+
data.tar.gz: 4f4aa1606534e1a67ddacdc5058a737733ca0be788af51fa91fb807d7cac8e3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb94deb9dc0274ec9400662f84b93a857fc43d15d39d6c6bcd2ff57c7b2a0a11da6fb1923283537c44fc33ce135464b9788a615a4c6a97a9c670832004471e1d
|
7
|
+
data.tar.gz: df1823f5e97aa1c08d1fdca1ab4e8d30d9620881aa0facbafbe700218f5d1d4bac6e79ee2ba50c436abbce5fa22e1c3499ef00bb30c660db80daf4720f132463
|
data/README.md
CHANGED
@@ -70,3 +70,19 @@ The reporter currently supports the following metric types from the `metriks` ge
|
|
70
70
|
[grafana-cloud]: https://grafana.com/products/cloud/
|
71
71
|
[grafana-cloud-graphite-api]: https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-graphite/http-api/#adding-new-data-posting-to-metrics
|
72
72
|
[metriks-librato_metrics]: https://github.com/eric/metriks-librato_metrics
|
73
|
+
|
74
|
+
## Release workflow
|
75
|
+
|
76
|
+
* Bump the version in `lib/twingly/metrics/version.rb` in a commit, no need to push (the release task does that).
|
77
|
+
|
78
|
+
* Build and [publish](http://guides.rubygems.org/publishing/) the gem. This will create the proper tag in git, push the commit and tag and upload to RubyGems.
|
79
|
+
|
80
|
+
bundle exec rake release
|
81
|
+
|
82
|
+
* If you are not logged in as [twingly][twingly-rubygems] with ruby gems, the rake task will fail. Login using `gem signin` and run the `release` task again. It will be okay.
|
83
|
+
|
84
|
+
* Update the changelog with [GitHub Changelog Generator](https://github.com/skywinder/github-changelog-generator/) (`gem install github_changelog_generator` if you don't have it, set `CHANGELOG_GITHUB_TOKEN` to a personal access token to avoid rate limiting by GitHub). This command will update `CHANGELOG.md`, commit and push manually.
|
85
|
+
|
86
|
+
github_changelog_generator -u twingly -p twingly-metrics
|
87
|
+
|
88
|
+
[twingly-rubygems]: https://rubygems.org/profiles/twingly
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "net/https"
|
4
4
|
require "json"
|
5
5
|
require "metriks"
|
6
|
+
require "socket"
|
6
7
|
|
7
8
|
module Twingly
|
8
9
|
module Metrics
|
@@ -43,13 +44,13 @@ module Twingly
|
|
43
44
|
attr_reader :interval
|
44
45
|
attr_reader :timeout
|
45
46
|
|
46
|
-
def initialize(endpoint:, user:, token:, **options) # rubocop:disable
|
47
|
+
def initialize(endpoint:, user:, token:, **options) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
|
47
48
|
@endpoint = endpoint
|
48
49
|
@user = user
|
49
50
|
@token = token
|
50
51
|
|
51
52
|
@prefix = options[:prefix]
|
52
|
-
@source = options[:source]
|
53
|
+
@source = options[:source] || default_source
|
53
54
|
@logger = options[:logger]
|
54
55
|
|
55
56
|
@registry = options[:registry] || Metriks::Registry.default
|
@@ -109,6 +110,17 @@ module Twingly
|
|
109
110
|
|
110
111
|
private
|
111
112
|
|
113
|
+
def default_source
|
114
|
+
process_id = Process.pid # In case there are multiple processes running on the same host
|
115
|
+
hostname = if ENV["NOMAD_ALLOC_ID"].to_s.strip.empty?
|
116
|
+
Socket.gethostname.gsub(/[^a-zA-Z0-9_-]/, "_")
|
117
|
+
else
|
118
|
+
ENV.fetch("NOMAD_ALLOC_ID")
|
119
|
+
end
|
120
|
+
|
121
|
+
"#{hostname}_pid-#{process_id}"
|
122
|
+
end
|
123
|
+
|
112
124
|
def make_request(request_data) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
113
125
|
return if request_data.empty?
|
114
126
|
|
@@ -212,7 +224,7 @@ module Twingly
|
|
212
224
|
time: time.to_i,
|
213
225
|
}
|
214
226
|
|
215
|
-
graphite_data[:tags] = ["source=#{
|
227
|
+
graphite_data[:tags] = ["source=#{source}"]
|
216
228
|
|
217
229
|
graphite_data
|
218
230
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twingly-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Twingly AB
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-07-
|
10
|
+
date: 2025-07-21 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: metriks
|