Skip to content

Commit 8b7812e

Browse files
authored
Merge pull request #6 from Automattic/usielriedl/handle-multiple-local-proxies
Add label for proxy
2 parents d3afbef + 944c7bb commit 8b7812e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/twemproxy_exporter/twemproxy.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ def initialize(exporter, host = 'localhost', port = 22222)
1616
def count
1717
stats = self.stats
1818
name = stats['source']
19-
labels = {twemproxy: name}
19+
proxy = "#{@host}:#{@port}"
20+
labels = {twemproxy: name, proxy: proxy}
2021

2122
@exporter.total_connections.count stats['total_connections'], labels
2223
@exporter.curr_connections.count stats['curr_connections'], labels
2324
@exporter.uptime.count stats['uptime'], labels
2425

2526
stats.each do |cluster, cinfo|
2627
next unless cinfo.is_a? Hash
27-
labels = {twemproxy: name, cluster: cluster}
28+
labels = {twemproxy: name, proxy: proxy, cluster: cluster}
2829

2930
@exporter.fragments.count cinfo['fragments'], labels
3031
@exporter.forward_error.count cinfo['forward_error'], labels
@@ -35,7 +36,7 @@ def count
3536

3637
cinfo.each do |server, sinfo|
3738
next unless sinfo.is_a? Hash
38-
labels = {twemproxy: name, cluster: cluster, server: server}
39+
labels = {twemproxy: name, proxy: proxy, cluster: cluster, server: server}
3940

4041
@exporter.in_queue.count sinfo['in_queue'], labels
4142
@exporter.in_queue_bytes.count sinfo['in_queue_bytes'], labels

spec/twemproxy_exporter/exporter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe TwemproxyExporter::Exporter do
22
let(:stats_file) { File.open("spec/fixtures/files/stats.json") }
33
let(:config) { { "proxies" => ["localhost"] } }
4-
let(:twemproxy_labels) { { twemproxy: "app-production-redis-twemproxy" } }
4+
let(:twemproxy_labels) { { twemproxy: "app-production-redis-twemproxy", proxy: "localhost:22222" } }
55
let(:cluster_labels) { twemproxy_labels.merge({ cluster: "app_persistent" }) }
66

77
before do

0 commit comments

Comments
 (0)