Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into merge-main-2
Browse files Browse the repository at this point in the history
  • Loading branch information
mvirgil committed Jan 29, 2025
2 parents 3714372 + f0360d7 commit b23b57d
Show file tree
Hide file tree
Showing 20 changed files with 174 additions and 80 deletions.
7 changes: 6 additions & 1 deletion .github/actions/install-playwright/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ description: 'Install Playwright browser binaries and OS dependencies'
runs:
using: 'composite'
steps:
- name: Get Node.js version
id: node-version
shell: bash
run: echo "node=$(node -v)" >> $GITHUB_ENV

- name: Get installed Playwright version
id: playwright-version
shell: bash
Expand All @@ -20,7 +25,7 @@ runs:
id: playwright-cache
with:
path: ${{ env.PLAYWRIGHT_CACHE_PATH }}
key: '${{ runner.os }}-playwright-cache-${{ env.PLAYWRIGHT_VERSION }}-splunk-otel-js-web-artifacts'
key: '${{ runner.os }}-node-${{ steps.node-version.outputs.node }}-playwright-cache-${{ env.PLAYWRIGHT_VERSION }}-splunk-otel-js-web-artifacts'

- name: Install Playwright browser binaries
if: steps.playwright-cache.outputs.cache-hit != 'true'
Expand Down
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@

If the version of Open Telemetry is unspecified for a version, then it is the same as in the previous release.

## 0.20.0-beta.4

* `@splunk/otel-web`
* feat: add `http.status_code` to all resources spans
* Resource spans now contain status code. The status code is set always when browser reports it.
Browser does not report status code for [cross-origin resources](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus#value) that do not have [`crossorigin` attribute set](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin).
in such cases, status code is omitted. ([#936](https://github.com/signalfx/splunk-otel-js-web/pull/936))
* fix: do not extend session from discarded session replay spans
* Session is not extended when span is discarded by session replay. Please see detailed info in [PR description](https://github.com/signalfx/splunk-otel-js-web/pull/939).
* There is a possibly breaking change as the `Splunk.getSessionId()` can return `undefined` when previous session
expired and there are no new spans. The API already was typed as returning `string | undefined` hence not
considered as a breaking change. See PR for explanation. ([#939](https://github.com/signalfx/splunk-otel-js-web/pull/939))

## 0.20.0-beta.3

* `@splunk/otel-web`
* fix: rename `http.response.status_code` to `http.status_code` in documentFetch span ([#934](https://github.com/signalfx/splunk-otel-js-web/pull/934))

## 0.20.0-beta.2

* `@splunk/otel-web`
* fix: add 'http.response.status_code' to documentFetch span ([#928](https://github.com/signalfx/splunk-otel-js-web/pull/928))
* fix: add `http.response.status_code` to documentFetch span ([#928](https://github.com/signalfx/splunk-otel-js-web/pull/928))
* `root - internal changes`
* chore(internal): deps bump ([#890](https://github.com/signalfx/splunk-otel-js-web/pull/890), [#915](https://github.com/signalfx/splunk-otel-js-web/pull/915), [#921](https://github.com/signalfx/splunk-otel-js-web/pull/921), [#911](https://github.com/signalfx/splunk-otel-js-web/pull/911))
* chore(internal): update license headers to reflect new year ([#920](https://github.com/signalfx/splunk-otel-js-web/pull/920))
Expand Down
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@splunk/otel-web-dev-root",
"private": true,
"version": "0.20.0-beta.2",
"version": "0.20.0-beta.4",
"--workspaces": "Hardcoded so npm runs workspaces commands in order",
"workspaces": [
"packages/web",
Expand Down
4 changes: 2 additions & 2 deletions packages/integration-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@splunk/otel-js-web-integration-tests",
"private": true,
"version": "0.20.0-beta.2",
"version": "0.20.0-beta.4",
"repository": "github:signalfx/splunk-otel-js-browser",
"scripts": {
"server": "run-p server:*",
Expand All @@ -15,7 +15,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@fastify/static": "^8.0.2",
"@playwright/test": "^1.48.2",
"@playwright/test": "^1.50.0",
"@types/ejs": "^3.1.5",
"@types/express": "^5.0.0",
"@types/node": "^22.9.0",
Expand Down
10 changes: 9 additions & 1 deletion packages/integration-tests/src/tests/docload/docload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,18 @@ test.describe('docload', () => {
expect(scriptFetchSpans[0].traceId).toBe(docLoadSpans[0].traceId)
expect(scriptFetchSpans[0].parentId).toBe(docLoadSpans[0].id)
expect(scriptFetchSpans[0].tags['component']).toBe('document-load')
if (browserName !== 'webkit') {
// Webkit does not support https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus
expect(parseInt(scriptFetchSpans[0].tags['http.status_code'] as string)).toBe(200)
}

expect(brokenImageFetchSpans.length).toBeGreaterThanOrEqual(1)
expect(brokenImageFetchSpans[0].traceId).toBe(docLoadSpans[0].traceId)
expect(brokenImageFetchSpans[0].parentId).toBe(docLoadSpans[0].id)
if (browserName !== 'webkit') {
// Webkit does not support https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus
expect(parseInt(brokenImageFetchSpans[0].tags['http.status_code'] as string)).toBe(404)
}

expect(docFetchSpans[0].tags['component']).toBe('document-load')
expect(docLoadSpans[0].tags['location.href']).toBe('http://localhost:3000/docload/docload.ejs')
Expand All @@ -98,7 +106,7 @@ test.describe('docload', () => {
expect(docFetchSpans[0].tags['link.spanId']).toBeDefined()
if (browserName !== 'webkit') {
// Webkit does not support https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus
expect(parseInt(docFetchSpans[0].tags['http.response.status_code'] as string)).toBe(200)
expect(parseInt(docFetchSpans[0].tags['http.status_code'] as string)).toBe(200)
}

expect(parseInt(scriptFetchSpans[0].tags['http.response_content_length'] as string)).toBeGreaterThan(0)
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
*/

// this is an autogenerated file, see scripts/version-update.js
export const VERSION = '0.20.0-beta.2'
export const VERSION = '0.20.0-beta.4'
2 changes: 1 addition & 1 deletion packages/session-recorder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splunk/otel-web-session-recorder",
"version": "0.20.0-beta.2",
"version": "0.20.0-beta.4",
"description": "Splunk distribution of rrweb for recording session",
"repository": "github:signalfx/splunk-otel-js-browser",
"scripts": {
Expand Down
17 changes: 14 additions & 3 deletions packages/session-recorder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ const SplunkRumRecorder = {
return
}

if (SplunkRum._internalOnExternalSpanCreated) {
SplunkRum._internalOnExternalSpanCreated()
}
let isExtended = false

// Safeguards from our ingest getting DDOSed:
// 1. A session can send up to 4 hours of data
Expand All @@ -206,6 +204,13 @@ const SplunkRumRecorder = {
return
}

// We need to call it here before another getSessionID call. This will create a new session
// if the previous one was expired
if (SplunkRum._internalOnExternalSpanCreated) {
SplunkRum._internalOnExternalSpanCreated()
isExtended = true
}

lastKnownSession = SplunkRum.getSessionId()
sessionStartTime = Date.now()
// reset counters
Expand All @@ -218,6 +223,12 @@ const SplunkRumRecorder = {
return
}

if (!isExtended) {
if (SplunkRum._internalOnExternalSpanCreated) {
SplunkRum._internalOnExternalSpanCreated()
}
}

const time = event.timestamp
const eventI = eventCounter
eventCounter += 1
Expand Down
2 changes: 1 addition & 1 deletion packages/session-recorder/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
*/

// this is an autogenerated file, see scripts/version-update.js
export const VERSION = '0.20.0-beta.2'
export const VERSION = '0.20.0-beta.4'
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splunk/otel-web",
"version": "0.20.0-beta.2",
"version": "0.20.0-beta.4",
"description": "Splunk distribution of Open Telemetry for browser environment.",
"repository": "github:signalfx/splunk-otel-js-browser",
"scripts": {
Expand Down
15 changes: 9 additions & 6 deletions packages/web/src/SessionBasedSampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ export class SessionBasedSampler implements Sampler {

protected _upperBound: number

constructor({
ratio = 1,
sampled = new AlwaysOnSampler(),
notSampled = new AlwaysOffSampler(),
}: SessionBasedSamplerConfig = {}) {
constructor(
{
ratio = 1,
sampled = new AlwaysOnSampler(),
notSampled = new AlwaysOffSampler(),
}: SessionBasedSamplerConfig = {},
private readonly useLocalStorageForSessionMetadata = false,
) {
this._ratio = this._normalize(ratio)
this._upperBound = Math.floor(this._ratio * 0xffffffff)

Expand All @@ -75,7 +78,7 @@ export class SessionBasedSampler implements Sampler {
// Implementation based on @opentelemetry/core TraceIdRatioBasedSampler
// but replacing deciding based on traceId with sessionId
// (not extended from due to private methods)
const currentSession = getRumSessionId()
const currentSession = getRumSessionId({ useLocalStorage: this.useLocalStorageForSessionMetadata })
if (this._currentSession !== currentSession) {
this._currentSessionSampled = this._accumulate(currentSession) < this._upperBound
this._currentSession = currentSession
Expand Down
Loading

0 comments on commit b23b57d

Please sign in to comment.