consul-templaterb 1.27.0 → 1.27.1
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/CHANGELOG.md +6 -0
- data/lib/consul/async/consul_template.rb +14 -8
- data/lib/consul/async/version.rb +1 -1
- data/samples/prometheus_datacenter_coordinates.erb +56 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c4d19fa22c559f4a7960529dd3960c1c741f631b1cf0b51f5d10155b2b8a131
|
|
4
|
+
data.tar.gz: 926930e64938a40c2a2653abf9a84f0c86057201646a2f8e02fed06ed51927b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5126d79bcbd0d469bcb7ec5d214c979990056c3c11e1547d4819849f3fcd7fddd1534354f565722a52dbb09ba26c63dd4553f40282fcafaccd7be6a2a1d9442f
|
|
7
|
+
data.tar.gz: 7d6345911c69a8c0622f0b88343968ff951d8243db78d41b8cfad74e26ad5c87a39ae02e3bb24d4cf1615fe329fc53642f81aaf76591d1f5be4098c576baea96
|
data/CHANGELOG.md
CHANGED
|
@@ -31,7 +31,8 @@ module Consul
|
|
|
31
31
|
|
|
32
32
|
def as_json(url, default_value, refresh_delay_secs: 10, **opts)
|
|
33
33
|
conf = JSONConfiguration.new(url: url, min_duration: refresh_delay_secs, retry_on_non_diff: refresh_delay_secs, **opts)
|
|
34
|
-
|
|
34
|
+
endpoint_id = url + opts.to_json
|
|
35
|
+
@endp_manager.create_if_missing(url, {}, endpoint_id: endpoint_id) do
|
|
35
36
|
if default_value.is_a?(Array)
|
|
36
37
|
ConsulTemplateJSONArray.new(JSONEndpoint.new(conf, url, default_value))
|
|
37
38
|
else
|
|
@@ -394,16 +395,21 @@ module Consul
|
|
|
394
395
|
VaultEndpoint.new(vault_conf, path, :POST, {}, {})
|
|
395
396
|
end
|
|
396
397
|
|
|
397
|
-
def create_if_missing(path, query_params, fail_fast_errors: @fail_fast_errors,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
398
|
+
def create_if_missing(path, query_params, fail_fast_errors: @fail_fast_errors,
|
|
399
|
+
max_consecutive_errors_on_endpoint: @max_consecutive_errors_on_endpoint,
|
|
400
|
+
agent: nil, endpoint_id: nil)
|
|
401
|
+
endpoint_id ||= begin
|
|
402
|
+
fqdn = path.dup
|
|
403
|
+
query_params.each_pair do |k, v|
|
|
404
|
+
fqdn = "#{agent}#{fqdn}&#{k}=#{v}"
|
|
405
|
+
end
|
|
406
|
+
fqdn
|
|
407
|
+
end
|
|
408
|
+
tpl = @endpoints[endpoint_id]
|
|
403
409
|
unless tpl
|
|
404
410
|
tpl = yield
|
|
405
411
|
::Consul::Async::Debug.print_debug "path #{path.ljust(64)} #{query_params.inspect}\r"
|
|
406
|
-
@endpoints[
|
|
412
|
+
@endpoints[endpoint_id] = tpl
|
|
407
413
|
tpl.endpoint.on_response do |result|
|
|
408
414
|
@net_info[:success] += 1
|
|
409
415
|
@net_info[:bytes_read] += result.data.bytesize
|
data/lib/consul/async/version.rb
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# HELP consul_wan_servers_rtt_seconds Min Round trip with other servers of DC
|
|
2
|
+
# TYPE consul_wan_servers_rtt_seconds gauge
|
|
3
|
+
<%
|
|
4
|
+
# This computes the RTT over WAN for all DCs
|
|
5
|
+
results = {'min' => {}, 'max' => {}, 'p50' => {}, 'p90' => {}}
|
|
6
|
+
my_dcname = (agent_self['Config'] || {})['Datacenter']
|
|
7
|
+
my_dc = coordinate.datacenters.select { |d| d['Datacenter'] == my_dcname }.first
|
|
8
|
+
|
|
9
|
+
def percentile(values_sorted, percentile)
|
|
10
|
+
k = (percentile*(values_sorted.length-1)+1).floor - 1
|
|
11
|
+
f = (percentile*(values_sorted.length-1)+1).modulo(1)
|
|
12
|
+
return values_sorted[k] + (f * (values_sorted[k+1] - values_sorted[k]))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if my_dc
|
|
16
|
+
from = my_dc['Datacenter']
|
|
17
|
+
coordinate.datacenters.each do |dc_coords|
|
|
18
|
+
min = Float::MAX
|
|
19
|
+
max = 0
|
|
20
|
+
rtts = []
|
|
21
|
+
dc_coords['Coordinates'].each do |s2|
|
|
22
|
+
my_dc['Coordinates'].each do |s1|
|
|
23
|
+
rtt = coordinate.rtt(s1['Coord'], s2['Coord'])
|
|
24
|
+
min = rtt if rtt < min
|
|
25
|
+
max = rtt if rtt > max
|
|
26
|
+
idx = rtts.bsearch_index { |x| x > rtt }
|
|
27
|
+
if idx.nil?
|
|
28
|
+
rtts << rtt
|
|
29
|
+
else
|
|
30
|
+
rtts = rtts.insert(idx, rtt)
|
|
31
|
+
end
|
|
32
|
+
%>
|
|
33
|
+
consul_wan_servers_rtt_seconds{from="<%= from %>",to="<%= dc_coords['Datacenter'] %>",from_node="<%= s1['Node'] %>",to_node="<%= s2['Node'] %>"} <%= rtt.round(3) %><%
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
results['min'][dc_coords['Datacenter']] = min
|
|
37
|
+
results['max'][dc_coords['Datacenter']] = max
|
|
38
|
+
results['p50'][dc_coords['Datacenter']] = percentile(rtts, 0.5)
|
|
39
|
+
results['p90'][dc_coords['Datacenter']] = percentile(rtts, 0.9)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Now, we iterate over aggregated results, type is min, max...
|
|
43
|
+
results.each do |type, res_type|
|
|
44
|
+
%>
|
|
45
|
+
|
|
46
|
+
# HELP consul_wan_dc_<%= type %>_seconds <%= type %> round trip with other DCs
|
|
47
|
+
# TYPE consul_wan_dc_<%= type %>_seconds gauge
|
|
48
|
+
<%
|
|
49
|
+
# Iterate over destinations
|
|
50
|
+
res_type.each do |dst, val|
|
|
51
|
+
%>consul_wan_dc_<%= type %>_seconds{from="<%= my_dcname %>",to="<%= dst %>"} <%= val.round(3) %>
|
|
52
|
+
<%
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
%>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: consul-templaterb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.27.
|
|
4
|
+
version: 1.27.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SRE Core Services
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: em-http-request
|
|
@@ -242,6 +242,7 @@ files:
|
|
|
242
242
|
- samples/members.json.erb
|
|
243
243
|
- samples/metrics.erb
|
|
244
244
|
- samples/prometheus_consul_coordinates.erb
|
|
245
|
+
- samples/prometheus_datacenter_coordinates.erb
|
|
245
246
|
- samples/render_template_from_kv.erb
|
|
246
247
|
- samples/sample_keys.html.erb
|
|
247
248
|
- samples/service_checks_metrics.erb
|
|
@@ -272,8 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
272
273
|
- !ruby/object:Gem::Version
|
|
273
274
|
version: '0'
|
|
274
275
|
requirements: []
|
|
275
|
-
|
|
276
|
-
rubygems_version: 2.7.7
|
|
276
|
+
rubygems_version: 3.0.8
|
|
277
277
|
signing_key:
|
|
278
278
|
specification_version: 4
|
|
279
279
|
summary: Implementation of Consul template using Ruby and .erb templating language
|