Skip to content

Commit

Permalink
chore: more debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Mar 28, 2024
1 parent 1e20025 commit c05df7d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ export class SessionManager {

public async add(message: IncomingRecordingMessage): Promise<void> {
if (this.destroying) {
if (this.debug) {
status.warn('🚽', '[session-manager] add called but we are in a destroying state', {
...this.logContext(),
})
}
return
}

Expand Down Expand Up @@ -200,9 +205,18 @@ export class SessionManager {
}

// NOTE: This is uncompressed size estimate but that's okay as we currently want to over-flush to see if we can shake out a bug
if (this.buffer.sizeEstimate >= this.serverConfig.SESSION_RECORDING_MAX_BUFFER_SIZE_KB * 1024) {
const shouldAttemptFlush =
this.buffer.sizeEstimate >= this.serverConfig.SESSION_RECORDING_MAX_BUFFER_SIZE_KB * 1024
if (shouldAttemptFlush) {
await this.flush('buffer_size')
}
if (this.debug) {
status.info('🚽', `[session-manager] added message`, {
...this.logContext(),
metadata: message.metadata,
shouldAttemptFlush,
})
}
}

public get isEmpty(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,26 @@ export class SessionRecordingIngester {
const overflowKey = `${team_id}:${session_id}`

const { partition, highOffset } = event.metadata
if (this.debugPartition === partition) {
const isDebug = this.debugPartition === partition
if (isDebug) {
status.info('🔁', '[blob_ingester_consumer] - [PARTITION DEBUG] - consuming event', { ...event.metadata })
}

function dropEvent(dropCause: string) {
eventDroppedCounter
.labels({
event_type: 'session_recordings_blob_ingestion',
drop_cause: dropCause,
})
.inc()
if (isDebug) {
status.info('🔁', '[blob_ingester_consumer] - [PARTITION DEBUG] - dropping event', {
...event.metadata,
dropCause,
})
}
}

// Check that we are not below the high-water mark for this partition (another consumer may have flushed further than us when revoking)
if (
await this.persistentHighWaterMarker.isBelowHighWaterMark(
Expand All @@ -275,24 +291,12 @@ export class SessionRecordingIngester {
highOffset
)
) {
eventDroppedCounter
.labels({
event_type: 'session_recordings_blob_ingestion',
drop_cause: 'high_water_mark_partition',
})
.inc()

dropEvent('high_water_mark_partition')
return
}

if (await this.sessionHighWaterMarker.isBelowHighWaterMark(event.metadata, session_id, highOffset)) {
eventDroppedCounter
.labels({
event_type: 'session_recordings_blob_ingestion',
drop_cause: 'high_water_mark',
})
.inc()

dropEvent('high_water_mark')
return
}

Expand Down

0 comments on commit c05df7d

Please sign in to comment.