Skip to content

Commit 6c41841

Browse files
committed
sdk-core: PR suggestion changes
1 parent daba2f1 commit 6c41841

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

packages/sdk-core/src/common/jsonSize.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const booleanSize = (value: boolean) => (value ? 4 : 5);
1515
const undefinedSize = 0;
1616
const nullSize = 'null'.length;
1717

18-
const arraySize = (array: unknown[], replacer?: (this: unknown, key: string, value: unknown) => unknown): number => {
18+
function arraySize(array: unknown[], replacer?: (this: unknown, key: string, value: unknown) => unknown): number {
1919
const bracketLength = 2;
2020
const commaLength = array.length - 1;
2121
let elementsLength = 0;
@@ -33,7 +33,7 @@ const arraySize = (array: unknown[], replacer?: (this: unknown, key: string, val
3333
}
3434

3535
return bracketLength + commaLength + elementsLength;
36-
};
36+
}
3737

3838
const objectSize = (obj: object, replacer?: (this: unknown, key: string, value: unknown) => unknown): number => {
3939
let jsonObject: object;
@@ -126,6 +126,15 @@ function _jsonSize(
126126
return 0;
127127
}
128128

129-
export function jsonSize(value: unknown, replacer?: (this: unknown, key: string, value: unknown) => unknown) {
129+
/**
130+
* Calculates size of the object as it would be serialized into JSON.
131+
*
132+
* _Should_ return the same value as `JSON.stringify(value, replacer).length`.
133+
* This may not be 100% accurate, but should work for our requirements.
134+
* @param value Value to compute length for.
135+
* @param replacer A function that transforms the results as in `JSON.stringify`.
136+
* @returns Final string length.
137+
*/
138+
export function jsonSize(value: unknown, replacer?: (this: unknown, key: string, value: unknown) => unknown): number {
130139
return _jsonSize(undefined, '', value, replacer);
131140
}

packages/sdk-core/src/model/configuration/BacktraceConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export interface BacktraceBreadcrumbsSettings {
8686
* Use `false` to disable the limit.
8787
* @default 1048576 // 1MB
8888
*/
89-
maximumBreadcrumbsSize?: number | false;
89+
maximumTotalBreadcrumbsSize?: number | false;
9090

9191
/**
9292
* Inspects breadcrumb and allows to modify it. If the undefined value is being

packages/sdk-core/src/modules/breadcrumbs/BreadcrumbsManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class BreadcrumbsManager implements BacktraceBreadcrumbs, BacktraceModule
5656
maximumAttributesDepth: defaultIfNotFalse(configuration?.maximumAttributesDepth, 2),
5757
maximumBreadcrumbMessageLength: defaultIfNotFalse(configuration?.maximumBreadcrumbMessageLength, 255),
5858
maximumBreadcrumbSize: defaultIfNotFalse(configuration?.maximumBreadcrumbSize, 64 * 1024),
59-
maximumBreadcrumbsSize: defaultIfNotFalse(configuration?.maximumBreadcrumbsSize, 1024 * 1024),
59+
maximumTotalBreadcrumbsSize: defaultIfNotFalse(configuration?.maximumTotalBreadcrumbsSize, 1024 * 1024),
6060
};
6161

6262
this.breadcrumbsType = configuration?.eventType ?? defaultBreadcurmbType;
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
export interface BreadcrumbLimits {
22
/**
3-
* Specifies maximum number of breadcrumbs stored by the library. By default, only 100 breadcrumbs
4-
* will be stored.
3+
* Specifies maximum number of breadcrumbs stored by the library.
4+
*
5+
* @default 100
56
*/
67
readonly maximumBreadcrumbs?: number;
78

89
/**
910
* Specifies maximum object depth that are included in breadcrumb attributes.
11+
*
12+
* @default 2
1013
*/
1114
readonly maximumAttributesDepth?: number;
1215

1316
/**
1417
* Specifies maximum breadcrumb message length.
1518
* If the size is exceeded, message will be truncated.
19+
*
20+
* @default 255
1621
*/
1722
readonly maximumBreadcrumbMessageLength?: number;
1823

1924
/**
2025
* Specifies maximum single breadcrumb size in bytes.
2126
* If the size is exceeded, the breadcrumb will be skipped.
27+
*
28+
* @default 65536 // 64kB
2229
*/
2330
readonly maximumBreadcrumbSize?: number;
2431

2532
/**
2633
* Specifies maximum breadcrumbs size in bytes.
2734
* If the size is exceeded, oldest breadcrumbs will be skipped.
35+
*
36+
* @default 1048576 // 1MB
2837
*/
29-
readonly maximumBreadcrumbsSize?: number;
38+
readonly maximumTotalBreadcrumbsSize?: number;
3039
}

packages/sdk-core/src/modules/breadcrumbs/storage/InMemoryBreadcrumbsStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class InMemoryBreadcrumbsStorage implements BreadcrumbsStorage, Backtrace
2121
private _breadcrumbs: OverwritingArray<Breadcrumb>;
2222

2323
constructor(private readonly _limits: BreadcrumbsStorageLimits) {
24-
this._breadcrumbs = new OverwritingArray<Breadcrumb>(_limits.maximumBreadcrumbs ?? Infinity);
24+
this._breadcrumbs = new OverwritingArray<Breadcrumb>(_limits.maximumBreadcrumbs ?? 100);
2525
}
2626

2727
public getAttachments(): BacktraceAttachment<unknown>[] {

0 commit comments

Comments
 (0)