Skip to content

Commit

Permalink
feat: add setDiff (#1263)
Browse files Browse the repository at this point in the history
Co-authored-by: jinbing.jb <jinbing.jb@alibaba-inc.com>
  • Loading branch information
stone-jin and jinbing.jb authored Sep 1, 2021
1 parent da58bf6 commit 2bf7844
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/prometheus/src/service/dataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ export class DataService {
);
}

@Master()
async setDiff(name, diff) {
const current = await this.userDefinedMetrics[name].get();
let value = diff;
if (current.values.length !== 0) {
value = current.values[0].value + diff;
}
this.userDefinedMetrics[name].set(
{ ...this.prometheusConfig.labels },
value
);
}

@Master()
async getData() {
const Register = PromClient.register;
Expand Down

0 comments on commit 2bf7844

Please sign in to comment.