Repository navigation
fix(solidstart): Ignore build output spans with span streaming #26782
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
Merged
+347
−91
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
29c4842
fix(solidstart): Ignore build output spans with span streaming
s1gr1d 15a97bc
Merge remote-tracking branch 'origin/develop' into fix/solidstart-bui…
s1gr1d 83104a1
fix(solidstart): Ignore build output spans under a base path
s1gr1d 529ba2a
test(solidstart): Explain why the tunnel apps test build files
s1gr1d cc1d6f7
Merge remote-tracking branch 'origin/develop' into fix/solidstart-bui…
s1gr1d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
dev-packages/e2e-tests/test-applications/solidstart-1-tunnel/tests/build-assets.test.ts
This file contains hidden or 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,28 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { getSpanOp, waitForStreamedSpans } from '@sentry-internal/test-utils'; | ||
|
|
||
| // This app runs under a base path (`/app/`), so it also tests the build file filter with a base path. | ||
| const BUILD_FILE_PATH = '/app/_build/assets/entry.js.map'; | ||
| const PAGE_PATH = '/app/after-build-file'; | ||
|
|
||
| // In development, the server SDK does not know the base path when it initializes. | ||
| test.skip(process.env.TEST_ENV === 'development', 'Production only'); | ||
|
|
||
| test('does not send a server span for a build file under the base path', async ({ baseURL }) => { | ||
| const segmentPaths: string[] = []; | ||
| const pageSegmentPromise = waitForStreamedSpans('solidstart-1-tunnel', spans => { | ||
| segmentPaths.push( | ||
| ...spans | ||
| .filter(span => span.is_segment && getSpanOp(span) === 'http.server') | ||
| .map(span => `${span.attributes['url.path']?.value}`), | ||
| ); | ||
| return segmentPaths.includes(PAGE_PATH); | ||
| }); | ||
|
|
||
| await fetch(`${baseURL}${BUILD_FILE_PATH}`); | ||
| // A span for the build file would arrive before the span of this later request. | ||
| await fetch(`${baseURL}${PAGE_PATH}`); | ||
| await pageSegmentPromise; | ||
|
|
||
| expect(segmentPaths).not.toContain(BUILD_FILE_PATH); | ||
| }); |
28 changes: 28 additions & 0 deletions
28
dev-packages/e2e-tests/test-applications/solidstart-2-tunnel/tests/build-assets.test.ts
This file contains hidden or 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,28 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { getSpanOp, waitForStreamedSpans } from '@sentry-internal/test-utils'; | ||
|
|
||
| // This app runs under a base path (`/app/`), so it also tests the build file filter with a base path. | ||
| const BUILD_FILE_PATH = '/app/_build/assets/entry.js.map'; | ||
| const PAGE_PATH = '/app/after-build-file'; | ||
|
|
||
| // In development, the server SDK does not know the base path when it initializes. | ||
| test.skip(process.env.TEST_ENV === 'development', 'Production only'); | ||
|
|
||
| test('does not send a server span for a build file under the base path', async ({ baseURL }) => { | ||
| const segmentPaths: string[] = []; | ||
| const pageSegmentPromise = waitForStreamedSpans('solidstart-2-tunnel', spans => { | ||
| segmentPaths.push( | ||
| ...spans | ||
| .filter(span => span.is_segment && getSpanOp(span) === 'http.server') | ||
| .map(span => `${span.attributes['url.path']?.value}`), | ||
| ); | ||
| return segmentPaths.includes(PAGE_PATH); | ||
| }); | ||
|
|
||
| await fetch(`${baseURL}${BUILD_FILE_PATH}`); | ||
| // A span for the build file would arrive before the span of this later request. | ||
| await fetch(`${baseURL}${PAGE_PATH}`); | ||
| await pageSegmentPromise; | ||
|
|
||
| expect(segmentPaths).not.toContain(BUILD_FILE_PATH); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,17 +1,25 @@ | ||
| import type { Options } from '@sentry/core'; | ||
| import { applyBrowserTunnelDefaults } from '@sentry/core'; | ||
| import { applyBrowserTunnelDefaults, GLOBAL_OBJ } from '@sentry/core'; | ||
|
|
||
| /** Set on the server by `withSentry` to the app's `server.baseURL`. */ | ||
| /** Holds the app's `server.baseURL` on SolidStart 1 servers. Set by the server bundle and the `instrument.server` file. */ | ||
| export const TUNNEL_BASE_PATH_GLOBAL = '__sentry_solidstart_base_path'; | ||
|
|
||
| declare const __SENTRY_SOLIDSTART_TUNNEL_BASE_PATH__: string | undefined; | ||
|
|
||
| /** | ||
| * Returns the app's base path without a trailing slash. The build defines it where it bundles the SDK: in the browser | ||
| * and in the SolidStart 2 server. The SolidStart 1 server loads the SDK as an external module and reads the global. | ||
| */ | ||
| export function getBasePath(): string { | ||
| return typeof __SENTRY_SOLIDSTART_TUNNEL_BASE_PATH__ !== 'undefined' | ||
| ? __SENTRY_SOLIDSTART_TUNNEL_BASE_PATH__ | ||
| : ((GLOBAL_OBJ as { [TUNNEL_BASE_PATH_GLOBAL]?: string })[TUNNEL_BASE_PATH_GLOBAL] ?? ''); | ||
| } | ||
|
|
||
| /** | ||
| * Serves the browser's managed tunnel under the app's base path, which `withSentry` (SolidStart 1) or | ||
| * `sentrySolidStart` (SolidStart 2) defines at build time. A `basePath` the user set wins. | ||
| */ | ||
| export function applyTunnelBasePath(options: Pick<Options, 'tunnel'>): void { | ||
| const basePath = | ||
| typeof __SENTRY_SOLIDSTART_TUNNEL_BASE_PATH__ !== 'undefined' ? __SENTRY_SOLIDSTART_TUNNEL_BASE_PATH__ : ''; | ||
| options.tunnel = applyBrowserTunnelDefaults(options.tunnel, { basePath }); | ||
| options.tunnel = applyBrowserTunnelDefaults(options.tunnel, { basePath: getBasePath() }); | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,18 +1,31 @@ | ||
| import { _INTERNAL_captureOptionsSetByUser, applySdkMetadata } from '@sentry/core'; | ||
| import { URL_PATH } from '@sentry/conventions/attributes'; | ||
| import { HTTP_SERVER } from '@sentry/conventions/op'; | ||
| import { _INTERNAL_captureOptionsSetByUser, applySdkMetadata, escapeStringForRegex } from '@sentry/core'; | ||
| import type { NodeClient, NodeOptions } from '@sentry/node'; | ||
| import { init as initNodeSdk } from '@sentry/node'; | ||
| import { filterLowQualityTransactions } from './utils'; | ||
| import { getBasePath } from '../common/tunnel'; | ||
|
|
||
| /** | ||
| * Initializes the server side of the Solid Start SDK | ||
| */ | ||
| export function init(options: NodeOptions): NodeClient | undefined { | ||
| const opts = { | ||
| ..._INTERNAL_captureOptionsSetByUser(options), | ||
| ignoreSpans: [...(options.ignoreSpans || []), getBuildAssetRequestFilter()], | ||
| }; | ||
|
|
||
| applySdkMetadata(opts, 'solidstart', ['solidstart', 'node']); | ||
| filterLowQualityTransactions(opts); | ||
|
|
||
| return initNodeSdk(opts); | ||
| } | ||
|
|
||
| /** | ||
| * SolidStart serves its client build under `<base path>/_build/`. Matches `url.path`, because a span name has no path | ||
| * yet when `ignoreSpans` runs. | ||
| */ | ||
| function getBuildAssetRequestFilter(): NonNullable<NodeOptions['ignoreSpans']>[number] { | ||
| const basePath = getBasePath(); | ||
| // A full URL as the base (a CDN) is not part of the request path. | ||
| const pathPrefix = basePath.includes('://') ? '' : basePath; | ||
| return { op: HTTP_SERVER, attributes: { [URL_PATH]: new RegExp(`^${escapeStringForRegex(pathPrefix)}/_build/`) } }; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
the tests are in the tunnel because this is the only app that runs under a base path.