chore: reduce telemetry queue logging to errors only

- Remove debug, info, and warn logging from telemetry queue system
- Keep only error logging for actual failures
- This reduces log noise in production while still capturing important errors
- Fix ESLint warnings for unused variables
This commit is contained in:
hannesrudolph 2025-08-05 09:59:04 -07:00
parent 1ffa1fabf3
commit 951feff080
4 changed files with 22 additions and 45 deletions

View file

@ -11,7 +11,7 @@ export class CloudQueueProcessor implements QueueProcessor {
try {
// Use the telemetry client to send the event
await this.telemetryClient.capture(event.event)
console.debug(`[CloudQueueProcessor] Successfully processed event ${event.id}`)
// Only log errors, not successes
return true
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)
@ -26,7 +26,7 @@ export class CloudQueueProcessor implements QueueProcessor {
}
// Non-retryable error, consider it "processed" to remove from queue
console.warn(`[CloudQueueProcessor] Non-retryable error for event ${event.id}, removing from queue`)
// Only log actual errors, not warnings about non-retryable errors
return true
}
}

View file

@ -38,7 +38,7 @@ export class GlobalStateQueueStorage implements QueueStorage {
...multiInstanceConfig,
}
console.info(`[QueueStorage] Initialized with instance ID: ${this.instanceId}, hostname: ${this.hostname}`)
// Only log errors, not initialization info
}
/**
@ -80,7 +80,7 @@ export class GlobalStateQueueStorage implements QueueStorage {
// Atomic compare-and-swap
const success = await this.compareAndSwapLock(currentLock, newLock)
if (success) {
console.debug(`[QueueStorage] Lock acquired by instance ${this.instanceId}`)
// Only log errors, not successful lock acquisition
return true
}
}
@ -92,7 +92,7 @@ export class GlobalStateQueueStorage implements QueueStorage {
}
}
console.warn(`[QueueStorage] Failed to acquire lock within ${timeout}ms`)
// Failed to acquire lock within timeout, return silently
return false
}
@ -108,7 +108,7 @@ export class GlobalStateQueueStorage implements QueueStorage {
const currentLock = await this.getLock()
if (currentLock && currentLock.instanceId === this.instanceId) {
await this.context.globalState.update(GlobalStateQueueStorage.LOCK_KEY, undefined)
console.debug(`[QueueStorage] Lock released by instance ${this.instanceId}`)
// Only log errors, not successful lock release
}
} catch (error) {
console.error("[QueueStorage] Error releasing lock:", error)
@ -185,19 +185,13 @@ export class GlobalStateQueueStorage implements QueueStorage {
const sizeInBytes = this.calculateSize(events)
if (sizeInBytes > this.maxStorageSize) {
// Remove oldest events until we're under the limit
let removedCount = 0
let _removedCount = 0
while (events.length > 0 && this.calculateSize(events) > this.maxStorageSize) {
events.shift() // Remove oldest event (FIFO)
removedCount++
_removedCount++
}
if (removedCount > 0) {
console.warn(
`[QueueStorage] Removed ${removedCount} oldest events to stay under ${
this.maxStorageSize / 1024 / 1024
}MB storage limit`,
)
}
// Removed oldest events to stay under storage limit, no need to log
// If even the single new event is too large, throw an error
if (events.length === 0) {
@ -329,9 +323,7 @@ export class GlobalStateQueueStorage implements QueueStorage {
// Exponential backoff with jitter
const delay = baseDelay * Math.pow(2, attempt) + Math.random() * 100
console.warn(
`[QueueStorage] Operation failed, retrying in ${delay}ms (attempt ${attempt + 1}/${maxRetries})`,
)
// Operation failed, retrying silently
await this.sleep(delay)
}
}

View file

@ -42,11 +42,7 @@ export class QueuedTelemetryClient extends BaseTelemetryClient {
this.queue = new TelemetryEventQueue(this.storage, processor, queueOptions)
// Log instance information
const instanceInfo = this.storage.getInstanceInfo()
console.info(
`[QueuedTelemetryClient] Initialized with instance: ${instanceInfo.instanceId} on ${instanceInfo.hostname}`,
)
// Only log errors, not initialization info
// Set up periodic processing if in leader mode
if (multiInstanceConfig?.mode === "leader") {
@ -64,10 +60,8 @@ export class QueuedTelemetryClient extends BaseTelemetryClient {
this.processingInterval = setInterval(async () => {
try {
// Only process if we can acquire the lock (leader election)
const processed = await this.queue.processQueue()
if (processed > 0) {
console.debug(`[QueuedTelemetryClient] Periodic processing: ${processed} events`)
}
await this.queue.processQueue()
// Only log errors, not successful processing
} catch (error) {
console.error("[QueuedTelemetryClient] Periodic processing error:", error)
}
@ -79,9 +73,7 @@ export class QueuedTelemetryClient extends BaseTelemetryClient {
*/
public override async capture(event: TelemetryEvent): Promise<void> {
if (!this.isTelemetryEnabled() || !this.isEventCapturable(event.event)) {
if (this.debug) {
console.info(`[QueuedTelemetryClient#capture] Skipping event: ${event.event}`)
}
// Skip event silently
return
}
@ -174,8 +166,8 @@ export class QueuedTelemetryClient extends BaseTelemetryClient {
// Process any remaining events before shutdown
try {
const processed = await this.queue.processQueue()
console.info(`[QueuedTelemetryClient] Processed ${processed} events during shutdown`)
await this.queue.processQueue()
// Only log errors, not successful shutdown processing
} catch (error) {
console.error("[QueuedTelemetryClient] Failed to process queue during shutdown:", error)
}
@ -191,7 +183,7 @@ export class QueuedTelemetryClient extends BaseTelemetryClient {
* Force process the queue (useful for testing or manual triggers)
*/
public async forceProcessQueue(): Promise<number> {
console.info("[QueuedTelemetryClient] Force processing queue")
// Force processing queue silently
return this.queue.processQueue()
}

View file

@ -95,7 +95,7 @@ export class TelemetryEventQueue {
if (isMultiInstanceEnabled && this.storage instanceof GlobalStateQueueStorage) {
hasLock = await this.storage.acquireLock()
if (!hasLock) {
console.debug("[TelemetryEventQueue] Could not acquire lock, another instance may be processing")
// Only log errors, not debug info about lock acquisition
return 0
}
@ -111,7 +111,7 @@ export class TelemetryEventQueue {
try {
// Check if processor is ready
if (!(await this.processor.isReady())) {
console.debug("[TelemetryEventQueue] Processor not ready, skipping queue processing")
// Only log errors, not debug info about processor readiness
return 0
}
@ -121,16 +121,14 @@ export class TelemetryEventQueue {
// Check if we still hold the lock (for multi-instance)
if (isMultiInstanceEnabled && this.storage instanceof GlobalStateQueueStorage) {
if (!(await this.storage.holdsLock())) {
console.warn("[TelemetryEventQueue] Lost lock during processing, stopping")
// Lost lock during processing, stopping silently
break
}
}
// Skip events that have exceeded retry limit
if (event.retryCount >= this.options.maxRetries) {
console.warn(
`[TelemetryEventQueue] Event ${event.id} exceeded retry limit (${event.retryCount}/${this.options.maxRetries}), removing`,
)
// Event exceeded retry limit, removing silently
await this.storage.remove(event.id)
continue
}
@ -147,16 +145,11 @@ export class TelemetryEventQueue {
await this.storage.update(event)
// Stop processing on failure (no automatic retry)
console.debug(
`[TelemetryEventQueue] Event ${event.id} failed (attempt ${event.retryCount}), stopping queue processing`,
)
break
}
}
if (processedCount > 0) {
console.info(`[TelemetryEventQueue] Successfully processed ${processedCount} events`)
}
// Only log errors, not success info
} catch (error) {
console.error("[TelemetryEventQueue] Queue processing error:", error)
} finally {