From 646e2eacd07127f9658b302c09d3056b3b2e1771 Mon Sep 17 00:00:00 2001 From: Ivan Santos Date: Sat, 11 Dec 2021 12:34:23 -0600 Subject: [PATCH] feat: ename value recorder on decorators and update readme --- README.md | 8 ++++---- .../decorators/{value-recorder.ts => histogram.ts} | 4 ++-- src/metrics/decorators/index.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/metrics/decorators/{value-recorder.ts => histogram.ts} (64%) diff --git a/README.md b/README.md index 572ca5d..36a4029 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ You have the following decorators: * `@OtelCounter()` * `@OtelUpDownCounter()` -* `@OtelValueRecorder()` +* `@OtelHistogram()` Example of usage: @@ -272,12 +272,12 @@ Impl |Metric |Description| Labels | Metric Type | ✅ | http_response_total| Total number of HTTP responses.| method, status, path | Counter | | ✅ | http_response_success_total| Total number of all successful responses.| - | Counter | | ✅ | http_response_error_total| Total number of all response errors.| - | Counter | -| ✅ | http_request_duration_seconds | HTTP latency value recorder in seconds. | method, status, path | ValueRecorder | +| ✅ | http_request_duration_seconds | HTTP latency value recorder in seconds. | method, status, path | Histogram | | ✅ | http_client_error_total | Total number of client error requests. | - | Counter | | ✅ | http_server_error_total | Total number of server error requests. | - | Counter | | ✅ | http_server_aborts_total | Total number of data transfers aborted. | - | Counter | -| ✅ | http_request_size_bytes | Current total of incoming bytes. | - | ValueRecorder| -| ✅ | http_response_size_bytes | Current total of outgoing bytes. | - | ValueRecorder | +| ✅ | http_request_size_bytes | Current total of incoming bytes. | - | Histogram| +| ✅ | http_response_size_bytes | Current total of outgoing bytes. | - | Histogram | ## Prometheus Metrics diff --git a/src/metrics/decorators/value-recorder.ts b/src/metrics/decorators/histogram.ts similarity index 64% rename from src/metrics/decorators/value-recorder.ts rename to src/metrics/decorators/histogram.ts index 1810537..aaf9ec3 100644 --- a/src/metrics/decorators/value-recorder.ts +++ b/src/metrics/decorators/histogram.ts @@ -2,9 +2,9 @@ import { createParamDecorator } from '@nestjs/common'; import { MetricOptions } from '@opentelemetry/api-metrics'; import { getOrCreateHistogram, MetricType } from '../metric-data'; -export const OtelValueRecorder = createParamDecorator((name: string, options?: MetricOptions) => { +export const OtelHistogram = createParamDecorator((name: string, options?: MetricOptions) => { if (!name || name.length === 0) { - throw new Error('OtelValueRecorder need a name argument'); + throw new Error('OtelHistogram need a name argument'); } return getOrCreateHistogram(name, MetricType.Histogram, options); }); diff --git a/src/metrics/decorators/index.ts b/src/metrics/decorators/index.ts index 78a2e62..e458232 100644 --- a/src/metrics/decorators/index.ts +++ b/src/metrics/decorators/index.ts @@ -1,3 +1,3 @@ export * from './common'; export * from './counter'; -export * from './value-recorder'; +export * from './histogram';