Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Aug 23, 2024
1 parent 28559df commit d4251dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/requestduration.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Request, RequestHandler } from 'express';
import type { Histogram } from '@opentelemetry/api';
import { hrTime, hrTimeDuration, hrTimeToMilliseconds } from '@opentelemetry/core';
import {
SEMATTRS_HTTP_METHOD,
SEMATTRS_HTTP_ROUTE,
SEMATTRS_HTTP_STATUS_CODE,
ATTR_HTTP_REQUEST_METHOD,
ATTR_HTTP_RESPONSE_STATUS_CODE,
ATTR_HTTP_ROUTE,
} from '@opentelemetry/semantic-conventions';
import type { OpenApiRequest } from '@myrotvorets/oav-installer';

Expand Down Expand Up @@ -37,9 +37,9 @@ export function requestDurationMiddleware(requestDurationHistogram: Histogram):
const route = extractRoute(req);

requestDurationHistogram.record(hrTimeToMilliseconds(duration), {
[SEMATTRS_HTTP_METHOD]: req.method,
[SEMATTRS_HTTP_ROUTE]: route,
[SEMATTRS_HTTP_STATUS_CODE]: res.statusCode,
[ATTR_HTTP_REQUEST_METHOD]: req.method,
[ATTR_HTTP_ROUTE]: route,
[ATTR_HTTP_RESPONSE_STATUS_CODE]: res.statusCode,
});
};

Expand Down

0 comments on commit d4251dc

Please sign in to comment.