-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add _experimental_longtaskNoStartSession
flag
#899
Conversation
49c99ef
to
34e0f4c
Compare
_experimental_longtaskNoStartSession
flag
@@ -52,6 +58,16 @@ export class SplunkLongTaskInstrumentation extends InstrumentationBase { | |||
init(): void {} | |||
|
|||
private _createSpanFromEntry(entry: PerformanceEntry) { | |||
if ( | |||
!!this.initOptions._experimental_longtaskNoStartSession && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core of the PR... if there is no session we do not spawn new one when this flag is set to true
otlp?: boolean | ||
} | ||
|
||
export interface SplunkOtelWebConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to separate file to avoid circular dependency
@@ -633,6 +515,14 @@ export const SplunkRum: SplunkOtelWebType = { | |||
_experimental_getSessionId() { | |||
return this.getSessionId() | |||
}, | |||
|
|||
_internalOnExternalSpanCreated() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this gets called from session recorder - when span is created we extend expiration (inactivity) time of session
export const SESSION_DURATION_SECONDS = 4 * 60 * 60 // 4 hours | ||
export const SESSION_DURATION_MS = SESSION_DURATION_SECONDS * 1000 | ||
export const SESSION_INACTIVITY_TIMEOUT_MS = 15 * 60 * 1000 // 15 minutes | ||
export const SESSION_STORAGE_KEY = '_splunk_rum_sid' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same key is used for cookies and localstorage
cookieStore._set(value) | ||
}, | ||
|
||
_set: throttle((value: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing to cookies/localstorage is throttled. We write directly on load, when session is created and when page gets hidden.
* limitations under the License. | ||
* | ||
*/ | ||
export function throttle<T extends (...args: unknown[]) => any>(func: T, limit: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throttle function with visibilitychange flush feature
// safety valve | ||
return | ||
} | ||
|
||
const cookieValue = encodeURIComponent(JSON.stringify(sessionState)) | ||
const domain = cookieDomain ? `domain=${cookieDomain};` : '' | ||
let cookie = COOKIE_NAME + '=' + cookieValue + '; path=/;' + domain + 'max-age=' + InactivityTimeoutSeconds | ||
let cookie = SESSION_STORAGE_KEY + '=' + cookieValue + '; path=/;' + domain + 'max-age=' + SESSION_DURATION_SECONDS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max-age is set to session duration and expiresAt is in cookie state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer a template string here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job 🤞
Description
Added
_experimental_longtaskNoStartSession
. When set totrue
, no new session will be spawned after the previous one expires when long task occurs. If both_experimental_longtaskNoStartSession
and_experimental_allSpansExtendSession
are set to true,_experimental_longtaskNoStartSession
takes precedence.List Github issue(s) which this PR fixes.
Type of change
Delete options that are not relevant.
How has this been tested?
Delete options that are not relevant.