Skip to content

Commit

Permalink
Change naming for some methods and update some metadata sent
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-rr committed Nov 17, 2023
1 parent cbee47f commit b29205b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export class Recorder {
this.record(new Metric(name, MetricType.Gauge, value, metadata));
}

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

it('recordActionExecution()', async function() {
it('recordActionExecuted()', 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 });

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

it('recordActionInvoke()', async function() {
it('recordActionInvoked()', async function() {
const recorderMetricsSpy = [];
const recorder = new Recorder('test', new testSink(), recorderMetricsSpy);
const expectedMetric = new Metric('test.action.invoked', MetricType.Counter, 1, { action: 'convert', success: true });
const expectedMetric = new Metric('test.action.invoked', MetricType.Counter, 1, { action: 'convert' });

await recorder.recordActionInvoke('convert', { success: true });
await recorder.recordActionInvoked('convert');
expect(recorderMetricsSpy).toHaveLength(1);
expect(recorderMetricsSpy[0]).toEqual(expectedMetric);
});
Expand All @@ -78,7 +78,7 @@ describe('Recorder', function() {
const {recorder, stop} = WithPeriodicFlushRecorder(new Recorder('test', sink, recorderMetricsSpy), 100);
const expectedMetric = new Metric('test.action.executed', MetricType.Counter, 1, { action: 'validate', success: true });

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

Expand Down

0 comments on commit b29205b

Please sign in to comment.