Skip to content

Commit

Permalink
Merge branch 'main' into feat/replay
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/session-recorder/src/index.ts
  • Loading branch information
potty committed Jan 31, 2025
2 parents d348cb0 + 6c9ab7e commit 55015f0
Show file tree
Hide file tree
Showing 24 changed files with 207 additions and 96 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
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-node@v4.0.3
- uses: actions/setup-node@v4.2.0
with:
node-version: '18'
cache: 'npm'
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-node@v4.0.3
- uses: actions/setup-node@v4.2.0
with:
node-version: '18'
cache: 'npm'
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-node@v4.0.3
- uses: actions/setup-node@v4.2.0
with:
node-version: '18'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ build_artifacts:
script:
- if [ ! -d "artifacts" ]; then mkdir artifacts; fi
- npm run compile
- npm pack --pack-destination artifacts -ws
- npm pack --pack-destination artifacts --workspace packages/session-recorder --workspace packages/web

# complete artifacts & checksums
- cp packages/*/dist/artifacts/* artifacts/
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

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))
* `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))
* chore(internal): use playwright for e2e tests ([#887](https://github.com/signalfx/splunk-otel-js-web/pull/887))

## 0.20.0-beta.0

* `@splunk/otel-web`
Expand Down
43 changes: 22 additions & 21 deletions 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 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.0",
"version": "0.20.0-beta.4",
"--workspaces": "Hardcoded so npm runs workspaces commands in order",
"workspaces": [
"packages/web",
Expand Down Expand Up @@ -65,7 +65,7 @@
"globals": "^15.11.0",
"prettier": "^3.3.3",
"size-limit": "^11.1.6",
"typescript": "^5.1.6",
"typescript": "^5.7.3",
"typescript-eslint": "^8.12.2"
}
}
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.0",
"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
15 changes: 14 additions & 1 deletion packages/integration-tests/src/tests/docload/docload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test.describe('docload', () => {
}
})

test('documentFetch, resourceFetch, and documentLoad spans', async ({ recordPage }) => {
test('documentFetch, resourceFetch, and documentLoad spans', async ({ recordPage, browserName }) => {
await recordPage.goTo('/docload/docload.ejs')

await recordPage.waitForSpans((spans) => spans.filter((span) => span.name === 'documentLoad').length === 1)
Expand Down 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 @@ -96,6 +104,11 @@ test.describe('docload', () => {

expect(docFetchSpans[0].tags['link.traceId']).toBeDefined()
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.status_code'] as string)).toBe(200)
}

expect(parseInt(scriptFetchSpans[0].tags['http.response_content_length'] as string)).toBeGreaterThan(0)

expect(docLoadSpans[0].tags['component']).toBe('document-load')
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.0'
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.0",
"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 @@ -177,9 +177,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 @@ -189,6 +187,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 @@ -204,6 +209,12 @@ const SplunkRumRecorder = {
return
}

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

const time = Math.floor(segment.metadata.startUnixMs)
const eventI = eventCounter

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.0'
export const VERSION = '0.20.0-beta.4'
3 changes: 2 additions & 1 deletion packages/session-recorder/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"pretty": true,
"resolveJsonModule": true,
"target": "ES2017",
"types": ["node"]
"types": ["node"],
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.js"],
"exclude": ["node_modules"]
Expand Down
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.0",
"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
Loading

0 comments on commit 55015f0

Please sign in to comment.