Skip to content

Commit

Permalink
chore: remove connection id from tracking (#9072)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Jan 9, 2025
1 parent 135c1bd commit 161fa13
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ test('should collect metrics for requests', async () => {

const metrics = await prometheusRegister.metrics();
expect(metrics).toMatch(
/http_request_duration_milliseconds\{quantile="0\.99",path="somePath",method="GET",status="200",appName="undefined",connectionId="undefined"\}.*1337/,
/http_request_duration_milliseconds\{quantile="0\.99",path="somePath",method="GET",status="200",appName="undefined"\}.*1337/,
);
});

Expand Down
5 changes: 2 additions & 3 deletions src/lib/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function registerPrometheusMetrics(
const requestDuration = createSummary({
name: 'http_request_duration_milliseconds',
help: 'App response time',
labelNames: ['path', 'method', 'status', 'appName', 'connectionId'],
labelNames: ['path', 'method', 'status', 'appName'],
percentiles: [0.1, 0.5, 0.9, 0.95, 0.99],
maxAgeSeconds: 600,
ageBuckets: 5,
Expand Down Expand Up @@ -700,14 +700,13 @@ export function registerPrometheusMetrics(

eventBus.on(
events.REQUEST_TIME,
({ path, method, time, statusCode, appName, connectionId }) => {
({ path, method, time, statusCode, appName }) => {
requestDuration
.labels({
path,
method,
status: statusCode,
appName,
connectionId,
})
.observe(time);
},
Expand Down
5 changes: 0 additions & 5 deletions src/lib/middleware/response-time-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export function responseTimeMetrics(
// when pathname is undefined use a fallback
pathname = pathname ?? collapse(req.path);
let appName: string | undefined;
let connectionId: string | undefined;
if (
!flagResolver.isEnabled('responseTimeWithAppNameKillSwitch') &&
(instanceStatsService.getAppCountSnapshot('7d') ??
Expand All @@ -65,9 +64,6 @@ export function responseTimeMetrics(
req.headers['x-unleash-appname'] ??
req.headers['unleash-appname'] ??
req.query.appName;
if (flagResolver.isEnabled('uniqueSdkTracking')) {
connectionId = req.headers['x-unleash-connection-id'];
}
}

const timingInfo = {
Expand All @@ -76,7 +72,6 @@ export function responseTimeMetrics(
statusCode,
time,
appName,
connectionId,
};
if (!res.locals.responseTimeEmitted) {
res.locals.responseTimeEmitted = true;
Expand Down

0 comments on commit 161fa13

Please sign in to comment.