Skip to content

Commit a5b3105

Browse files
committed
Update DiagnosticsMetrics to conditionally log limit warnings
This commit modifies the DiagnosticsMetrics class to log warnings about exceeded attribute limits only if it is in a linked app context
1 parent a2c1eb2 commit a5b3105

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/metrics/DiagnosticsMetrics.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Attributes } from '@opentelemetry/api'
22
import { Types } from '@vtex/diagnostics-nodejs'
33
import { getMetricClient } from '../service/metrics/client'
4-
import { METRIC_CLIENT_INIT_TIMEOUT_MS } from '../constants'
4+
import { METRIC_CLIENT_INIT_TIMEOUT_MS, LINKED } from '../constants'
55

66
/**
77
* Maximum number of attributes allowed per metric to control cardinality.
@@ -33,10 +33,12 @@ function limitAttributes(attributes?: Attributes): Attributes | undefined {
3333
return attributes
3434
}
3535

36-
console.warn(
37-
`Attribute limit exceeded: ${entries.length} attributes provided, using only the first ${MAX_ATTRIBUTES}. ` +
38-
`Consider reducing the number of attributes to avoid high cardinality.`
39-
)
36+
if (LINKED) {
37+
console.warn(
38+
`Attribute limit exceeded: ${entries.length} attributes provided, using only the first ${MAX_ATTRIBUTES}. ` +
39+
`Consider reducing the number of attributes to avoid high cardinality.`
40+
)
41+
}
4042

4143
return Object.fromEntries(entries.slice(0, MAX_ATTRIBUTES))
4244
}

0 commit comments

Comments
 (0)