mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-09-30 14:59:05 +02:00
fix: various bugs in observability / OTel (#1564)
This commit is contained in:
@@ -4,11 +4,16 @@
|
||||
import Header from '$lib/components/header/header.svelte';
|
||||
import { Toaster } from '$lib/components/ui/sonner';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { startPageTrace } from '$lib/utils/tracing-util';
|
||||
import { beforeNavigate } from '$app/navigation';
|
||||
import { ModeWatcher } from 'mode-watcher';
|
||||
import { type Snippet } from 'svelte';
|
||||
import '../app.css';
|
||||
import type { LayoutData } from './$types';
|
||||
|
||||
// Start a new page-level trace on each navigation so a page view and the API calls it triggers are correlated as a single trace.
|
||||
beforeNavigate((nav) => startPageTrace(nav.to?.url.pathname));
|
||||
|
||||
let {
|
||||
data,
|
||||
children
|
||||
|
||||
@@ -4,6 +4,7 @@ import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import userStore from '$lib/stores/user-store';
|
||||
import { setLocaleForLibraries } from '$lib/utils/locale.util';
|
||||
import { getAuthRedirectPath } from '$lib/utils/redirection-util';
|
||||
import { setTracingEnabled } from '$lib/utils/tracing-util';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
@@ -37,6 +38,10 @@ export const load: LayoutLoad = async ({ url }) => {
|
||||
appConfigStore.set(appConfig);
|
||||
}
|
||||
|
||||
// Only export traces when the backend is configured to forward them; otherwise the SPA would POST spans to an unregistered endpoint.
|
||||
// When enabled this dynamically imports the OpenTelemetry libraries, so awaiting it ensures the tracer provider is ready before any traced navigation or request.
|
||||
await setTracingEnabled(appConfig?.tracingEnabled ?? false);
|
||||
|
||||
await setLocaleForLibraries();
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user