Skip to content

Commit

Permalink
chore: rename one of the metrics (#20)
Browse files Browse the repository at this point in the history
peter-rr authored Jan 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents cbafe46 + 61982b8 commit d6a3d46
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/recorder.ts
Original file line number Diff line number Diff line change
@@ -16,9 +16,9 @@ export class Recorder {
this.record(new Metric(name, MetricType.Gauge, value, metadata));
}

async recordActionExecuted(actionName: string, metadata: MetricMetadata = {}) {
async recordActionFinished(actionName: string, metadata: MetricMetadata = {}) {
metadata['action'] = actionName;
this.record(new Metric('action.executed', MetricType.Counter, 1, metadata));
this.record(new Metric('action.finished', MetricType.Counter, 1, metadata));
}
async recordActionInvoked(actionName: string, metadata: MetricMetadata = {}) {
metadata['action'] = actionName;
10 changes: 5 additions & 5 deletions test/recorder.spec.ts
Original file line number Diff line number Diff line change
@@ -51,12 +51,12 @@ describe('Recorder', function() {
expect(recorderMetricsSpy[0]).toEqual(expectedMetric);
});

it('recordActionExecuted()', async function() {
it('recordActionFinished()', async function() {
const recorderMetricsSpy = [];
const recorder = new Recorder('test', new testSink(), recorderMetricsSpy);
const expectedMetric = new Metric('test.action.executed', MetricType.Counter, 1, { action: 'validate', success: true });
const expectedMetric = new Metric('test.action.finished', MetricType.Counter, 1, { action: 'validate', success: true });

await recorder.recordActionExecuted('validate', { success: true });
await recorder.recordActionFinished('validate', { success: true });
expect(recorderMetricsSpy).toHaveLength(1);
expect(recorderMetricsSpy[0]).toEqual(expectedMetric);
});
@@ -76,9 +76,9 @@ describe('Recorder', function() {
const sink = new testSink();
const recorderMetricsSpy = [];
const {recorder, stop} = WithPeriodicFlushRecorder(new Recorder('test', sink, recorderMetricsSpy), 100);
const expectedMetric = new Metric('test.action.executed', MetricType.Counter, 1, { action: 'validate', success: true });
const expectedMetric = new Metric('test.action.finished', MetricType.Counter, 1, { action: 'validate', success: true });

await recorder.recordActionExecuted('validate', { success: true });
await recorder.recordActionFinished('validate', { success: true });
expect(recorderMetricsSpy).toHaveLength(1);
expect(recorderMetricsSpy[0]).toEqual(expectedMetric);

0 comments on commit d6a3d46

Please sign in to comment.