|
150 | 150 | end |
151 | 151 | end |
152 | 152 |
|
| 153 | + context "with a metric that takes ALL instead of SUM" do |
| 154 | + it "reports all the values from different processes" do |
| 155 | + allow(Process).to receive(:pid).and_return(12345) |
| 156 | + metric_store1 = subject.for_metric( |
| 157 | + :metric_name, |
| 158 | + metric_type: :gauge, |
| 159 | + metric_settings: { aggregation: :all } |
| 160 | + ) |
| 161 | + metric_store1.set(labels: { foo: "bar" }, val: 1) |
| 162 | + metric_store1.set(labels: { foo: "baz" }, val: 7) |
| 163 | + metric_store1.set(labels: { foo: "yyy" }, val: 3) |
| 164 | + |
| 165 | + allow(Process).to receive(:pid).and_return(23456) |
| 166 | + metric_store2 = subject.for_metric( |
| 167 | + :metric_name, |
| 168 | + metric_type: :gauge, |
| 169 | + metric_settings: { aggregation: :all } |
| 170 | + ) |
| 171 | + metric_store2.set(labels: { foo: "bar" }, val: 3) |
| 172 | + metric_store2.set(labels: { foo: "baz" }, val: 2) |
| 173 | + metric_store2.set(labels: { foo: "zzz" }, val: 1) |
| 174 | + |
| 175 | + expect(metric_store1.all_values).to eq( |
| 176 | + { foo: "bar", pid: "12345" } => 1.0, |
| 177 | + { foo: "bar", pid: "23456" } => 3.0, |
| 178 | + { foo: "baz", pid: "12345" } => 7.0, |
| 179 | + { foo: "baz", pid: "23456" } => 2.0, |
| 180 | + { foo: "yyy", pid: "12345" } => 3.0, |
| 181 | + { foo: "zzz", pid: "23456" } => 1.0, |
| 182 | + ) |
| 183 | + |
| 184 | + # Both processes should return the same value |
| 185 | + expect(metric_store1.all_values).to eq(metric_store2.all_values) |
| 186 | + end |
| 187 | + end |
| 188 | + |
153 | 189 | it "resizes the File if metrics get too big" do |
154 | 190 | truncate_calls_count = 0 |
155 | 191 | allow_any_instance_of(Prometheus::Client::DataStores::DirectFileStore::FileMappedDict). |
|
0 commit comments