درک نحوه عملکرد برنامه SvelteKit شما در تولید – از جریان درخواست تا تنگناهای عملکرد – برای ایجاد تجربیات کاربر قابل اعتماد بسیار مهم است. SvelteKit اکنون دارای پشتیبانی سطح بالای دید است: ردیابی داخلی OpenTelemetry و یک فایل پیکربندی ابزار اختصاصی که تضمین می کند ابزارهای نظارتی شما به خوبی اجرا می شوند.
برای انتخاب، SvelteKit و آداپتور خود را ارتقا دهید و موارد زیر را به خود اضافه کنید svelte.config.js:
SvelteKit اکنون می تواند ردیابی OpenTelemetry را برای موارد زیر پخش کند:
دامنه های منتشر شده شامل ویژگی هایی هستند که درخواست فعلی را توصیف می کنند، مانند http.routeو بافت اطراف، مانند +page یا +layout فایل مربوط به الف load تابع اگر ویژگیهای دیگری وجود دارد که فکر میکنید ممکن است مفید باشد، لطفاً مشکلی را در ردیاب مشکل SvelteKit GitHub ثبت کنید.
خانه ای مناسب برای همه ابزار شما
فقط انتشار آثار کافی نیست: شما همچنین باید آنها را جمع آوری کرده و به جایی بفرستید. در شرایط عادی، این می تواند کمی چالش برانگیز باشد. با توجه به ماهیت ابزارهای نظارت، آنها باید قبل از بارگیری هر کدی از برنامه شما بارگذاری شوند. برای کمک به این امر، SvelteKit اکنون از a src/instrumentation.server.ts فایلی که با فرض اینکه آداپتور شما از آن پشتیبانی می کند، تضمین شده است که قبل از کد برنامه شما بارگیری می شود.
Register a module that exports hooks that customize Node.js module
resolution and loading behavior. See
Customization hooks.
This feature requires --allow-worker if used with the
Permission Model.
v20.6.0, v18.19.0
specifier
Customization hooks to be registered; this should be
the same string that would be passed to import(), except that if it is
relative, it is resolved relative to parentURL.
parentURL
f you want to resolve specifier relative to a base
URL, such as import.meta.url, you can pass that URL here.
Register a module that exports hooks that customize Node.js module
resolution and loading behavior. See
Customization hooks.
This feature requires --allow-worker if used with the
Permission Model.
v20.6.0, v18.19.0
specifier
Customization hooks to be registered; this should be
the same string that would be passed to import(), except that if it is
relative, it is resolved relative to parentURL.
parentURL
f you want to resolve specifier relative to a base
URL, such as import.meta.url, you can pass that URL here.
('import-in-the-middle/hook.mjs',import.meta
The type of import.meta.
If you need to declare that a given property exists on import.meta,
this type may be augmented via interface merging.
.url(property)ImportMeta.url:string
The absolute file: URL of the module.
This is defined exactly the same as it is in browsers providing the URL of the
current module file.
This enables useful patterns such as relative file loading:
برای دستورالعمل های ابزار خاص، با اسناد پلت فرم خود مشورت کنید. در حال حاضر، تمام آداپتورهای رسمی SvelteKit با یک جزء سرور (با عرض پوزش adapter-static) نگهداری instrumentation.server.ts.
قدردانی
با تشکر فراوان از لوکاس استراکه، که ما را در این ماجراجویی با سخنرانی عالی خود در Svelte Summit 2025 و پروژه اولیه روابط عمومی خود برای instrumentation.server.ts. با تشکر دیگر از Sentry که به او اجازه داد ساعات کاری خود را صرف بررسی و آزمایش کار ما کند.