-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Handle missing root transactions
There are (currently unknown) situations where a span batch may not be able to identify a root transaction. That is, all spans available in the transaction group are siblings. This may not be the ideal fix, and we'll revisit shortly. This is simply to unblock UI errors. Refs GH-90, GH-61
- Loading branch information
Showing
9 changed files
with
681 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
- name: Install deps | ||
run: pnpm install | ||
- name: Build packages | ||
run: pnpm build | ||
- name: Run tests | ||
run: pnpm test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,6 @@ dist-ssr | |
.yalc | ||
yalc.lock | ||
.vite-inspect | ||
.vercel | ||
.vercel | ||
|
||
junit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/core/src/integrations/sentry/utils/traces.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { createId } from '@paralleldrive/cuid2'; | ||
import { describe, expect, test } from 'vitest'; | ||
import { Span } from '../types'; | ||
import { groupSpans } from './traces'; | ||
|
||
function mockSpan({ duration, ...span }: Partial<Span> & { duration?: number } = {}): Span { | ||
const defaultTimestamp = new Date().getTime(); | ||
return { | ||
trace_id: createId(), | ||
span_id: createId(), | ||
parent_span_id: createId(), | ||
op: 'unknown', | ||
status: 'unknown', | ||
start_timestamp: defaultTimestamp, | ||
timestamp: duration ? (span.start_timestamp || defaultTimestamp) + duration : defaultTimestamp, | ||
...span, | ||
}; | ||
} | ||
|
||
describe('groupSpans', () => { | ||
test('empty span list', () => { | ||
expect(groupSpans([])).toEqual([]); | ||
}); | ||
|
||
test('missing root transactions as siblings, creates faux parent', () => { | ||
const parent_span_id = createId(); | ||
const span1 = mockSpan({ | ||
parent_span_id, | ||
}); | ||
const span2 = mockSpan({ | ||
parent_span_id, | ||
}); | ||
const result = groupSpans([span1, span2]); | ||
expect(result.length).toEqual(1); | ||
expect(result[0].op).toEqual('unknown'); | ||
expect(result[0].status).toEqual('unknown'); | ||
expect(result[0].parent_span_id).toBe(null); | ||
expect(result[0].children?.length).toEqual(2); | ||
expect(result[0].children![0].span_id).toEqual(span1.span_id); | ||
expect(result[0].children![1].span_id).toEqual(span2.span_id); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference types="vitest" /> | ||
|
||
// import tsconfigPaths from "vite-tsconfig-paths"; | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
// plugins: [tsconfigPaths()], | ||
test: { | ||
coverage: { | ||
provider: 'v8', | ||
reporter: ['json'], | ||
}, | ||
globals: true, | ||
// setupFiles: ["./src/test/setup-test-env.ts"], | ||
include: ['./src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
watchExclude: ['.*\\/node_modules\\/.*', '.*\\/dist\\/.*'], | ||
}, | ||
}); |
Empty file.
Oops, something went wrong.