Skip to content

Commit

Permalink
Add sendMetric() to able sending custom metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
valamidev committed Jan 13, 2024
1 parent e67a941 commit 1dec0cc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/handlers/metricsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ export class GraphiteMetrics extends EventEmitter {
return metrics;
}

public async sendMetric(
name: string,
interval: number,
value: number,
time?: number,
tags?: Record<string, string>
): Promise<void> {
const data: MetricSchema = {
name: this.options.namespace ? `${this.options.namespace}.${name}` : name,
interval,
value,
time: time ?? Date.now(),
tags,
};

try {
await this.httpHandler.sendMetrics(data);
} catch (error) {
this.emit("error", error);
} finally {
return;
}
}

public registerGauge(
name: string,
interval: number,
Expand Down

0 comments on commit 1dec0cc

Please sign in to comment.