Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/core/src/logs/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';
import { createLogEnvelope } from './envelope';

const MAX_LOG_BUFFER_SIZE = 100;
const LOG_SEQUENCE_ATTR_KEY = 'sentry.log.sequence';

let _logSequenceNumber = 0;

/**
* Sets a log attribute if the value exists and the attribute key is not already present.
Expand Down Expand Up @@ -163,6 +166,7 @@ export function _INTERNAL_captureLog(
attributes: {
...serializeAttributes(scopeAttributes),
...serializeAttributes(logAttributes, true),
[LOG_SEQUENCE_ATTR_KEY]: { value: _logSequenceNumber++, type: 'integer' },
},
};

Expand Down Expand Up @@ -215,3 +219,10 @@ function _getBufferMap(): WeakMap<Client, Array<SerializedLog>> {
// The reference to the Client <> LogBuffer map is stored on the carrier to ensure it's always the same
return getGlobalSingleton('clientToLogBufferMap', () => new WeakMap<Client, Array<SerializedLog>>());
}

/**
* Resets the log sequence number. Only exported for testing purposes.
*/
export function _INTERNAL_resetLogSequenceNumber(): void {
_logSequenceNumber = 0;
}
Loading
Loading