Don't log downsample warning when unnecessary (#4291)

* fix log

use process.env

ensure the log happens regardless of `isDownsampledSession`

fix log

* oops, revert test
zio/stable
Hailey 2024-05-30 17:52:56 -07:00 committed by GitHub
parent d6275e98c2
commit 8e2c21a882
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 7 deletions

View File

@ -102,15 +102,18 @@ export function logEvent<E extends keyof LogEvents>(
rawMetadata: LogEvents[E] & FlatJSONRecord, rawMetadata: LogEvents[E] & FlatJSONRecord,
) { ) {
try { try {
if (isDownsampledSession && DOWNSAMPLED_EVENTS.has(eventName)) { if (
return process.env.NODE_ENV === 'development' &&
} eventName.endsWith(':sampled') &&
if (process.env.NODE_ENV === 'development') { !DOWNSAMPLED_EVENTS.has(eventName)
if (eventName.endsWith(':sampled')) { ) {
logger.error( logger.error(
'Did you forget to add ' + eventName + ' to DOWNSAMPLED_EVENTS?', 'Did you forget to add ' + eventName + ' to DOWNSAMPLED_EVENTS?',
) )
} }
if (isDownsampledSession && DOWNSAMPLED_EVENTS.has(eventName)) {
return
} }
const fullMetadata = { const fullMetadata = {
...rawMetadata, ...rawMetadata,