@sentry/server-utils 11.21.0 → 11.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/THIRD-PARTY-LICENSES.txt +10 -10
- package/build/cjs/chunks/config.js +4 -2
- package/build/cjs/chunks/config.js.map +1 -1
- package/build/cjs/chunks/core.js +0 -1
- package/build/cjs/chunks/exports.js +76 -28
- package/build/cjs/chunks/exports.js.map +1 -1
- package/build/cjs/chunks/module-details-from-path.js +427 -428
- package/build/cjs/chunks/module-details-from-path.js.map +1 -1
- package/build/cjs/chunks/moduleInjectedTransform.js +419 -421
- package/build/cjs/chunks/moduleInjectedTransform.js.map +1 -1
- package/build/cjs/chunks/rolldown-runtime.js +8 -6
- package/build/cjs/index.js +95 -41
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/index.request-handler.js +2 -2
- package/build/cjs/orchestrion/bundler/bun.js +1 -1
- package/build/cjs/orchestrion/bundler/esbuild.js +1 -1
- package/build/cjs/orchestrion/bundler/rollup.js +1 -1
- package/build/cjs/orchestrion/bundler/vite.js +2 -2
- package/build/cjs/orchestrion/bundler/webpack-loader.js +2 -2
- package/build/cjs/orchestrion/bundler/webpack.js +4 -4
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/defineProperty.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/assertClassBrand.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/checkPrivateRedeclaration.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateFieldGet2.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateFieldInitSpec.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateFieldSet2.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/classPrivateMethodInitSpec.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/defineProperty.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/toPrimitive.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/toPropertyKey.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/typeof.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/toPrimitive.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/toPropertyKey.js +1 -1
- package/build/esm/_virtual/{_@oxc-project_runtime@0.158.0 → _@oxc-project_runtime@0.160.0}/helpers/typeof.js +1 -1
- package/build/esm/_virtual/_rolldown/runtime.js +8 -6
- package/build/esm/ai/anthropic-ai/index.js +2 -2
- package/build/esm/ai/anthropic-ai/streaming.js +11 -2
- package/build/esm/ai/anthropic-ai/streaming.js.map +1 -1
- package/build/esm/ai/anthropic-ai/tool-runner.js +3 -3
- package/build/esm/ai/anthropic-ai/utils.js +2 -2
- package/build/esm/ai/core/span-hooks.js +1 -1
- package/build/esm/ai/core/time-to-first-chunk.js +1 -1
- package/build/esm/ai/core/utils.js +2 -2
- package/build/esm/ai/flue/index.js +2 -2
- package/build/esm/ai/flue/utils.js +2 -2
- package/build/esm/ai/google-genai/decisions.js +1 -1
- package/build/esm/ai/google-genai/index.js +2 -2
- package/build/esm/ai/google-genai/streaming.js +9 -2
- package/build/esm/ai/google-genai/streaming.js.map +1 -1
- package/build/esm/ai/google-genai/utils.js +1 -1
- package/build/esm/ai/langchain/embeddings.js +3 -3
- package/build/esm/ai/langchain/index.js +15 -9
- package/build/esm/ai/langchain/index.js.map +1 -1
- package/build/esm/ai/langchain/typesafe-classifier.js +2 -2
- package/build/esm/ai/langchain/utils.js +3 -4
- package/build/esm/ai/langchain/utils.js.map +1 -1
- package/build/esm/ai/langgraph/agent-span.js +3 -3
- package/build/esm/ai/langgraph/index.js +1 -1
- package/build/esm/ai/langgraph/stream.js +2 -2
- package/build/esm/ai/langgraph/utils.js +3 -3
- package/build/esm/ai/mastra/index.js +2 -2
- package/build/esm/ai/mastra/span-registry.js +1 -1
- package/build/esm/ai/mastra/utils.js +2 -2
- package/build/esm/ai/mistral/index.js +2 -2
- package/build/esm/ai/mistral/streaming.js +18 -9
- package/build/esm/ai/mistral/streaming.js.map +1 -1
- package/build/esm/ai/openai/index.js +2 -2
- package/build/esm/ai/openai/mapping.js +1 -1
- package/build/esm/ai/openai/streaming.js +15 -2
- package/build/esm/ai/openai/streaming.js.map +1 -1
- package/build/esm/ai/openai/utils.js +2 -2
- package/build/esm/ai/pi-ai/chat.js +12 -4
- package/build/esm/ai/pi-ai/chat.js.map +1 -1
- package/build/esm/ai/pi-ai/providers.js +1 -1
- package/build/esm/ai/pi-ai/recording.js +1 -1
- package/build/esm/ai/pi-durable/index.js +2 -2
- package/build/esm/ai/pi-durable/runs.js +3 -3
- package/build/esm/ai/pi-durable/tools.js +3 -3
- package/build/esm/ai/tanstack-ai/index.js +2 -2
- package/build/esm/ai/tanstack-ai/utils.js +2 -2
- package/build/esm/ai/typesafe/index.js +3 -3
- package/build/esm/ai/workers-ai/index.js +2 -2
- package/build/esm/ai/workers-ai/streaming.js +7 -5
- package/build/esm/ai/workers-ai/streaming.js.map +1 -1
- package/build/esm/ai/workers-ai/utils.js +7 -4
- package/build/esm/ai/workers-ai/utils.js.map +1 -1
- package/build/esm/async-context.js +1 -1
- package/build/esm/cron/common.js +1 -1
- package/build/esm/cron/cron.js +1 -1
- package/build/esm/cron/node-cron.js +1 -1
- package/build/esm/cron/node-schedule.js +1 -1
- package/build/esm/eve.js +1 -1
- package/build/esm/integrations/amqplib.js +3 -3
- package/build/esm/integrations/anthropic.js +3 -4
- package/build/esm/integrations/anthropic.js.map +1 -1
- package/build/esm/integrations/aws-sdk/index.js +3 -3
- package/build/esm/integrations/aws-sdk/services/MessageAttributes.js +1 -1
- package/build/esm/integrations/aws-sdk/services/bedrock-runtime-content.js +2 -2
- package/build/esm/integrations/aws-sdk/services/bedrock-runtime.js +3 -3
- package/build/esm/integrations/aws-sdk/services/dynamodb.js +1 -1
- package/build/esm/integrations/aws-sdk/services/lambda.js +2 -2
- package/build/esm/integrations/aws-sdk/services/sns.js +3 -3
- package/build/esm/integrations/aws-sdk/services/sqs.js +2 -2
- package/build/esm/integrations/bullmq/meter.js +2 -2
- package/build/esm/integrations/bullmq/tracer.js +2 -2
- package/build/esm/integrations/clickhouse.js +3 -3
- package/build/esm/integrations/cron.js +1 -1
- package/build/esm/integrations/dataloader.js +3 -3
- package/build/esm/integrations/express/error-handler.js +1 -1
- package/build/esm/integrations/express/index.js +1 -1
- package/build/esm/integrations/express/instrumentation.js +3 -3
- package/build/esm/integrations/fastify/errors.js +1 -1
- package/build/esm/integrations/fastify/index.js +1 -1
- package/build/esm/integrations/fastify/instrumentation.js +8 -4
- package/build/esm/integrations/fastify/instrumentation.js.map +1 -1
- package/build/esm/integrations/firebase/firestore.js +2 -2
- package/build/esm/integrations/firebase/functions.js +1 -1
- package/build/esm/integrations/firebase/index.js +1 -1
- package/build/esm/integrations/flue.js +1 -1
- package/build/esm/integrations/generic-pool.js +3 -3
- package/build/esm/integrations/google-genai.js +2 -2
- package/build/esm/integrations/graphql/graphql-dc-subscriber.js +3 -3
- package/build/esm/integrations/graphql/index.js +1 -1
- package/build/esm/integrations/graphql/resolvers.js +2 -2
- package/build/esm/integrations/graphql/spans.js +3 -3
- package/build/esm/integrations/groq.js +1 -1
- package/build/esm/integrations/hapi/hapi-error-handler.js +1 -1
- package/build/esm/integrations/hapi/hapi-utils.js +4 -5
- package/build/esm/integrations/hapi/hapi-utils.js.map +1 -1
- package/build/esm/integrations/hapi/index.js +1 -1
- package/build/esm/integrations/hono/applyPatches.js +1 -1
- package/build/esm/integrations/hono/createHonoMiddleware.js +1 -1
- package/build/esm/integrations/hono/honoIntegration.js +3 -3
- package/build/esm/integrations/hono/matchResult.js +1 -1
- package/build/esm/integrations/hono/middlewareHandlers.js +2 -2
- package/build/esm/integrations/hono/patchAppRequest.js +3 -3
- package/build/esm/integrations/hono/patchAppUse.js +1 -1
- package/build/esm/integrations/hono/patchRoute.js +1 -1
- package/build/esm/integrations/hono/wrapMiddlewareSpan.js +3 -3
- package/build/esm/integrations/kafkajs/consumer.js +2 -2
- package/build/esm/integrations/kafkajs/index.js +1 -1
- package/build/esm/integrations/kafkajs/spans.js +2 -2
- package/build/esm/integrations/knex.js +3 -3
- package/build/esm/integrations/koa/index.js +3 -3
- package/build/esm/integrations/langchain.js +1 -1
- package/build/esm/integrations/langgraph.js +1 -1
- package/build/esm/integrations/lru-memoizer.js +1 -1
- package/build/esm/integrations/mastra-classifier.js +2 -2
- package/build/esm/integrations/mastra.js +4 -4
- package/build/esm/integrations/mcp-server.js +2 -2
- package/build/esm/integrations/mistral.js +2 -2
- package/build/esm/integrations/mongodb/index.js +1 -1
- package/build/esm/integrations/mongodb/mongodb-span.js +1 -1
- package/build/esm/integrations/mongoose/index.js +1 -1
- package/build/esm/integrations/mongoose/mongoose-dc-subscriber.js +3 -3
- package/build/esm/integrations/mongoose/mongoose-legacy-span.js +1 -1
- package/build/esm/integrations/mysql.js +3 -3
- package/build/esm/integrations/mysql2/index.js +1 -1
- package/build/esm/integrations/mysql2/mysql2-dc-subscriber.js +3 -3
- package/build/esm/integrations/neon.js +13 -5
- package/build/esm/integrations/neon.js.map +1 -1
- package/build/esm/integrations/nitro/captureStorageEvents.js +3 -3
- package/build/esm/integrations/nitro/captureTracingEvents.js +3 -3
- package/build/esm/integrations/nitro/index.js +1 -1
- package/build/esm/integrations/nitro/setServerTimingHeaders.js +1 -1
- package/build/esm/integrations/node-cron.js +1 -1
- package/build/esm/integrations/node-schedule.js +1 -1
- package/build/esm/integrations/openai-compatible.js +2 -2
- package/build/esm/integrations/openai.js +2 -2
- package/build/esm/integrations/pg.js +43 -16
- package/build/esm/integrations/pg.js.map +1 -1
- package/build/esm/integrations/pi-ai.js +1 -1
- package/build/esm/integrations/pi-durable.js +1 -1
- package/build/esm/integrations/pino.js +1 -1
- package/build/esm/integrations/pino.js.map +1 -1
- package/build/esm/integrations/postgresjs/index.js +3 -3
- package/build/esm/integrations/postgresjs/postgresjs-dc-subscriber.js +3 -3
- package/build/esm/integrations/postgresjs-wrapper.js +1 -1
- package/build/esm/integrations/prisma/index.js +1 -1
- package/build/esm/integrations/prisma/orchestrion.js +8 -12
- package/build/esm/integrations/prisma/orchestrion.js.map +1 -1
- package/build/esm/integrations/prisma/tracing-helper.js +2 -2
- package/build/esm/integrations/redis/index.js +3 -3
- package/build/esm/integrations/redis/ioredis-channel-subscriber.js +3 -3
- package/build/esm/integrations/redis/redis-cache.js +1 -1
- package/build/esm/integrations/redis/redis-dc-subscriber.js +3 -3
- package/build/esm/integrations/serveTunnel.js +2 -2
- package/build/esm/integrations/tanstack-ai.js +1 -1
- package/build/esm/integrations/tedious.js +4 -4
- package/build/esm/integrations/together-ai.js +1 -1
- package/build/esm/integrations/typesafe.js +1 -1
- package/build/esm/integrations/vercel-ai/extract.js +2 -3
- package/build/esm/integrations/vercel-ai/extract.js.map +1 -1
- package/build/esm/integrations/vercel-ai/index.js +1 -1
- package/build/esm/integrations/vercel-ai/util.js +21 -2
- package/build/esm/integrations/vercel-ai/util.js.map +1 -1
- package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js +3 -3
- package/build/esm/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.js +1 -1
- package/build/esm/integrations/vercel-ai/vercel-ai-tool-telemetry.js +3 -3
- package/build/esm/integrations/winston.js +1 -1
- package/build/esm/opentelemetry.js +1 -1
- package/build/esm/orchestrion/bundler/esbuild.js +1 -1
- package/build/esm/orchestrion/bundler/externalRequire.js +1 -1
- package/build/esm/orchestrion/bundler/rollup.js +1 -1
- package/build/esm/orchestrion/bundler/webpack-loader.js +1 -1
- package/build/esm/orchestrion/bundler/webpack.js +1 -1
- package/build/esm/orchestrion/config/index.js +1 -1
- package/build/esm/orchestrion/config/mistral.js +1 -1
- package/build/esm/orchestrion/config/mistral.js.map +1 -1
- package/build/esm/orchestrion/config/prisma.js +2 -0
- package/build/esm/orchestrion/config/prisma.js.map +1 -1
- package/build/esm/orchestrion/detect.js +1 -1
- package/build/esm/orchestrion/instrumentation.js +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/tracing-channel.js +1 -2
- package/build/esm/tracing-channel.js.map +1 -1
- package/build/esm/utils/cronMonitoring.js +1 -1
- package/build/esm/utils/diagnosticsChannel.js +1 -1
- package/build/esm/utils/module.js +2 -2
- package/build/esm/utils/module.js.map +1 -1
- package/build/esm/utils/monitorStream.js +1 -1
- package/build/esm/utils/serverTimingTraceHeader.js +1 -1
- package/build/esm/utils/tunnelServer.js +1 -1
- package/build/esm/utils/wrapServerRequestHandler.js +4 -4
- package/build/esm/vendored/@apm-js-collab/code-transformer/lib/matcher.js +3 -3
- package/build/esm/vendored/@apm-js-collab/code-transformer/lib/transformer.js +5 -5
- package/build/esm/vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/core-BiWIBBjf.js +1 -1
- package/build/esm/vendored/@apm-js-collab/code-transformer-bundler-plugins/dist/esm/webpack-loader-factory.js +1 -1
- package/build/esm/vendored/esquery/dist/esquery.min.js +1 -0
- package/build/esm/vendored/esquery/dist/esquery.min.js.map +1 -1
- package/build/esm/vendored/meriyah/dist/meriyah.js +416 -418
- package/build/esm/vendored/meriyah/dist/meriyah.js.map +1 -1
- package/build/esm/vendored/meriyah/dist/meriyah2.js +416 -418
- package/build/esm/vendored/meriyah/dist/meriyah2.js.map +1 -1
- package/build/esm/vendored/source-map/lib/base64-vlq.js +1 -1
- package/build/esm/vendored/source-map/lib/base64-vlq.js.map +1 -1
- package/build/types/ai/anthropic-ai/streaming.d.ts.map +1 -1
- package/build/types/ai/anthropic-ai/types.d.ts +1 -0
- package/build/types/ai/anthropic-ai/types.d.ts.map +1 -1
- package/build/types/ai/google-genai/streaming.d.ts.map +1 -1
- package/build/types/ai/langchain/index.d.ts.map +1 -1
- package/build/types/ai/mistral/streaming.d.ts.map +1 -1
- package/build/types/ai/openai/streaming.d.ts.map +1 -1
- package/build/types/ai/pi-ai/chat.d.ts.map +1 -1
- package/build/types/ai/workers-ai/streaming.d.ts.map +1 -1
- package/build/types/ai/workers-ai/utils.d.ts.map +1 -1
- package/build/types/integrations/fastify/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/neon.d.ts.map +1 -1
- package/build/types/integrations/pg.d.ts +6 -1
- package/build/types/integrations/pg.d.ts.map +1 -1
- package/build/types/integrations/pino.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/extract.d.ts +2 -5
- package/build/types/integrations/vercel-ai/extract.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/util.d.ts.map +1 -1
- package/build/types/orchestrion/channels.d.ts +1 -0
- package/build/types/orchestrion/channels.d.ts.map +1 -1
- package/build/types/orchestrion/config/mistral.d.ts +3 -3
- package/build/types/orchestrion/config/prisma.d.ts +2 -1
- package/build/types/orchestrion/config/prisma.d.ts.map +1 -1
- package/build/types/tracing-channel.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","names":["diagnosticsChannel.subscribe"],"sources":["../../../../src/integrations/fastify/instrumentation.ts"],"sourcesContent":["/*\n * Copyright (c) 2024-present The Fastify team <https://github.com/fastify/fastify#team>\n * SPDX-License-Identifier: MIT\n *\n * NOTICE from the Sentry authors:\n * - Based on: https://github.com/fastify/otel/tree/bae80d6caef4287e7f01ff3c8dc753243706ea86 (@fastify/otel@0.18.1)\n * - Streamlined to the Sentry SDK's needs: dropped the `InstrumentationBase` wrapper, the unused\n * request/lifecycle hooks, `ignorePaths`/`minimatch` support and the OpenTelemetry tracer/context\n * APIs in favor of the Sentry span API.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-this-alias */\n/* eslint-disable max-lines */\n\nimport * as diagnosticsChannel from '../../utils/diagnosticsChannel';\nimport {\n HTTP_REQUEST_METHOD,\n HTTP_RESPONSE_STATUS_CODE,\n HTTP_ROUTE,\n SENTRY_OP,\n URL_PATH,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { HANDLER, MIDDLEWARE } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n isObjectLike,\n getActiveSpan,\n getClient,\n getIsolationScope,\n hasSpanStreamingEnabled,\n REQUEST_HANDLER_SPAN_NAME_FALLBACK,\n SPAN_STATUS_ERROR,\n spanIsSampled,\n startInactiveSpan,\n startSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport type { FastifyInstance } from './types';\nimport { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute';\nimport { handleFastifyError } from './errors';\n\nconst ORIGIN = 'auto.http.fastify';\n\nconst FASTIFY_HOOKS = [\n 'onRequest',\n 'preParsing',\n 'preValidation',\n 'preHandler',\n 'preSerialization',\n 'onSend',\n 'onResponse',\n 'onError',\n];\nconst ATTRIBUTE_HOOK_NAME = 'hook.name' as const;\nconst ATTRIBUTE_FASTIFY_TYPE = 'fastify.type' as const;\nconst ATTRIBUTE_HOOK_CALLBACK_NAME = 'hook.callback.name' as const;\n\nconst HOOK_TYPE_ROUTE = 'route-hook' as const;\nconst HOOK_TYPE_INSTANCE = 'hook' as const;\nconst HOOK_TYPE_HANDLER = 'request-handler' as const;\nconst ANONYMOUS_FUNCTION_NAME = 'anonymous';\n\nconst kRequestSpan = Symbol('sentry fastify request span');\nconst kAddHookOriginal = Symbol('sentry fastify addHook original');\nconst kSetNotFoundOriginal = Symbol('sentry fastify setNotFoundHandler original');\n\ntype AnyFn = (...args: any[]) => any;\n\n/**\n * Read the matched route URL off a request. Fastify >=4 exposes it on `request.routeOptions.url`,\n * while v3 only has the (since-removed-in-v5) `request.routerPath`.\n */\nfunction getRequestRouteUrl(request: any): string | undefined {\n return request.routeOptions?.url ?? request.routerPath;\n}\n\n/**\n * Detect whether one of a wrapped handler's arguments is the Fastify request. We can't rely on a\n * single property since the route metadata moved from `routerPath` (v3) to `routeOptions` (>=4),\n * so we accept either shape.\n */\nfunction isFastifyRequest(arg: any): boolean {\n return isObjectLike(arg) && !!arg.method && !!arg.url && (!!arg.routeOptions || 'routerPath' in arg);\n}\n\n/**\n * Wire up the request/hook/handler spans and error handling on a Fastify instance.\n *\n * This runs synchronously from the `fastify.initialization` diagnostics channel, which fires while\n * `Fastify()` is still constructing the instance, before any user code runs. Doing it synchronously\n * (rather than via `instance.register()`, which defers the work until the boot phase) is what lets us\n * patch `addHook`/`setNotFoundHandler` in time: `addHook` runs immediately, so hooks a user adds\n * synchronously before `listen()`/`ready()` would otherwise slip through un-instrumented.\n */\nfunction instrumentFastifyInstance(instance: FastifyInstance): void {\n // oxlint-disable-next-line typescript/unbound-method\n instance.decorate(kAddHookOriginal, instance.addHook);\n instance.decorate(kSetNotFoundOriginal, instance.setNotFoundHandler);\n instance.decorateRequest('opentelemetry', function opentelemetry(this: any) {\n return { span: this[kRequestSpan] as Span | null };\n });\n instance.decorateRequest(kRequestSpan, null);\n\n instance.addHook('onRoute', onRoute);\n instance.addHook('onRequest', onRequest);\n instance.addHook('onResponse', onResponse);\n // Must be an async hook: a sync (callback-style) `onError` hook would have to invoke Fastify's\n // `done` callback\n instance.addHook('onError', async (request, reply, error) => {\n handleFastifyError(request, reply, error);\n });\n\n // Patch last, so the hooks we add above go through the original (un-wrapped) `addHook`.\n instance.addHook = addHookPatched;\n instance.setNotFoundHandler = setNotFoundHandlerPatched;\n}\n\nfunction onRoute(this: any, routeOptions: any): void {\n for (const hook of FASTIFY_HOOKS) {\n const handlerLike = routeOptions[hook];\n\n if (typeof handlerLike === 'function') {\n routeOptions[hook] = handlerWrapper(\n handlerLike,\n hook,\n routeHookAttributes(this.pluginName, hook, handlerLike, routeOptions.url),\n );\n } else if (Array.isArray(handlerLike)) {\n routeOptions[hook] = handlerLike.map((handler: AnyFn) =>\n handlerWrapper(handler, hook, routeHookAttributes(this.pluginName, hook, handler, routeOptions.url)),\n );\n }\n }\n\n routeOptions.onSend = appendRouteHook(routeOptions.onSend, finalizeResponseSpanHook);\n routeOptions.onError = appendRouteHook(routeOptions.onError, recordErrorInSpanHook);\n\n routeOptions.handler = handlerWrapper(routeOptions.handler, 'handler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - route-handler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_HANDLER,\n [HTTP_ROUTE]: routeOptions.url,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]:\n routeOptions.handler.name.length > 0 ? routeOptions.handler.name : ANONYMOUS_FUNCTION_NAME,\n });\n}\n\nfunction routeHookAttributes(pluginName: string, hook: string, handler: AnyFn, url: string): Record<string, string> {\n return {\n [ATTRIBUTE_HOOK_NAME]: `${pluginName} - route -> ${hook}`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_ROUTE,\n [HTTP_ROUTE]: url,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: handler.name?.length > 0 ? handler.name : ANONYMOUS_FUNCTION_NAME,\n };\n}\n\nfunction appendRouteHook(existing: AnyFn | AnyFn[] | undefined, hook: AnyFn): AnyFn | AnyFn[] {\n if (existing == null) {\n return hook;\n }\n return Array.isArray(existing) ? [...existing, hook] : [existing, hook];\n}\n\nfunction onRequest(this: any, request: any, _reply: any, hookDone: () => void): void {\n const routeName = getRequestRouteUrl(request);\n const method = request.method || 'GET';\n\n getIsolationScope().setTransactionName(`${method} ${routeName}`);\n\n const attributes: Record<string, string> = {\n [SENTRY_ORIGIN]: ORIGIN,\n [SENTRY_OP]: HANDLER,\n [HTTP_REQUEST_METHOD]: request.method,\n [URL_PATH]: request.url,\n };\n\n const route = getRequestRouteUrl(request);\n if (route != null) {\n attributes[HTTP_ROUTE] = route;\n\n setHttpServerSpanRouteAttribute(route);\n }\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so request handler\n // spans are named after their route alone, without the method prefix.\n const isStreamedSpan = !!client && hasSpanStreamingEnabled(client);\n\n const requestSpan = startInactiveSpan({\n name: isStreamedSpan\n ? route || REQUEST_HANDLER_SPAN_NAME_FALLBACK\n : route != null\n ? `${request.method} ${route}`\n : 'request',\n attributes,\n });\n request[kRequestSpan] = requestSpan;\n\n // Set the request span as the active span for the remainder of the request lifecycle, so that\n // downstream hooks/handlers as well as errors captured via the error diagnostics channel are\n // parented to it (otherwise they would attach to the root `http.server` span instead).\n withActiveSpan(requestSpan, () => {\n hookDone();\n });\n}\n\nfunction onResponse(request: any, reply: any, hookDone: () => void): void {\n const span = request[kRequestSpan] as Span | null;\n\n if (span != null) {\n span.setAttributes({ [HTTP_RESPONSE_STATUS_CODE]: reply.statusCode });\n span.end();\n }\n\n request[kRequestSpan] = null;\n\n hookDone();\n}\n\nfunction finalizeResponseSpanHook(\n request: any,\n reply: any,\n payload: any,\n hookDone: (err: null, payload: any) => void,\n): void {\n const span = request[kRequestSpan] as Span | null;\n\n if (span != null) {\n if (reply.statusCode >= 500) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n span.setAttributes({ [HTTP_RESPONSE_STATUS_CODE]: reply.statusCode });\n span.end();\n }\n\n request[kRequestSpan] = null;\n\n hookDone(null, payload);\n}\n\nfunction recordErrorInSpanHook(request: any, _reply: any, error: any, hookDone: () => void): void {\n const span = request[kRequestSpan] as Span | null;\n\n if (span != null) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n\n hookDone();\n}\n\nfunction addHookPatched(this: any, name: string, hook: AnyFn): FastifyInstance {\n const addHookOriginal = this[kAddHookOriginal];\n\n if (FASTIFY_HOOKS.includes(name)) {\n return addHookOriginal.call(\n this,\n name,\n handlerWrapper(hook, name, {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - ${name}`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: hook.name?.length > 0 ? hook.name : ANONYMOUS_FUNCTION_NAME,\n }),\n );\n }\n\n return addHookOriginal.call(this, name, hook);\n}\n\nfunction setNotFoundHandlerPatched(this: any, hooks: any, handler?: any): void {\n const setNotFoundHandlerOriginal = this[kSetNotFoundOriginal];\n\n if (typeof hooks === 'function') {\n setNotFoundHandlerOriginal.call(\n this,\n handlerWrapper(hooks, 'notFoundHandler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: hooks.name?.length > 0 ? hooks.name : ANONYMOUS_FUNCTION_NAME,\n }),\n );\n return;\n }\n\n if (hooks.preValidation != null) {\n hooks.preValidation = handlerWrapper(hooks.preValidation, 'notFoundHandler - preValidation', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler - preValidation`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]:\n hooks.preValidation.name?.length > 0 ? hooks.preValidation.name : ANONYMOUS_FUNCTION_NAME,\n });\n }\n\n if (hooks.preHandler != null) {\n hooks.preHandler = handlerWrapper(hooks.preHandler, 'notFoundHandler - preHandler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler - preHandler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]:\n hooks.preHandler.name?.length > 0 ? hooks.preHandler.name : ANONYMOUS_FUNCTION_NAME,\n });\n }\n\n // Fastify allows `setNotFoundHandler(opts)` without a handler, falling back to its built-in 404\n // handler. Forward the (already-wrapped) hooks unchanged so that fallback still applies.\n if (handler == null) {\n setNotFoundHandlerOriginal.call(this, hooks);\n return;\n }\n\n setNotFoundHandlerOriginal.call(\n this,\n hooks,\n handlerWrapper(handler, 'notFoundHandler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: handler.name?.length > 0 ? handler.name : ANONYMOUS_FUNCTION_NAME,\n }),\n );\n}\n\nfunction getRequestFromArgs(args: any[]): any | null {\n for (const arg of args) {\n if (isFastifyRequest(arg)) {\n return arg;\n }\n }\n return null;\n}\n\nfunction handlerWrapper(handler: AnyFn, hookName: string, spanAttributes: Record<string, string> = {}): AnyFn {\n return function handlerWrapped(this: any, ...args: any[]) {\n const request = getRequestFromArgs(args);\n\n if (!request) {\n return handler.call(this, ...args);\n }\n\n const parentSpan = (request[kRequestSpan] as Span | null) ?? undefined;\n\n // A child of an unsampled span is never sampled either, so skip creating it. Hooks that run after\n // the request span ended (e.g. `onResponse`) fall back to the active span, like `startSpan` would.\n const effectiveParentSpan = parentSpan ?? getActiveSpan();\n if (effectiveParentSpan && !spanIsSampled(effectiveParentSpan)) {\n return handler.call(this, ...args);\n }\n\n const handlerName = handler.name?.length > 0 ? handler.name : (this.pluginName ?? ANONYMOUS_FUNCTION_NAME);\n\n const hookType = spanAttributes[ATTRIBUTE_FASTIFY_TYPE];\n const op = hookType === HOOK_TYPE_INSTANCE ? MIDDLEWARE : hookType === HOOK_TYPE_HANDLER ? HANDLER : undefined;\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so request handler\n // spans are named after their route.\n const isStreamedRequestHandlerSpan = hookType === HOOK_TYPE_HANDLER && !!client && hasSpanStreamingEnabled(client);\n\n const attributeHookName = spanAttributes[ATTRIBUTE_HOOK_NAME];\n\n const name = isStreamedRequestHandlerSpan\n ? spanAttributes[HTTP_ROUTE] || REQUEST_HANDLER_SPAN_NAME_FALLBACK\n : op && typeof attributeHookName === 'string'\n ? attributeHookName\n : `${hookName} - ${handlerName}`;\n\n return startSpan(\n {\n name,\n attributes: {\n ...spanAttributes,\n [SENTRY_OP]: op,\n [SENTRY_ORIGIN]: ORIGIN,\n },\n parentSpan,\n },\n () => handler.call(this, ...args),\n );\n };\n}\n\nlet _isInstrumented = false;\n\n/**\n * Set up the Fastify (>= 3.21.0 < 7) instrumentation by subscribing to the `fastify.initialization`\n * diagnostics channel and synchronously instrumenting every Fastify instance as it is created.\n */\nexport function instrumentFastify(): void {\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n diagnosticsChannel.subscribe('fastify.initialization', message => {\n const fastifyInstance = (message as { fastify?: FastifyInstance }).fastify;\n\n if (fastifyInstance) {\n instrumentFastifyInstance(fastifyInstance);\n }\n });\n}\n"],"mappings":";;;;;;;AA4CA,MAAM,SAAS;AAEf,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,+BAA+B;AAErC,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,MAAM,0BAA0B;AAEhC,MAAM,eAAe,OAAO,6BAA6B;AACzD,MAAM,mBAAmB,OAAO,iCAAiC;AACjE,MAAM,uBAAuB,OAAO,4CAA4C;;;;;AAQhF,SAAS,mBAAmB,SAAkC;CAC5D,OAAO,QAAQ,cAAc,OAAO,QAAQ;AAC9C;;;;;;AAOA,SAAS,iBAAiB,KAA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KACF,YAAY;KACZ,gBAAgB;GACnB;GACA;EACF,SACM,QAAQ,KAAK,MAAM,GAAG,IAAI,CAClC;CACF;AACF;AAEA,IAAI,kBAAkB;;;;;AAMtB,SAAgB,oBAA0B;CACxC,IAAI,iBACF;CAEF,kBAAkB;CAElBA,UAA6B,2BAA0B,YAAW;EAChE,MAAM,kBAAmB,QAA0C;EAEnE,IAAI,iBACF,0BAA0B,eAAe;CAE7C,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","names":["diagnosticsChannel.subscribe"],"sources":["../../../../src/integrations/fastify/instrumentation.ts"],"sourcesContent":["/*\n * Copyright (c) 2024-present The Fastify team <https://github.com/fastify/fastify#team>\n * SPDX-License-Identifier: MIT\n *\n * NOTICE from the Sentry authors:\n * - Based on: https://github.com/fastify/otel/tree/bae80d6caef4287e7f01ff3c8dc753243706ea86 (@fastify/otel@0.18.1)\n * - Streamlined to the Sentry SDK's needs: dropped the `InstrumentationBase` wrapper, the unused\n * request/lifecycle hooks, `ignorePaths`/`minimatch` support and the OpenTelemetry tracer/context\n * APIs in favor of the Sentry span API.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-this-alias */\n/* eslint-disable max-lines */\n\nimport * as diagnosticsChannel from '../../utils/diagnosticsChannel';\nimport {\n HTTP_REQUEST_METHOD,\n HTTP_RESPONSE_STATUS_CODE,\n HTTP_ROUTE,\n SENTRY_OP,\n URL_PATH,\n SENTRY_ORIGIN,\n} from '@sentry/conventions/attributes';\nimport { HANDLER, MIDDLEWARE } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n isObjectLike,\n getActiveSpan,\n getClient,\n getIsolationScope,\n hasSpanStreamingEnabled,\n REQUEST_HANDLER_SPAN_NAME_FALLBACK,\n SPAN_STATUS_ERROR,\n spanIsSampled,\n startInactiveSpan,\n startSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport type { FastifyInstance } from './types';\nimport { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute';\nimport { handleFastifyError } from './errors';\n\nconst ORIGIN = 'auto.http.fastify';\n\nconst FASTIFY_HOOKS = [\n 'onRequest',\n 'preParsing',\n 'preValidation',\n 'preHandler',\n 'preSerialization',\n 'onSend',\n 'onResponse',\n 'onError',\n];\nconst ATTRIBUTE_HOOK_NAME = 'hook.name' as const;\nconst ATTRIBUTE_FASTIFY_TYPE = 'fastify.type' as const;\nconst ATTRIBUTE_HOOK_CALLBACK_NAME = 'hook.callback.name' as const;\n\nconst HOOK_TYPE_ROUTE = 'route-hook' as const;\nconst HOOK_TYPE_INSTANCE = 'hook' as const;\nconst HOOK_TYPE_HANDLER = 'request-handler' as const;\nconst ANONYMOUS_FUNCTION_NAME = 'anonymous';\n\nconst kRequestSpan = Symbol('sentry fastify request span');\nconst kAddHookOriginal = Symbol('sentry fastify addHook original');\nconst kSetNotFoundOriginal = Symbol('sentry fastify setNotFoundHandler original');\n\ntype AnyFn = (...args: any[]) => any;\n\n/**\n * Read the matched route URL off a request. Fastify >=4 exposes it on `request.routeOptions.url`,\n * while v3 only has the (since-removed-in-v5) `request.routerPath`.\n */\nfunction getRequestRouteUrl(request: any): string | undefined {\n return request.routeOptions?.url ?? request.routerPath;\n}\n\n/**\n * Detect whether one of a wrapped handler's arguments is the Fastify request. We can't rely on a\n * single property since the route metadata moved from `routerPath` (v3) to `routeOptions` (>=4),\n * so we accept either shape.\n */\nfunction isFastifyRequest(arg: any): boolean {\n return isObjectLike(arg) && !!arg.method && !!arg.url && (!!arg.routeOptions || 'routerPath' in arg);\n}\n\n/**\n * Wire up the request/hook/handler spans and error handling on a Fastify instance.\n *\n * This runs synchronously from the `fastify.initialization` diagnostics channel, which fires while\n * `Fastify()` is still constructing the instance, before any user code runs. Doing it synchronously\n * (rather than via `instance.register()`, which defers the work until the boot phase) is what lets us\n * patch `addHook`/`setNotFoundHandler` in time: `addHook` runs immediately, so hooks a user adds\n * synchronously before `listen()`/`ready()` would otherwise slip through un-instrumented.\n */\nfunction instrumentFastifyInstance(instance: FastifyInstance): void {\n // oxlint-disable-next-line typescript/unbound-method\n instance.decorate(kAddHookOriginal, instance.addHook);\n instance.decorate(kSetNotFoundOriginal, instance.setNotFoundHandler);\n instance.decorateRequest('opentelemetry', function opentelemetry(this: any) {\n return { span: this[kRequestSpan] as Span | null };\n });\n instance.decorateRequest(kRequestSpan, null);\n\n instance.addHook('onRoute', onRoute);\n instance.addHook('onRequest', onRequest);\n instance.addHook('onResponse', onResponse);\n // Must be an async hook: a sync (callback-style) `onError` hook would have to invoke Fastify's\n // `done` callback\n instance.addHook('onError', async (request, reply, error) => {\n handleFastifyError(request, reply, error);\n });\n\n // Patch last, so the hooks we add above go through the original (un-wrapped) `addHook`.\n instance.addHook = addHookPatched;\n instance.setNotFoundHandler = setNotFoundHandlerPatched;\n}\n\nfunction onRoute(this: any, routeOptions: any): void {\n for (const hook of FASTIFY_HOOKS) {\n const handlerLike = routeOptions[hook];\n\n if (typeof handlerLike === 'function') {\n routeOptions[hook] = handlerWrapper(\n handlerLike,\n hook,\n routeHookAttributes(this.pluginName, hook, handlerLike, routeOptions.url),\n );\n } else if (Array.isArray(handlerLike)) {\n routeOptions[hook] = handlerLike.map((handler: AnyFn) =>\n handlerWrapper(handler, hook, routeHookAttributes(this.pluginName, hook, handler, routeOptions.url)),\n );\n }\n }\n\n routeOptions.onSend = appendRouteHook(routeOptions.onSend, finalizeResponseSpanHook);\n routeOptions.onError = appendRouteHook(routeOptions.onError, recordErrorInSpanHook);\n\n routeOptions.handler = handlerWrapper(routeOptions.handler, 'handler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - route-handler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_HANDLER,\n [HTTP_ROUTE]: routeOptions.url,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]:\n routeOptions.handler.name.length > 0 ? routeOptions.handler.name : ANONYMOUS_FUNCTION_NAME,\n });\n}\n\nfunction routeHookAttributes(pluginName: string, hook: string, handler: AnyFn, url: string): Record<string, string> {\n return {\n [ATTRIBUTE_HOOK_NAME]: `${pluginName} - route -> ${hook}`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_ROUTE,\n [HTTP_ROUTE]: url,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: handler.name?.length > 0 ? handler.name : ANONYMOUS_FUNCTION_NAME,\n };\n}\n\nfunction appendRouteHook(existing: AnyFn | AnyFn[] | undefined, hook: AnyFn): AnyFn | AnyFn[] {\n if (existing == null) {\n return hook;\n }\n return Array.isArray(existing) ? [...existing, hook] : [existing, hook];\n}\n\nfunction onRequest(this: any, request: any, _reply: any, hookDone: () => void): void {\n const routeName = getRequestRouteUrl(request);\n const method = request.method || 'GET';\n\n getIsolationScope().setTransactionName(`${method} ${routeName}`);\n\n // No active parent span means this request is being ignored (e.g. via `ignoreIncomingRequests`),\n // so don't open a span that would become the root of a new trace.\n if (!getActiveSpan()) {\n hookDone();\n return;\n }\n\n const attributes: Record<string, string> = {\n [SENTRY_ORIGIN]: ORIGIN,\n [SENTRY_OP]: HANDLER,\n [HTTP_REQUEST_METHOD]: request.method,\n [URL_PATH]: request.url,\n };\n\n const route = getRequestRouteUrl(request);\n if (route != null) {\n attributes[HTTP_ROUTE] = route;\n\n setHttpServerSpanRouteAttribute(route);\n }\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so request handler\n // spans are named after their route alone, without the method prefix.\n const isStreamedSpan = !!client && hasSpanStreamingEnabled(client);\n\n const requestSpan = startInactiveSpan({\n name: isStreamedSpan\n ? route || REQUEST_HANDLER_SPAN_NAME_FALLBACK\n : route != null\n ? `${request.method} ${route}`\n : 'request',\n attributes,\n });\n request[kRequestSpan] = requestSpan;\n\n // Set the request span as the active span for the remainder of the request lifecycle, so that\n // downstream hooks/handlers as well as errors captured via the error diagnostics channel are\n // parented to it (otherwise they would attach to the root `http.server` span instead).\n withActiveSpan(requestSpan, () => {\n hookDone();\n });\n}\n\nfunction onResponse(request: any, reply: any, hookDone: () => void): void {\n const span = request[kRequestSpan] as Span | null;\n\n if (span != null) {\n span.setAttributes({ [HTTP_RESPONSE_STATUS_CODE]: reply.statusCode });\n span.end();\n }\n\n request[kRequestSpan] = null;\n\n hookDone();\n}\n\nfunction finalizeResponseSpanHook(\n request: any,\n reply: any,\n payload: any,\n hookDone: (err: null, payload: any) => void,\n): void {\n const span = request[kRequestSpan] as Span | null;\n\n if (span != null) {\n if (reply.statusCode >= 500) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n span.setAttributes({ [HTTP_RESPONSE_STATUS_CODE]: reply.statusCode });\n span.end();\n }\n\n request[kRequestSpan] = null;\n\n hookDone(null, payload);\n}\n\nfunction recordErrorInSpanHook(request: any, _reply: any, error: any, hookDone: () => void): void {\n const span = request[kRequestSpan] as Span | null;\n\n if (span != null) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n\n hookDone();\n}\n\nfunction addHookPatched(this: any, name: string, hook: AnyFn): FastifyInstance {\n const addHookOriginal = this[kAddHookOriginal];\n\n if (FASTIFY_HOOKS.includes(name)) {\n return addHookOriginal.call(\n this,\n name,\n handlerWrapper(hook, name, {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - ${name}`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: hook.name?.length > 0 ? hook.name : ANONYMOUS_FUNCTION_NAME,\n }),\n );\n }\n\n return addHookOriginal.call(this, name, hook);\n}\n\nfunction setNotFoundHandlerPatched(this: any, hooks: any, handler?: any): void {\n const setNotFoundHandlerOriginal = this[kSetNotFoundOriginal];\n\n if (typeof hooks === 'function') {\n setNotFoundHandlerOriginal.call(\n this,\n handlerWrapper(hooks, 'notFoundHandler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: hooks.name?.length > 0 ? hooks.name : ANONYMOUS_FUNCTION_NAME,\n }),\n );\n return;\n }\n\n if (hooks.preValidation != null) {\n hooks.preValidation = handlerWrapper(hooks.preValidation, 'notFoundHandler - preValidation', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler - preValidation`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]:\n hooks.preValidation.name?.length > 0 ? hooks.preValidation.name : ANONYMOUS_FUNCTION_NAME,\n });\n }\n\n if (hooks.preHandler != null) {\n hooks.preHandler = handlerWrapper(hooks.preHandler, 'notFoundHandler - preHandler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler - preHandler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]:\n hooks.preHandler.name?.length > 0 ? hooks.preHandler.name : ANONYMOUS_FUNCTION_NAME,\n });\n }\n\n // Fastify allows `setNotFoundHandler(opts)` without a handler, falling back to its built-in 404\n // handler. Forward the (already-wrapped) hooks unchanged so that fallback still applies.\n if (handler == null) {\n setNotFoundHandlerOriginal.call(this, hooks);\n return;\n }\n\n setNotFoundHandlerOriginal.call(\n this,\n hooks,\n handlerWrapper(handler, 'notFoundHandler', {\n [ATTRIBUTE_HOOK_NAME]: `${this.pluginName} - not-found-handler`,\n [ATTRIBUTE_FASTIFY_TYPE]: HOOK_TYPE_INSTANCE,\n [ATTRIBUTE_HOOK_CALLBACK_NAME]: handler.name?.length > 0 ? handler.name : ANONYMOUS_FUNCTION_NAME,\n }),\n );\n}\n\nfunction getRequestFromArgs(args: any[]): any | null {\n for (const arg of args) {\n if (isFastifyRequest(arg)) {\n return arg;\n }\n }\n return null;\n}\n\nfunction handlerWrapper(handler: AnyFn, hookName: string, spanAttributes: Record<string, string> = {}): AnyFn {\n return function handlerWrapped(this: any, ...args: any[]) {\n const request = getRequestFromArgs(args);\n\n if (!request) {\n return handler.call(this, ...args);\n }\n\n const parentSpan = (request[kRequestSpan] as Span | null) ?? undefined;\n\n // Without a parent span the request is being ignored, and a child of an unsampled span is never\n // sampled either, so skip creating the span in both cases. Hooks that run after the request span\n // ended (e.g. `onResponse`) fall back to the active span, like `startSpan` would.\n const effectiveParentSpan = parentSpan ?? getActiveSpan();\n if (!effectiveParentSpan || !spanIsSampled(effectiveParentSpan)) {\n return handler.call(this, ...args);\n }\n\n const handlerName = handler.name?.length > 0 ? handler.name : (this.pluginName ?? ANONYMOUS_FUNCTION_NAME);\n\n const hookType = spanAttributes[ATTRIBUTE_FASTIFY_TYPE];\n const op = hookType === HOOK_TYPE_INSTANCE ? MIDDLEWARE : hookType === HOOK_TYPE_HANDLER ? HANDLER : undefined;\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so request handler\n // spans are named after their route.\n const isStreamedRequestHandlerSpan = hookType === HOOK_TYPE_HANDLER && !!client && hasSpanStreamingEnabled(client);\n\n const attributeHookName = spanAttributes[ATTRIBUTE_HOOK_NAME];\n\n const name = isStreamedRequestHandlerSpan\n ? spanAttributes[HTTP_ROUTE] || REQUEST_HANDLER_SPAN_NAME_FALLBACK\n : op && typeof attributeHookName === 'string'\n ? attributeHookName\n : `${hookName} - ${handlerName}`;\n\n return startSpan(\n {\n name,\n attributes: {\n ...spanAttributes,\n [SENTRY_OP]: op,\n [SENTRY_ORIGIN]: ORIGIN,\n },\n parentSpan,\n },\n () => handler.call(this, ...args),\n );\n };\n}\n\nlet _isInstrumented = false;\n\n/**\n * Set up the Fastify (>= 3.21.0 < 7) instrumentation by subscribing to the `fastify.initialization`\n * diagnostics channel and synchronously instrumenting every Fastify instance as it is created.\n */\nexport function instrumentFastify(): void {\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n diagnosticsChannel.subscribe('fastify.initialization', message => {\n const fastifyInstance = (message as { fastify?: FastifyInstance }).fastify;\n\n if (fastifyInstance) {\n instrumentFastifyInstance(fastifyInstance);\n }\n });\n}\n"],"mappings":";;;;;;;AA4CA,MAAM,SAAS;AAEf,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,+BAA+B;AAErC,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,MAAM,0BAA0B;AAEhC,MAAM,eAAe,OAAO,6BAA6B;AACzD,MAAM,mBAAmB,OAAO,iCAAiC;AACjE,MAAM,uBAAuB,OAAO,4CAA4C;;;;;AAQhF,SAAS,mBAAmB,SAAkC;CAC5D,OAAO,QAAQ,cAAc,OAAO,QAAQ;AAC9C;;;;;;AAOA,SAAS,iBAAiB,KAAmB;CAC3C,OAAO,aAAa,GAAG,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,IAAI,gBAAgB,gBAAgB;AAClG;;;;;;;;;;AAWA,SAAS,0BAA0B,UAAiC;CAElE,SAAS,SAAS,kBAAkB,SAAS,OAAO;CACpD,SAAS,SAAS,sBAAsB,SAAS,kBAAkB;CACnE,SAAS,gBAAgB,iBAAiB,SAAS,gBAAyB;EAC1E,OAAO,EAAE,MAAM,KAAK,cAA6B;CACnD,CAAC;CACD,SAAS,gBAAgB,cAAc,IAAI;CAE3C,SAAS,QAAQ,WAAW,OAAO;CACnC,SAAS,QAAQ,aAAa,SAAS;CACvC,SAAS,QAAQ,cAAc,UAAU;CAGzC,SAAS,QAAQ,WAAW,OAAO,SAAS,OAAO,UAAU;EAC3D,mBAAmB,SAAS,OAAO,KAAK;CAC1C,CAAC;CAGD,SAAS,UAAU;CACnB,SAAS,qBAAqB;AAChC;AAEA,SAAS,QAAmB,cAAyB;CACnD,KAAK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AEvC,IAAI,CAAC,SACH,OAAO,QAAQ,KAAK,MAAM,GAAG,IAAI;EAGnC,MAAM,aAAc,QAAQ,iBAAiC,KAAA;EAK7D,MAAM,sBAAsB,cAAc,cAAc;EACxD,IAAI,CAAC,uBAAuB,CAAC,cAAc,mBAAmB,GAC5D,OAAO,QAAQ,KAAK,MAAM,GAAG,IAAI;EAGnC,MAAM,cAAc,QAAQ,MAAM,SAAS,IAAI,QAAQ,OAAQ,KAAK,cAAc;EAElF,MAAM,WAAW,eAAe;EAChC,MAAM,KAAK,aAAa,qBAAqB,aAAa,aAAa,oBAAoB,UAAU,KAAA;EAErG,MAAM,SAAS,UAAU;EAGzB,MAAM,+BAA+B,aAAa,qBAAqB,CAAC,CAAC,UAAU,wBAAwB,MAAM;EAEjH,MAAM,oBAAoB,eAAe;EAEzC,MAAM,OAAO,+BACT,eAAe,eAAe,qCAC9B,MAAM,OAAO,sBAAsB,WACjC,oBACA,GAAG,SAAS,KAAK;EAEvB,OAAO,UACL;GACE;GACA,YAAY;IACV,GAAG;KACF,YAAY;KACZ,gBAAgB;GACnB;GACA;EACF,SACM,QAAQ,KAAK,MAAM,GAAG,IAAI,CAClC;CACF;AACF;AAEA,IAAI,kBAAkB;;;;;AAMtB,SAAgB,oBAA0B;CACxC,IAAI,iBACF;CAEF,kBAAkB;CAElBA,UAA6B,2BAA0B,YAAW;EAChE,MAAM,kBAAmB,QAA0C;EAEnE,IAAI,iBACF,0BAA0B,eAAe;CAE7C,CAAC;AACH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as net from "node:net";
|
|
1
2
|
import { DB_COLLECTION_NAME, DB_NAMESPACE, DB_OPERATION_NAME, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
|
|
2
|
-
import { startInactiveSpan } from "@sentry/core";
|
|
3
3
|
import { DB_QUERY } from "@sentry/conventions/op";
|
|
4
|
-
import
|
|
4
|
+
import { startInactiveSpan } from "@sentry/core";
|
|
5
5
|
// src/integrations/firebase/firestore.ts
|
|
6
6
|
/**
|
|
7
7
|
* Opens the inactive `db.query` span for a Firestore operation. `bindTracingChannelToSpan` makes it the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FAAS_NAME, FAAS_TRIGGER, GCP_FUNCTION_CONTEXT_TYPE, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SENTRY_SEGMENT_NAME_SOURCE } from "@sentry/conventions/attributes";
|
|
2
|
-
import { SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK, SPAN_STATUS_ERROR, captureException, flush, getClient, hasSpanStreamingEnabled, startSpanManual } from "@sentry/core";
|
|
3
2
|
import { FUNCTION_GCP } from "@sentry/conventions/op";
|
|
3
|
+
import { SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK, SPAN_STATUS_ERROR, captureException, flush, getClient, hasSpanStreamingEnabled, startSpanManual } from "@sentry/core";
|
|
4
4
|
// src/integrations/firebase/functions.ts
|
|
5
5
|
const FUNCTIONS_ORIGIN = "auto.function.firebase";
|
|
6
6
|
const WRAPPED = "__sentryFirebaseWrapped";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { defineIntegration } from "@sentry/core";
|
|
1
2
|
import { firebaseModuleNames } from "../../orchestrion/config/firebase.js";
|
|
2
3
|
import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
|
|
3
4
|
import { instrumentFirebase } from "./instrumentation.js";
|
|
4
|
-
import { defineIntegration } from "@sentry/core";
|
|
5
5
|
// src/integrations/firebase/index.ts
|
|
6
6
|
const INTEGRATION_NAME = "Firebase";
|
|
7
7
|
const _firebaseIntegration = (() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { GLOBAL_OBJ, debug, defineIntegration } from "@sentry/core";
|
|
1
2
|
import { createFlueInstrumentation } from "../ai/flue/index.js";
|
|
2
3
|
import { FLUE_INTEGRATION_NAME, FLUE_MODULE_NAME } from "../ai/flue/constants.js";
|
|
3
4
|
import { DEBUG_BUILD } from "../debug-build.js";
|
|
4
|
-
import { GLOBAL_OBJ, debug, defineIntegration } from "@sentry/core";
|
|
5
5
|
// src/integrations/flue.ts
|
|
6
6
|
/**
|
|
7
7
|
* The `instrument` we last registered against, so a second `setup()` in the same isolate is a
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
+
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
3
|
+
import { DB } from "@sentry/conventions/op";
|
|
4
|
+
import { defineIntegration, startInactiveSpan } from "@sentry/core";
|
|
2
5
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
3
6
|
import { genericPoolModuleNames } from "../orchestrion/config/generic-pool.js";
|
|
4
7
|
import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
|
|
5
8
|
import { bindTracingChannelToSpan } from "../tracing-channel.js";
|
|
6
|
-
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
7
|
-
import { defineIntegration, startInactiveSpan } from "@sentry/core";
|
|
8
|
-
import { DB } from "@sentry/conventions/op";
|
|
9
9
|
// src/integrations/generic-pool.ts
|
|
10
10
|
const INTEGRATION_NAME = "GenericPool";
|
|
11
11
|
const _genericPoolIntegration = (() => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { GEN_AI_REQUEST_MODEL, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
1
2
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
3
|
+
import { defineIntegration, getActiveSpan, getClient, hasSpanStreamingEnabled, spanToJSON, startInactiveSpan } from "@sentry/core";
|
|
2
4
|
import { getGenAiSpanOp, markCancelledIfAborted, resolveGenAiCallRecording } from "../ai/core/utils.js";
|
|
3
5
|
import { runGenAiSpanEnd, runGenAiSpanStart } from "../ai/core/span-hooks.js";
|
|
4
6
|
import { addPrivateRequestAttributes, addResponseAttributes, extractRequestAttributes, getAbortSignal, getCallAbortSignal, resolveChatParams } from "../ai/google-genai/index.js";
|
|
@@ -8,8 +10,6 @@ import { CHANNELS } from "../orchestrion/channels.js";
|
|
|
8
10
|
import { bindTracingChannelToSpan } from "../tracing-channel.js";
|
|
9
11
|
import { googleGenAiModuleNames } from "../orchestrion/config/google-genai.js";
|
|
10
12
|
import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
|
|
11
|
-
import { GEN_AI_REQUEST_MODEL, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
12
|
-
import { defineIntegration, getActiveSpan, getClient, hasSpanStreamingEnabled, spanToJSON, startInactiveSpan } from "@sentry/core";
|
|
13
13
|
// src/integrations/google-genai.ts
|
|
14
14
|
const INTEGRATION_NAME = "Google_GenAI";
|
|
15
15
|
const ORIGIN = "auto.ai.google_genai";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
2
|
+
import { GRAPHQL } from "@sentry/conventions/op";
|
|
3
|
+
import { SPAN_STATUS_ERROR, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
|
|
1
4
|
import { bindTracingChannelToSpan } from "../../tracing-channel.js";
|
|
2
5
|
import { GRAPHQL_FIELD_NAME, GRAPHQL_FIELD_PATH, GRAPHQL_FIELD_TYPE, GRAPHQL_PARENT_NAME, GRAPHQL_PROCESSING_TYPE, ORIGIN, PROCESSING_TYPE_EXECUTE, PROCESSING_TYPE_PARSE, PROCESSING_TYPE_RESOLVE, PROCESSING_TYPE_VALIDATE, SPAN_NAME_EXECUTE, SPAN_NAME_PARSE, SPAN_NAME_RESOLVE, SPAN_NAME_SUBSCRIBE, SPAN_NAME_VALIDATE } from "./constants.js";
|
|
3
6
|
import { collectGraphqlDocument, getOperationSpanName, hasResultErrors, renameRootSpanWithOperation } from "./utils.js";
|
|
4
|
-
import { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
5
|
-
import { SPAN_STATUS_ERROR, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
|
|
6
|
-
import { GRAPHQL } from "@sentry/conventions/op";
|
|
7
7
|
// src/integrations/graphql/graphql-dc-subscriber.ts
|
|
8
8
|
const GRAPHQL_DC_CHANNEL_PARSE = "graphql:parse";
|
|
9
9
|
const GRAPHQL_DC_CHANNEL_VALIDATE = "graphql:validate";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { tracingChannel } from "../../utils/diagnosticsChannel.js";
|
|
2
|
+
import { defineIntegration, waitForTracingChannelBinding } from "@sentry/core";
|
|
2
3
|
import { subscribeGraphqlDiagnosticChannels } from "./graphql-dc-subscriber.js";
|
|
3
4
|
import { CHANNELS } from "../../orchestrion/channels.js";
|
|
4
5
|
import { graphqlModuleNames } from "../../orchestrion/config/graphql.js";
|
|
5
6
|
import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
|
|
6
7
|
import { bindTracingChannelToSpan, safeChannelCallback } from "../../tracing-channel.js";
|
|
7
8
|
import { finalizeExecuteSpan, finalizeValidateSpan, startExecuteSpan, startParseSpan, startValidateSpan } from "./spans.js";
|
|
8
|
-
import { defineIntegration, waitForTracingChannelBinding } from "@sentry/core";
|
|
9
9
|
// src/integrations/graphql/index.ts
|
|
10
10
|
const INTEGRATION_NAME = "Graphql";
|
|
11
11
|
function getOptionsWithDefaults(options) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GRAPHQL_DATA_SYMBOL, GRAPHQL_FIELD_NAME, GRAPHQL_FIELD_PATH, GRAPHQL_FIELD_TYPE, GRAPHQL_PARENT_NAME, GRAPHQL_PATCHED_SYMBOL, GRAPHQL_PROCESSING_TYPE, ORIGIN, PROCESSING_TYPE_RESOLVE, SPAN_NAME_RESOLVE } from "./constants.js";
|
|
2
1
|
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
3
|
-
import { SPAN_STATUS_ERROR, getClient, hasSpanStreamingEnabled, isObjectLike, startInactiveSpan, withActiveSpan } from "@sentry/core";
|
|
4
2
|
import { GRAPHQL } from "@sentry/conventions/op";
|
|
3
|
+
import { SPAN_STATUS_ERROR, getClient, hasSpanStreamingEnabled, isObjectLike, startInactiveSpan, withActiveSpan } from "@sentry/core";
|
|
4
|
+
import { GRAPHQL_DATA_SYMBOL, GRAPHQL_FIELD_NAME, GRAPHQL_FIELD_PATH, GRAPHQL_FIELD_TYPE, GRAPHQL_PARENT_NAME, GRAPHQL_PATCHED_SYMBOL, GRAPHQL_PROCESSING_TYPE, ORIGIN, PROCESSING_TYPE_RESOLVE, SPAN_NAME_RESOLVE } from "./constants.js";
|
|
5
5
|
// src/integrations/graphql/resolvers.ts
|
|
6
6
|
function isPromise(value) {
|
|
7
7
|
return typeof value?.then === "function";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
2
|
+
import { GRAPHQL } from "@sentry/conventions/op";
|
|
3
|
+
import { SPAN_STATUS_ERROR, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
|
|
1
4
|
import { collectGraphqlDocument, getOperationSpanName, hasResultErrors, renameRootSpanWithOperation } from "./utils.js";
|
|
2
5
|
import { GRAPHQL_DATA_SYMBOL, GRAPHQL_PROCESSING_TYPE, ORIGIN, PROCESSING_TYPE_EXECUTE, PROCESSING_TYPE_PARSE, PROCESSING_TYPE_VALIDATE, SPAN_NAME_EXECUTE, SPAN_NAME_PARSE, SPAN_NAME_VALIDATE } from "./constants.js";
|
|
3
6
|
import { getOperation, wrapFieldResolver, wrapFields } from "./resolvers.js";
|
|
4
|
-
import { GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME, GRAPHQL_OPERATION_TYPE, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
5
|
-
import { SPAN_STATUS_ERROR, getClient, hasSpanStreamingEnabled, startInactiveSpan } from "@sentry/core";
|
|
6
|
-
import { GRAPHQL } from "@sentry/conventions/op";
|
|
7
7
|
// src/integrations/graphql/spans.ts
|
|
8
8
|
const BASE_ATTRIBUTES = {
|
|
9
9
|
[SENTRY_ORIGIN]: ORIGIN,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { defineIntegration } from "@sentry/core";
|
|
1
2
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
2
3
|
import { groqModuleNames } from "../orchestrion/config/groq.js";
|
|
3
4
|
import { createOpenAiCompatibleIntegration } from "./openai-compatible.js";
|
|
4
|
-
import { defineIntegration } from "@sentry/core";
|
|
5
5
|
// src/integrations/groq.ts
|
|
6
6
|
const GROQ_INTEGRATION_NAME = "Groq";
|
|
7
7
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { addNonEnumerableProperty, captureException, debug, getDefaultIsolationScope, getIsolationScope } from "@sentry/core";
|
|
1
2
|
import { DEBUG_BUILD } from "../../debug-build.js";
|
|
2
3
|
import { defaultShouldHandleError } from "./hapi-utils.js";
|
|
3
|
-
import { addNonEnumerableProperty, captureException, debug, getDefaultIsolationScope, getIsolationScope } from "@sentry/core";
|
|
4
4
|
// src/integrations/hapi/hapi-error-handler.ts
|
|
5
5
|
const ERROR_HANDLER_STATE = "__SENTRY_HAPI_ERROR_HANDLER_STATE__";
|
|
6
6
|
function isErrorEvent(event) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { HapiLayerType, HapiLifecycleMethodNames, handlerPatched } from "./hapi-types.js";
|
|
2
|
-
import { setHttpServerSpanRouteAttribute } from "../../utils/setHttpServerSpanRouteAttribute.js";
|
|
3
|
-
import { HAPI_EXT_TYPE, HAPI_PLUGIN_NAME, HAPI_TYPE, HTTP_REQUEST_METHOD, HTTP_ROUTE, SENTRY_OP, SENTRY_ORIGIN, SERVER_EXT_TYPE } from "@sentry/conventions/attributes";
|
|
4
1
|
import { REQUEST_HANDLER_SPAN_NAME_FALLBACK, ROUTER_SPAN_NAME_FALLBACK, getActiveSpan, getClient, hasSpanStreamingEnabled, isObjectLike, startSpan } from "@sentry/core";
|
|
2
|
+
import { HAPI_EXT_TYPE, HAPI_PLUGIN_NAME, HAPI_TYPE, HTTP_REQUEST_METHOD, HTTP_ROUTE, SENTRY_OP, SENTRY_ORIGIN, SERVER_EXT_TYPE } from "@sentry/conventions/attributes";
|
|
5
3
|
import { HANDLER, MIDDLEWARE, ROUTER } from "@sentry/conventions/op";
|
|
4
|
+
import { HapiLayerType, HapiLifecycleMethodNames, handlerPatched } from "./hapi-types.js";
|
|
5
|
+
import { setHttpServerSpanRouteAttribute } from "../../utils/setHttpServerSpanRouteAttribute.js";
|
|
6
6
|
// src/integrations/hapi/hapi-utils.ts
|
|
7
7
|
/**
|
|
8
8
|
* Default function deciding whether an error should be sent to Sentry.
|
|
@@ -179,8 +179,7 @@ function wrapExtArguments(args, pluginName) {
|
|
|
179
179
|
return;
|
|
180
180
|
} else if (isDirectExtInput(args)) {
|
|
181
181
|
const extInput = args;
|
|
182
|
-
|
|
183
|
-
args[1] = wrapExtMethods(method, extInput[0], pluginName);
|
|
182
|
+
args[1] = wrapExtMethods(extInput[1], extInput[0], pluginName);
|
|
184
183
|
return;
|
|
185
184
|
} else if (isLifecycleExtEventObj(args[0])) {
|
|
186
185
|
const lifecycleEventObj = args[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hapi-utils.js","names":[],"sources":["../../../../src/integrations/hapi/hapi-utils.ts"],"sourcesContent":["/*\n * OTel-free, `@hapi/*`-free port of the span-building helpers and handler/ext\n * wrap logic from the vendored `@opentelemetry/instrumentation-hapi`\n * (upstream @opentelemetry/instrumentation-hapi@0.64.0). Span output (names,\n * origins, attributes) is kept close to that instrumentation — except the\n * span ops, which are normalized to cross-framework ops (`handler` for plugin\n * routes, `router` for routes, `middleware` for server extensions); span\n * creation goes through the `@sentry/core` API and the OTel active-span guard\n * is replaced with `getActiveSpan()`.\n */\n\nimport {\n getActiveSpan,\n getClient,\n hasSpanStreamingEnabled,\n isObjectLike,\n REQUEST_HANDLER_SPAN_NAME_FALLBACK,\n ROUTER_SPAN_NAME_FALLBACK,\n startSpan,\n} from '@sentry/core';\nimport {\n HAPI_EXT_TYPE,\n HAPI_PLUGIN_NAME,\n HAPI_TYPE,\n HTTP_REQUEST_METHOD,\n HTTP_ROUTE,\n SENTRY_OP,\n SENTRY_ORIGIN,\n SERVER_EXT_TYPE,\n} from '@sentry/conventions/attributes';\nimport { HANDLER, MIDDLEWARE, ROUTER } from '@sentry/conventions/op';\nimport type {\n HapiRequest,\n LifecycleMethod,\n PatchableExtMethod,\n PatchableServerRoute,\n ServerExtDirectInput,\n ServerExtEventsObject,\n ServerExtEventsRequestObject,\n ServerRequestExtType,\n ServerRouteOptions,\n} from './hapi-types';\nimport { handlerPatched, HapiLayerType, HapiLifecycleMethodNames } from './hapi-types';\nimport { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute';\n\n/**\n * Default function deciding whether an error should be sent to Sentry.\n *\n * Captures 5xx errors and any error whose status can't be resolved; skips 3xx\n * and 4xx (client errors / redirects) and 2xx-and-below outliers are captured\n * as they usually signal an unmapped thrown error. Mirrors the defaults used by\n * the other server framework integrations.\n */\nexport function defaultShouldHandleError(error: unknown, request: HapiRequest): boolean {\n const statusCode = getResponseStatusCode(request, error);\n if (typeof statusCode !== 'number') {\n return true;\n }\n // 3xx and 4xx errors are not sent by default.\n return statusCode >= 500 || statusCode <= 299;\n}\n\n/**\n * Resolve the HTTP status for an errored hapi request: prefer the resolved\n * response (Boom `output.statusCode`, else `statusCode`), falling back to a Boom\n * error passed directly.\n */\nfunction getResponseStatusCode(request: HapiRequest, error: unknown): number | undefined {\n const response = request.response;\n if (isObjectLike(response)) {\n if (response.isBoom && isObjectLike(response.output) && typeof response.output.statusCode === 'number') {\n return response.output.statusCode;\n }\n if (typeof response.statusCode === 'number') {\n return response.statusCode;\n }\n }\n\n if (isObjectLike(error) && isObjectLike(error.output) && typeof error.output.statusCode === 'number') {\n return error.output.statusCode;\n }\n\n return undefined;\n}\n\ntype SpanAttributes = Record<string, string | undefined>;\n\ninterface SpanMetadata {\n attributes: SpanAttributes;\n name: string;\n}\n\nconst isLifecycleExtType = (variableToCheck: unknown): variableToCheck is ServerRequestExtType => {\n return typeof variableToCheck === 'string' && HapiLifecycleMethodNames.has(variableToCheck);\n};\n\nconst isLifecycleExtEventObj = (variableToCheck: unknown): variableToCheck is ServerExtEventsRequestObject => {\n const event = (variableToCheck as ServerExtEventsRequestObject)?.type;\n return event !== undefined && isLifecycleExtType(event);\n};\n\nconst isDirectExtInput = (variableToCheck: unknown): variableToCheck is ServerExtDirectInput => {\n return (\n Array.isArray(variableToCheck) &&\n variableToCheck.length <= 3 &&\n isLifecycleExtType(variableToCheck[0]) &&\n typeof variableToCheck[1] === 'function'\n );\n};\n\nconst isPatchableExtMethod = (\n variableToCheck: PatchableExtMethod | PatchableExtMethod[],\n): variableToCheck is PatchableExtMethod => {\n return !Array.isArray(variableToCheck);\n};\n\n/** Build the span name and attributes for a Hapi route. */\nexport const getRouteMetadata = ({\n path,\n method,\n pluginName,\n}: {\n path: string;\n method?: string;\n pluginName?: string;\n}): SpanMetadata => {\n const attributes: SpanAttributes = {\n [HTTP_ROUTE]: path,\n [HTTP_REQUEST_METHOD]: method,\n };\n\n if (pluginName) {\n attributes[HAPI_TYPE] = HapiLayerType.PLUGIN;\n attributes[HAPI_PLUGIN_NAME] = pluginName;\n } else {\n attributes[HAPI_TYPE] = HapiLayerType.ROUTER;\n }\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so router and request\n // handler spans are named after their route alone, without the method prefix.\n const isStreamedSpan = !!client && hasSpanStreamingEnabled(client);\n const fallbackName = pluginName ? REQUEST_HANDLER_SPAN_NAME_FALLBACK : ROUTER_SPAN_NAME_FALLBACK;\n const staticName = method ? `${method} ${path}` : path;\n\n return {\n attributes,\n name: isStreamedSpan ? path || fallbackName : staticName,\n };\n};\n\n/** Build the span name and attributes for a Hapi server extension. */\nexport const getExtMetadata = (\n extPoint: ServerRequestExtType,\n pluginName?: string,\n methodName?: string,\n): SpanMetadata => {\n let baseName = `ext - ${extPoint}`;\n if (methodName && methodName !== 'method') {\n // `method` is the default name for the extension in the ServerExtEventsObject format.\n baseName = `ext - ${extPoint} - ${methodName}`;\n }\n const attributes: SpanAttributes = {\n [HAPI_EXT_TYPE]: extPoint,\n // TODO(v12): Remove `server.ext.type`, which `hapi.ext.type` replaces.\n // oxlint-disable-next-line typescript/no-deprecated\n [SERVER_EXT_TYPE]: extPoint,\n [HAPI_TYPE]: HapiLayerType.EXT,\n };\n if (pluginName) {\n return {\n attributes: { ...attributes, [HAPI_PLUGIN_NAME]: pluginName },\n name: `${pluginName}: ${baseName}`,\n };\n }\n return { attributes, name: baseName };\n};\n\nconst HAPI_TYPE_TO_SPAN_OP: Record<string, string> = {\n [HapiLayerType.PLUGIN]: HANDLER,\n [HapiLayerType.ROUTER]: ROUTER,\n [HapiLayerType.EXT]: MIDDLEWARE,\n};\n\nfunction startMetadataSpan(metadata: SpanMetadata, original: () => unknown): unknown {\n const hapiType = metadata.attributes[HAPI_TYPE];\n const op = hapiType ? HAPI_TYPE_TO_SPAN_OP[hapiType] : undefined;\n return startSpan(\n {\n name: metadata.name,\n attributes: {\n ...metadata.attributes,\n [SENTRY_OP]: op,\n [SENTRY_ORIGIN]: 'auto.http.hapi',\n },\n },\n original,\n );\n}\n\n// The route config can register several methods (or `'*'`), so read the method\n// Hapi resolved for this request instead.\nfunction getRequestMethod(request: unknown): string | undefined {\n return isObjectLike(request) && typeof request.method === 'string' ? request.method.toUpperCase() : undefined;\n}\n\n/**\n * Patches each individual route handler method in order to create the span. It\n * does not create spans when there is no parent span.\n */\nfunction wrapRouteHandler(route: PatchableServerRoute, pluginName?: string): PatchableServerRoute {\n if (route[handlerPatched] === true) return route;\n route[handlerPatched] = true;\n\n const wrapHandler: (oldHandler: LifecycleMethod) => LifecycleMethod = oldHandler => {\n return function (this: unknown, ...params: Parameters<LifecycleMethod>) {\n if (!getActiveSpan()) {\n return oldHandler.call(this, ...params);\n }\n setHttpServerSpanRouteAttribute(route.path);\n const metadata = getRouteMetadata({ path: route.path, method: getRequestMethod(params[0]), pluginName });\n return startMetadataSpan(metadata, () => oldHandler.call(this, ...params));\n };\n };\n\n if (typeof route.handler === 'function') {\n route.handler = wrapHandler(route.handler as LifecycleMethod);\n } else if (typeof route.options === 'function') {\n const oldOptions = route.options;\n route.options = function (server: unknown): ServerRouteOptions {\n const options = oldOptions(server);\n if (typeof options.handler === 'function') {\n options.handler = wrapHandler(options.handler as LifecycleMethod);\n }\n return options;\n };\n } else if (typeof route.options?.handler === 'function') {\n route.options.handler = wrapHandler(route.options.handler as LifecycleMethod);\n }\n return route;\n}\n\n/**\n * Wraps request extension methods to add instrumentation to each new extension\n * handler. It does not create spans when there is no parent span.\n */\nfunction wrapExtMethods<T extends PatchableExtMethod | PatchableExtMethod[]>(\n method: T,\n extPoint: ServerRequestExtType,\n pluginName?: string,\n): T {\n if (Array.isArray(method)) {\n for (const [i, m] of method.entries()) {\n method[i] = wrapExtMethods(m, extPoint);\n }\n return method;\n } else if (isPatchableExtMethod(method)) {\n if (method[handlerPatched] === true) return method;\n method[handlerPatched] = true;\n\n const newHandler: PatchableExtMethod = function (this: unknown, ...params: Parameters<LifecycleMethod>) {\n if (!getActiveSpan()) {\n return method.apply(this, params);\n }\n const metadata = getExtMetadata(extPoint, pluginName, method.name);\n return startMetadataSpan(metadata, () => method.apply(undefined, params));\n };\n // Mark the wrapper too (not just the original)\n newHandler[handlerPatched] = true;\n return newHandler as T;\n }\n return method;\n}\n\n/**\n * Wrap the route handler(s) in the live `server.route` arguments array, mutating\n * `args[0]` in place. `args[0]` is either a single route options object or an\n * array of them. Idempotent via the `handlerPatched` marker.\n */\nexport function wrapRouteArguments(args: unknown[], pluginName?: string): void {\n const route = args[0] as PatchableServerRoute | PatchableServerRoute[];\n if (Array.isArray(route)) {\n for (const [i, r] of route.entries()) {\n route[i] = wrapRouteHandler(r, pluginName);\n }\n } else {\n args[0] = wrapRouteHandler(route, pluginName);\n }\n}\n\n/**\n * Wrap the extension method(s) in the live `server.ext` arguments array,\n * mutating `args` in place. Handles the three accepted input shapes:\n * `(eventsArray)`, `(lifecycleEventObject)`, and `(extTypeString, method, options)`.\n * Idempotent via the `handlerPatched` marker.\n */\nexport function wrapExtArguments(args: unknown[], pluginName?: string): void {\n if (Array.isArray(args[0])) {\n const eventsList = args[0] as ServerExtEventsObject[] | ServerExtEventsRequestObject[];\n for (const [i, eventObj] of eventsList.entries()) {\n if (isLifecycleExtType(eventObj.type)) {\n const lifecycleEventObj = eventObj as ServerExtEventsRequestObject;\n const handler = wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName);\n lifecycleEventObj.method = handler;\n eventsList[i] = lifecycleEventObj;\n }\n }\n return;\n } else if (isDirectExtInput(args)) {\n const extInput: ServerExtDirectInput = args;\n const method: PatchableExtMethod = extInput[1];\n const handler = wrapExtMethods(method, extInput[0], pluginName);\n args[1] = handler;\n return;\n } else if (isLifecycleExtEventObj(args[0])) {\n const lifecycleEventObj = args[0];\n const handler = wrapExtMethods(lifecycleEventObj.method, lifecycleEventObj.type, pluginName);\n lifecycleEventObj.method = handler;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqDA,SAAgB,yBAAyB,OAAgB,SAA+B;CACtF,MAAM,aAAa,sBAAsB,SAAS,KAAK;CACvD,IAAI,OAAO,eAAe,UAC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,QAAQ,GAC7C,IAAI,mBAAmB,SAAS,IAAI,GAAG;GACrC,MAAM,oBAAoB;GAE1B,kBAAkB,SADF,eAAe,kBAAkB,QAAQ,SAAS,MAAM,UACvC;GACjC,WAAW,KAAK;EAClB;EAEF;CACF,OAAO,IAAI,iBAAiB,IAAI,GAAG;EACjC,MAAM,WAAiC;EACvC,MAAM,SAA6B,SAAS;EAE5C,KAAK,KADW,eAAe,QAAQ,SAAS,IAAI,UACpC;EAChB;CACF,OAAO,IAAI,uBAAuB,KAAK,EAAE,GAAG;EAC1C,MAAM,oBAAoB,KAAK;EAE/B,kBAAkB,SADF,eAAe,kBAAkB,QAAQ,kBAAkB,MAAM,UAChD;CACnC;AACF"}
|
|
1
|
+
{"version":3,"file":"hapi-utils.js","names":[],"sources":["../../../../src/integrations/hapi/hapi-utils.ts"],"sourcesContent":["/*\n * OTel-free, `@hapi/*`-free port of the span-building helpers and handler/ext\n * wrap logic from the vendored `@opentelemetry/instrumentation-hapi`\n * (upstream @opentelemetry/instrumentation-hapi@0.64.0). Span output (names,\n * origins, attributes) is kept close to that instrumentation — except the\n * span ops, which are normalized to cross-framework ops (`handler` for plugin\n * routes, `router` for routes, `middleware` for server extensions); span\n * creation goes through the `@sentry/core` API and the OTel active-span guard\n * is replaced with `getActiveSpan()`.\n */\n\nimport {\n getActiveSpan,\n getClient,\n hasSpanStreamingEnabled,\n isObjectLike,\n REQUEST_HANDLER_SPAN_NAME_FALLBACK,\n ROUTER_SPAN_NAME_FALLBACK,\n startSpan,\n} from '@sentry/core';\nimport {\n HAPI_EXT_TYPE,\n HAPI_PLUGIN_NAME,\n HAPI_TYPE,\n HTTP_REQUEST_METHOD,\n HTTP_ROUTE,\n SENTRY_OP,\n SENTRY_ORIGIN,\n SERVER_EXT_TYPE,\n} from '@sentry/conventions/attributes';\nimport { HANDLER, MIDDLEWARE, ROUTER } from '@sentry/conventions/op';\nimport type {\n HapiRequest,\n LifecycleMethod,\n PatchableExtMethod,\n PatchableServerRoute,\n ServerExtDirectInput,\n ServerExtEventsObject,\n ServerExtEventsRequestObject,\n ServerRequestExtType,\n ServerRouteOptions,\n} from './hapi-types';\nimport { handlerPatched, HapiLayerType, HapiLifecycleMethodNames } from './hapi-types';\nimport { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute';\n\n/**\n * Default function deciding whether an error should be sent to Sentry.\n *\n * Captures 5xx errors and any error whose status can't be resolved; skips 3xx\n * and 4xx (client errors / redirects) and 2xx-and-below outliers are captured\n * as they usually signal an unmapped thrown error. Mirrors the defaults used by\n * the other server framework integrations.\n */\nexport function defaultShouldHandleError(error: unknown, request: HapiRequest): boolean {\n const statusCode = getResponseStatusCode(request, error);\n if (typeof statusCode !== 'number') {\n return true;\n }\n // 3xx and 4xx errors are not sent by default.\n return statusCode >= 500 || statusCode <= 299;\n}\n\n/**\n * Resolve the HTTP status for an errored hapi request: prefer the resolved\n * response (Boom `output.statusCode`, else `statusCode`), falling back to a Boom\n * error passed directly.\n */\nfunction getResponseStatusCode(request: HapiRequest, error: unknown): number | undefined {\n const response = request.response;\n if (isObjectLike(response)) {\n if (response.isBoom && isObjectLike(response.output) && typeof response.output.statusCode === 'number') {\n return response.output.statusCode;\n }\n if (typeof response.statusCode === 'number') {\n return response.statusCode;\n }\n }\n\n if (isObjectLike(error) && isObjectLike(error.output) && typeof error.output.statusCode === 'number') {\n return error.output.statusCode;\n }\n\n return undefined;\n}\n\ntype SpanAttributes = Record<string, string | undefined>;\n\ninterface SpanMetadata {\n attributes: SpanAttributes;\n name: string;\n}\n\nconst isLifecycleExtType = (variableToCheck: unknown): variableToCheck is ServerRequestExtType => {\n return typeof variableToCheck === 'string' && HapiLifecycleMethodNames.has(variableToCheck);\n};\n\nconst isLifecycleExtEventObj = (variableToCheck: unknown): variableToCheck is ServerExtEventsRequestObject => {\n const event = (variableToCheck as ServerExtEventsRequestObject)?.type;\n return event !== undefined && isLifecycleExtType(event);\n};\n\nconst isDirectExtInput = (variableToCheck: unknown): variableToCheck is ServerExtDirectInput => {\n return (\n Array.isArray(variableToCheck) &&\n variableToCheck.length <= 3 &&\n isLifecycleExtType(variableToCheck[0]) &&\n typeof variableToCheck[1] === 'function'\n );\n};\n\nconst isPatchableExtMethod = (\n variableToCheck: PatchableExtMethod | PatchableExtMethod[],\n): variableToCheck is PatchableExtMethod => {\n return !Array.isArray(variableToCheck);\n};\n\n/** Build the span name and attributes for a Hapi route. */\nexport const getRouteMetadata = ({\n path,\n method,\n pluginName,\n}: {\n path: string;\n method?: string;\n pluginName?: string;\n}): SpanMetadata => {\n const attributes: SpanAttributes = {\n [HTTP_ROUTE]: path,\n [HTTP_REQUEST_METHOD]: method,\n };\n\n if (pluginName) {\n attributes[HAPI_TYPE] = HapiLayerType.PLUGIN;\n attributes[HAPI_PLUGIN_NAME] = pluginName;\n } else {\n attributes[HAPI_TYPE] = HapiLayerType.ROUTER;\n }\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so router and request\n // handler spans are named after their route alone, without the method prefix.\n const isStreamedSpan = !!client && hasSpanStreamingEnabled(client);\n const fallbackName = pluginName ? REQUEST_HANDLER_SPAN_NAME_FALLBACK : ROUTER_SPAN_NAME_FALLBACK;\n const staticName = method ? `${method} ${path}` : path;\n\n return {\n attributes,\n name: isStreamedSpan ? path || fallbackName : staticName,\n };\n};\n\n/** Build the span name and attributes for a Hapi server extension. */\nexport const getExtMetadata = (\n extPoint: ServerRequestExtType,\n pluginName?: string,\n methodName?: string,\n): SpanMetadata => {\n let baseName = `ext - ${extPoint}`;\n if (methodName && methodName !== 'method') {\n // `method` is the default name for the extension in the ServerExtEventsObject format.\n baseName = `ext - ${extPoint} - ${methodName}`;\n }\n const attributes: SpanAttributes = {\n [HAPI_EXT_TYPE]: extPoint,\n // TODO(v12): Remove `server.ext.type`, which `hapi.ext.type` replaces.\n // oxlint-disable-next-line typescript/no-deprecated\n [SERVER_EXT_TYPE]: extPoint,\n [HAPI_TYPE]: HapiLayerType.EXT,\n };\n if (pluginName) {\n return {\n attributes: { ...attributes, [HAPI_PLUGIN_NAME]: pluginName },\n name: `${pluginName}: ${baseName}`,\n };\n }\n return { attributes, name: baseName };\n};\n\nconst HAPI_TYPE_TO_SPAN_OP: Record<string, string> = {\n [HapiLayerType.PLUGIN]: HANDLER,\n [HapiLayerType.ROUTER]: ROUTER,\n [HapiLayerType.EXT]: MIDDLEWARE,\n};\n\nfunction startMetadataSpan(metadata: SpanMetadata, original: () => unknown): unknown {\n const hapiType = metadata.attributes[HAPI_TYPE];\n const op = hapiType ? HAPI_TYPE_TO_SPAN_OP[hapiType] : undefined;\n return startSpan(\n {\n name: metadata.name,\n attributes: {\n ...metadata.attributes,\n [SENTRY_OP]: op,\n [SENTRY_ORIGIN]: 'auto.http.hapi',\n },\n },\n original,\n );\n}\n\n// The route config can register several methods (or `'*'`), so read the method\n// Hapi resolved for this request instead.\nfunction getRequestMethod(request: unknown): string | undefined {\n return isObjectLike(request) && typeof request.method === 'string' ? request.method.toUpperCase() : undefined;\n}\n\n/**\n * Patches each individual route handler method in order to create the span. It\n * does not create spans when there is no parent span.\n */\nfunction wrapRouteHandler(route: PatchableServerRoute, pluginName?: string): PatchableServerRoute {\n if (route[handlerPatched] === true) return route;\n route[handlerPatched] = true;\n\n const wrapHandler: (oldHandler: LifecycleMethod) => LifecycleMethod = oldHandler => {\n return function (this: unknown, ...params: Parameters<LifecycleMethod>) {\n if (!getActiveSpan()) {\n return oldHandler.call(this, ...params);\n }\n setHttpServerSpanRouteAttribute(route.path);\n const metadata = getRouteMetadata({ path: route.path, method: getRequestMethod(params[0]), pluginName });\n return startMetadataSpan(metadata, () => oldHandler.call(this, ...params));\n };\n };\n\n if (typeof route.handler === 'function') {\n route.handler = wrapHandler(route.handler as LifecycleMethod);\n } else if (typeof route.options === 'function') {\n const oldOptions = route.options;\n route.options = function (server: unknown): ServerRouteOptions {\n const options = oldOptions(server);\n if (typeof options.handler === 'function') {\n options.handler = wrapHandler(options.handler as LifecycleMethod);\n }\n return options;\n };\n } else if (typeof route.options?.handler === 'function') {\n route.options.handler = wrapHandler(route.options.handler as LifecycleMethod);\n }\n return route;\n}\n\n/**\n * Wraps request extension methods to add instrumentation to each new extension\n * handler. It does not create spans when there is no parent span.\n */\nfunction wrapExtMethods<T extends PatchableExtMethod | PatchableExtMethod[]>(\n method: T,\n extPoint: ServerRequestExtType,\n pluginName?: string,\n): T {\n if (Array.isArray(method)) {\n for (const [i, m] of method.entries()) {\n method[i] = wrapExtMethods(m, extPoint);\n }\n return method;\n } else if (isPatchableExtMethod(method)) {\n if (method[handlerPatched] === true) return method;\n method[handlerPatched] = true;\n\n const newHandler: PatchableExtMethod = function (this: unknown, ...params: Parameters<LifecycleMethod>) {\n if (!getActiveSpan()) {\n return method.apply(this, params);\n }\n const metadata = getExtMetadata(extPoint, pluginName, method.name);\n return startMetadataSpan(metadata, () => method.apply(undefined, params));\n };\n // Mark the wrapper too (not just the original)\n newHandler[handlerPatched] = true;\n return newHandler as T;\n }\n return method;\n}\n\n/**\n * Wrap the route handler(s) in the live `server.route` arguments array, mutating\n * `args[0]` in place. `args[0]` is either a single route options object or an\n * array of them. Idempotent via the `handlerPatched` marker.\n */\nexport function wrapRouteArguments(args: unknown[], pluginName?: string): void {\n const route = args[0] as PatchableServerRoute | PatchableServerRoute[];\n if (Array.isArray(route)) {\n for (const [i, r] of route.entries()) {\n route[i] = wrapRouteHandler(r, pluginName);\n }\n } else {\n args[0] = wrapRouteHandler(route, pluginName);\n }\n}\n\n/**\n * Wrap the extension method(s) in the live `server.ext` arguments array,\n * mutating `args` in place. Handles the three accepted input shapes:\n * `(eventsArray)`, `(lifecycleEventObject)`, and `(extTypeString, method, options)`.\n * Idempotent via the `handlerPatched` marker.\n */\nexport function wrapExtArguments(args: unknown[], pluginName?: string): void {\n if (Array.isArray(args[0])) {\n const eventsList = args[0] as ServerExtEventsObject[] | ServerExtEventsRequestObject[];\n for (const [i, eventObj] of eventsList.entries()) {\n if (isLifecycleExtType(eventObj.type)) {\n const lifecycleEventObj = eventObj as ServerExtEventsRequestObject;\n const handler = wrapExtMethods(lifecycleEventObj.method, eventObj.type, pluginName);\n lifecycleEventObj.method = handler;\n eventsList[i] = lifecycleEventObj;\n }\n }\n return;\n } else if (isDirectExtInput(args)) {\n const extInput: ServerExtDirectInput = args;\n const method: PatchableExtMethod = extInput[1];\n const handler = wrapExtMethods(method, extInput[0], pluginName);\n args[1] = handler;\n return;\n } else if (isLifecycleExtEventObj(args[0])) {\n const lifecycleEventObj = args[0];\n const handler = wrapExtMethods(lifecycleEventObj.method, lifecycleEventObj.type, pluginName);\n lifecycleEventObj.method = handler;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqDA,SAAgB,yBAAyB,OAAgB,SAA+B;CACtF,MAAM,aAAa,sBAAsB,SAAS,KAAK;CACvD,IAAI,OAAO,eAAe,UACxB,OAAO;CAGT,OAAO,cAAc,OAAO,cAAc;AAC5C;;;;;;AAOA,SAAS,sBAAsB,SAAsB,OAAoC;CACvF,MAAM,WAAW,QAAQ;CACzB,IAAI,aAAa,QAAQ,GAAG;EAC1B,IAAI,SAAS,UAAU,aAAa,SAAS,MAAM,KAAK,OAAO,SAAS,OAAO,eAAe,UAC5F,OAAO,SAAS,OAAO;EAEzB,IAAI,OAAO,SAAS,eAAe,UACjC,OAAO,SAAS;CAEpB;CAEA,IAAI,aAAa,KAAK,KAAK,aAAa,MAAM,MAAM,KAAK,OAAO,MAAM,OAAO,eAAe,UAC1F,OAAO,MAAM,OAAO;AAIxB;AASA,MAAM,sBAAsB,oBAAsE;CAChG,OAAO,OAAO,oBAAoB,YAAY,yBAAyB,IAAI,eAAe;AAC5F;AAEA,MAAM,0BAA0B,oBAA8E;CAC5G,MAAM,QAAS,iBAAkD;CACjE,OAAO,UAAU,KAAA,KAAa,mBAAmB,KAAK;AACxD;AAEA,MAAM,oBAAoB,oBAAsE;CAC9F,OACE,MAAM,QAAQ,eAAe,KAC7B,gBAAgB,UAAU,KAC1B,mBAAmB,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kBADU,eAAe,UAAU,YAAY,OAAO,IAC7B,SAAS,OAAO,MAAM,KAAA,GAAW,MAAM,CAAC;EAC1E;EAEA,WAAW,kBAAkB;EAC7B,OAAO;CACT;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,mBAAmB,MAAiB,YAA2B;CAC7E,MAAM,QAAQ,KAAK;CACnB,IAAI,MAAM,QAAQ,KAAK,GACrB,KAAK,MAAM,CAAC,GAAG,MAAM,MAAM,QAAQ,GACjC,MAAM,KAAK,iBAAiB,GAAG,UAAU;MAG3C,KAAK,KAAK,iBAAiB,OAAO,UAAU;AAEhD;;;;;;;AAQA,SAAgB,iBAAiB,MAAiB,YAA2B;CAC3E,IAAI,MAAM,QAAQ,KAAK,EAAE,GAAG;EAC1B,MAAM,aAAa,KAAK;EACxB,KAAK,MAAM,CAAC,GAAG,aAAa,WAAW,QAAQ,GAC7C,IAAI,mBAAmB,SAAS,IAAI,GAAG;GACrC,MAAM,oBAAoB;GAE1B,kBAAkB,SADF,eAAe,kBAAkB,QAAQ,SAAS,MAAM,UACvC;GACjC,WAAW,KAAK;EAClB;EAEF;CACF,OAAO,IAAI,iBAAiB,IAAI,GAAG;EACjC,MAAM,WAAiC;EAGvC,KAAK,KADW,eADmB,SAAS,IACL,SAAS,IAAI,UACpC;EAChB;CACF,OAAO,IAAI,uBAAuB,KAAK,EAAE,GAAG;EAC1C,MAAM,oBAAoB,KAAK;EAE/B,kBAAkB,SADF,eAAe,kBAAkB,QAAQ,kBAAkB,MAAM,UAChD;CACnC;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { tracingChannel } from "../../utils/diagnosticsChannel.js";
|
|
2
|
+
import { defineIntegration } from "@sentry/core";
|
|
2
3
|
import { CHANNELS } from "../../orchestrion/channels.js";
|
|
3
4
|
import { hapiModuleNames } from "../../orchestrion/config/hapi.js";
|
|
4
5
|
import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
|
|
5
6
|
import { attachHapiErrorHandler } from "./hapi-error-handler.js";
|
|
6
7
|
import { wrapExtArguments, wrapRouteArguments } from "./hapi-utils.js";
|
|
7
|
-
import { defineIntegration } from "@sentry/core";
|
|
8
8
|
// src/integrations/hapi/index.ts
|
|
9
9
|
const INTEGRATION_NAME = "Hapi";
|
|
10
10
|
const _hapiIntegration = (({ shouldHandleError } = {}) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { debug } from "@sentry/core";
|
|
1
2
|
import { DEBUG_BUILD } from "../../debug-build.js";
|
|
2
3
|
import { patchAppRequest } from "./patchAppRequest.js";
|
|
3
4
|
import { patchAppUse, patchHttpMethodHandlers } from "./patchAppUse.js";
|
|
4
5
|
import { installRouteHookOnPrototype, wrapSubAppMiddleware } from "./patchRoute.js";
|
|
5
|
-
import { debug } from "@sentry/core";
|
|
6
6
|
// src/integrations/hono/applyPatches.ts
|
|
7
7
|
let _routeHook;
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { addNonEnumerableProperty, getDefaultIsolationScope, getIsolationScope } from "@sentry/core";
|
|
1
2
|
import { SENTRY_HONO_MIDDLEWARE } from "./constants.js";
|
|
2
3
|
import { captureContextError, requestHandler, responseHandler } from "./middlewareHandlers.js";
|
|
3
|
-
import { addNonEnumerableProperty, getDefaultIsolationScope, getIsolationScope } from "@sentry/core";
|
|
4
4
|
// src/integrations/hono/createHonoMiddleware.ts
|
|
5
5
|
const HONO_REQUEST_HANDLED = Symbol.for("sentry.hono.requestHandled");
|
|
6
6
|
const HONO_SHOULD_HANDLE_ERROR = Symbol.for("sentry.hono.shouldHandleError");
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { tracingChannel } from "../../utils/diagnosticsChannel.js";
|
|
2
|
+
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
3
|
+
import { HTTP_SERVER } from "@sentry/conventions/op";
|
|
4
|
+
import { defineIntegration, startInactiveSpan } from "@sentry/core";
|
|
2
5
|
import { CHANNELS } from "../../orchestrion/channels.js";
|
|
3
6
|
import { honoModuleNames } from "../../orchestrion/config/hono.js";
|
|
4
7
|
import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
|
|
@@ -11,9 +14,6 @@ import { getMiddlewareFlags } from "./isMiddleware.js";
|
|
|
11
14
|
import { isMatchedHandlerList, wrapRouteHandlers } from "./matchResult.js";
|
|
12
15
|
import { extractPathname, isInternalRequestSpanActive } from "./patchAppRequest.js";
|
|
13
16
|
import { wrapMiddlewareWithSpan } from "./wrapMiddlewareSpan.js";
|
|
14
|
-
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
15
|
-
import { defineIntegration, startInactiveSpan } from "@sentry/core";
|
|
16
|
-
import { HTTP_SERVER } from "@sentry/conventions/op";
|
|
17
17
|
// src/integrations/hono/honoIntegration.ts
|
|
18
18
|
const INTEGRATION_NAME = "Hono";
|
|
19
19
|
function getHonoRuntime() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { sentryOriginalTraps } from "./sentryOriginalTraps.js";
|
|
2
1
|
import { addNonEnumerableProperty, isPlainObject } from "@sentry/core";
|
|
2
|
+
import { sentryOriginalTraps } from "./sentryOriginalTraps.js";
|
|
3
3
|
// src/integrations/hono/matchResult.ts
|
|
4
4
|
const ROUTE_HANDLER_INDEX = Symbol.for("sentry.hono.routeHandlerIndex");
|
|
5
5
|
const RECORDS_ROUTE_HANDLER_INDEX = Symbol.for("sentry.hono.recordsRouteHandlerIndex");
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { INTERNAL_setSegmentNameSourceIfSegment, captureException, getActiveSpan, getClient, getDefaultIsolationScope, getIsolationScope, getRootSpan, spanToJSON, updateSpanName, winterCGHeadersToDict, winterCGRequestToRequestData } from "@sentry/core";
|
|
2
|
+
import { getClientIPAddress } from "@sentry/core/server";
|
|
1
3
|
import { readConnInfo } from "./connInfo.js";
|
|
2
4
|
import { hasFetchEvent } from "./hono-context.js";
|
|
3
5
|
import { defaultShouldHandleError } from "./defaultShouldHandleError.js";
|
|
@@ -6,8 +8,6 @@ import { getMatchedHandlers, onRouteHandlerStart, wrapRouteHandlers } from "./ma
|
|
|
6
8
|
import { resolveRouteName } from "./resolveRouteName.js";
|
|
7
9
|
import { unwrapThrownValue } from "./unwrapThrownValue.js";
|
|
8
10
|
import { CLIENT_ADDRESS, CLIENT_PORT, HTTP_ROUTE, NETWORK_PEER_ADDRESS, NETWORK_PEER_PORT, NETWORK_TRANSPORT, NETWORK_TYPE } from "@sentry/conventions/attributes";
|
|
9
|
-
import { INTERNAL_setSegmentNameSourceIfSegment, captureException, getActiveSpan, getClient, getDefaultIsolationScope, getIsolationScope, getRootSpan, spanToJSON, updateSpanName, winterCGHeadersToDict, winterCGRequestToRequestData } from "@sentry/core";
|
|
10
|
-
import { getClientIPAddress } from "@sentry/core/server";
|
|
11
11
|
// src/integrations/hono/middlewareHandlers.ts
|
|
12
12
|
/**
|
|
13
13
|
* Request handler for Hono framework
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
2
|
+
import { HTTP_SERVER } from "@sentry/conventions/op";
|
|
3
|
+
import { debug, getActiveSpan, getOriginalFunction, startSpan } from "@sentry/core";
|
|
1
4
|
import { INTERNAL_REQUEST_ORIGIN } from "./constants.js";
|
|
2
5
|
import { DEBUG_BUILD } from "../../debug-build.js";
|
|
3
6
|
import { sentryOriginalTraps } from "./sentryOriginalTraps.js";
|
|
4
|
-
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
5
|
-
import { debug, getActiveSpan, getOriginalFunction, startSpan } from "@sentry/core";
|
|
6
|
-
import { HTTP_SERVER } from "@sentry/conventions/op";
|
|
7
7
|
// src/integrations/hono/patchAppRequest.ts
|
|
8
8
|
const INTERNAL_REQUEST_OP = HTTP_SERVER;
|
|
9
9
|
const INTERNAL_REQUEST_SPAN_ACTIVE = Symbol.for("sentry.hono.internalRequestSpanActive");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { debug } from "@sentry/core";
|
|
1
2
|
import { DEBUG_BUILD } from "../../debug-build.js";
|
|
2
3
|
import { wrapMiddlewareWithSpan } from "./wrapMiddlewareSpan.js";
|
|
3
|
-
import { debug } from "@sentry/core";
|
|
4
4
|
// src/integrations/hono/patchAppUse.ts
|
|
5
5
|
const patchedUseInstances = /* @__PURE__ */ new WeakSet();
|
|
6
6
|
const patchedMethodInstances = /* @__PURE__ */ new WeakSet();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { debug, getOriginalFunction } from "@sentry/core";
|
|
1
2
|
import { DEBUG_BUILD } from "../../debug-build.js";
|
|
2
3
|
import { getMiddlewareFlags } from "./isMiddleware.js";
|
|
3
4
|
import { patchAppRequest } from "./patchAppRequest.js";
|
|
4
5
|
import { wrapMiddlewareWithSpan } from "./wrapMiddlewareSpan.js";
|
|
5
6
|
import { sentryOriginalTraps } from "./sentryOriginalTraps.js";
|
|
6
|
-
import { debug, getOriginalFunction } from "@sentry/core";
|
|
7
7
|
// src/integrations/hono/patchRoute.ts
|
|
8
8
|
/**
|
|
9
9
|
* Creates the two-phase state machine for the route hook.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
2
|
+
import { MIDDLEWARE } from "@sentry/conventions/op";
|
|
3
|
+
import { SPAN_STATUS_ERROR, getActiveSpan, getOriginalFunction, getRootSpan, startInactiveSpan } from "@sentry/core";
|
|
1
4
|
import "./constants.js";
|
|
2
5
|
import { defaultShouldHandleError } from "./defaultShouldHandleError.js";
|
|
3
6
|
import { sentryOriginalTraps } from "./sentryOriginalTraps.js";
|
|
4
|
-
import { SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
5
|
-
import { SPAN_STATUS_ERROR, getActiveSpan, getOriginalFunction, getRootSpan, startInactiveSpan } from "@sentry/core";
|
|
6
|
-
import { MIDDLEWARE } from "@sentry/conventions/op";
|
|
7
7
|
// src/integrations/hono/wrapMiddlewareSpan.ts
|
|
8
8
|
const MIDDLEWARE_ORIGIN = "auto.middleware.hono";
|
|
9
9
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ATTR_MESSAGING_DESTINATION_PARTITION_ID, MESSAGING_OPERATION_TYPE_VALUE_PROCESS, MESSAGING_OPERATION_TYPE_VALUE_RECEIVE } from "./semconv.js";
|
|
2
|
-
import { endSpansOnPromise, getHeaderAsString, getLinksFromHeaders, startConsumerSpan } from "./spans.js";
|
|
3
1
|
import { MESSAGING_BATCH_MESSAGE_COUNT } from "@sentry/conventions/attributes";
|
|
4
2
|
import { continueTrace, startNewTrace, withActiveSpan } from "@sentry/core";
|
|
3
|
+
import { ATTR_MESSAGING_DESTINATION_PARTITION_ID, MESSAGING_OPERATION_TYPE_VALUE_PROCESS, MESSAGING_OPERATION_TYPE_VALUE_RECEIVE } from "./semconv.js";
|
|
4
|
+
import { endSpansOnPromise, getHeaderAsString, getLinksFromHeaders, startConsumerSpan } from "./spans.js";
|
|
5
5
|
// src/integrations/kafkajs/consumer.ts
|
|
6
6
|
const consumerCallbackWrapped = Symbol("sentry-kafkajs-consumer-callback-wrapped");
|
|
7
7
|
/** Whether `fn` is a callback this module already wrapped, so callers skip re-wrapping it. */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { tracingChannel } from "../../utils/diagnosticsChannel.js";
|
|
2
|
+
import { defineIntegration } from "@sentry/core";
|
|
2
3
|
import { CHANNELS } from "../../orchestrion/channels.js";
|
|
3
4
|
import { kafkajsModuleNames } from "../../orchestrion/config/kafkajs.js";
|
|
4
5
|
import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
|
|
5
6
|
import { isWrappedConsumerCallback, wrapEachBatch, wrapEachMessage } from "./consumer.js";
|
|
6
7
|
import { applyErrorToSpans, startProducerSpan } from "./spans.js";
|
|
7
|
-
import { defineIntegration } from "@sentry/core";
|
|
8
8
|
// src/integrations/kafkajs/index.ts
|
|
9
9
|
const INTEGRATION_NAME = "Kafka";
|
|
10
10
|
function subscribeToProducer() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ATTR_MESSAGING_DESTINATION_PARTITION_ID, ATTR_MESSAGING_KAFKA_MESSAGE_KEY, ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE, ATTR_MESSAGING_KAFKA_OFFSET, ERROR_TYPE_VALUE_OTHER, MESSAGING_OPERATION_TYPE_VALUE_RECEIVE, MESSAGING_OPERATION_TYPE_VALUE_SEND, MESSAGING_SYSTEM_VALUE_KAFKA } from "./semconv.js";
|
|
2
1
|
import { ERROR_TYPE, MESSAGING_DESTINATION_NAME, MESSAGING_OPERATION_NAME, MESSAGING_OPERATION_TYPE, MESSAGING_SYSTEM, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
3
|
-
import { SPAN_STATUS_ERROR, getClient, getTraceData, hasSpanStreamingEnabled, isObjectLike, propagationContextFromHeaders, startInactiveSpan } from "@sentry/core";
|
|
4
2
|
import { QUEUE_PROCESS, QUEUE_PUBLISH, QUEUE_RECEIVE } from "@sentry/conventions/op";
|
|
3
|
+
import { SPAN_STATUS_ERROR, getClient, getTraceData, hasSpanStreamingEnabled, isObjectLike, propagationContextFromHeaders, startInactiveSpan } from "@sentry/core";
|
|
4
|
+
import { ATTR_MESSAGING_DESTINATION_PARTITION_ID, ATTR_MESSAGING_KAFKA_MESSAGE_KEY, ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE, ATTR_MESSAGING_KAFKA_OFFSET, ERROR_TYPE_VALUE_OTHER, MESSAGING_OPERATION_TYPE_VALUE_RECEIVE, MESSAGING_OPERATION_TYPE_VALUE_SEND, MESSAGING_SYSTEM_VALUE_KAFKA } from "./semconv.js";
|
|
5
5
|
// src/integrations/kafkajs/spans.ts
|
|
6
6
|
const PRODUCER_ORIGIN = "auto.queue.kafkajs.producer";
|
|
7
7
|
const CONSUMER_ORIGIN = "auto.queue.kafkajs.consumer";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
+
import { SPAN_STATUS_ERROR, debug, defineIntegration, getActiveSpan, startInactiveSpan, truncate, waitForTracingChannelBinding } from "@sentry/core";
|
|
3
|
+
import { DB_NAMESPACE, DB_OPERATION_NAME, DB_SYSTEM_NAME, DB_USER, NETWORK_TRANSPORT, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
|
|
4
|
+
import { DB } from "@sentry/conventions/op";
|
|
2
5
|
import { DEBUG_BUILD } from "../debug-build.js";
|
|
3
6
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
4
7
|
import { bindTracingChannelToSpan } from "../tracing-channel.js";
|
|
5
8
|
import { getSqlQueryAttributes, getSqlSpanName, toSqlDialect } from "../utils/sql.js";
|
|
6
|
-
import { DB_NAMESPACE, DB_OPERATION_NAME, DB_SYSTEM_NAME, DB_USER, NETWORK_TRANSPORT, SENTRY_KIND, SENTRY_OP, SENTRY_ORIGIN, SERVER_ADDRESS, SERVER_PORT } from "@sentry/conventions/attributes";
|
|
7
|
-
import { SPAN_STATUS_ERROR, debug, defineIntegration, getActiveSpan, startInactiveSpan, truncate, waitForTracingChannelBinding } from "@sentry/core";
|
|
8
|
-
import { DB } from "@sentry/conventions/op";
|
|
9
9
|
// src/integrations/knex.ts
|
|
10
10
|
const INTEGRATION_NAME = "Knex";
|
|
11
11
|
const ORIGIN = "auto.db.knex";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { tracingChannel } from "../../utils/diagnosticsChannel.js";
|
|
2
|
+
import { ROUTER_SPAN_NAME_FALLBACK, addNonEnumerableProperty, debug, defineIntegration, getActiveSpan, getClient, getDefaultIsolationScope, getIsolationScope, hasSpanStreamingEnabled, startSpan } from "@sentry/core";
|
|
3
|
+
import { CODE_FUNCTION_NAME, HTTP_ROUTE, KOA_TYPE, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
4
|
+
import { MIDDLEWARE, ROUTER } from "@sentry/conventions/op";
|
|
2
5
|
import { DEBUG_BUILD } from "../../debug-build.js";
|
|
3
6
|
import { CHANNELS } from "../../orchestrion/channels.js";
|
|
4
7
|
import { koaModuleNames } from "../../orchestrion/config/koa.js";
|
|
5
8
|
import { invokeOrchestrionInstrumentation } from "../../orchestrion/instrumentation.js";
|
|
6
9
|
import { setHttpServerSpanRouteAttribute } from "../../utils/setHttpServerSpanRouteAttribute.js";
|
|
7
10
|
import { KOA_CONTEXT_SPAN, attachKoaErrorHandler } from "./koa-error-handler.js";
|
|
8
|
-
import { CODE_FUNCTION_NAME, HTTP_ROUTE, KOA_TYPE, SENTRY_OP, SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
9
|
-
import { ROUTER_SPAN_NAME_FALLBACK, addNonEnumerableProperty, debug, defineIntegration, getActiveSpan, getClient, getDefaultIsolationScope, getIsolationScope, hasSpanStreamingEnabled, startSpan } from "@sentry/core";
|
|
10
|
-
import { MIDDLEWARE, ROUTER } from "@sentry/conventions/op";
|
|
11
11
|
// src/integrations/koa/index.ts
|
|
12
12
|
const INTEGRATION_NAME = "Koa";
|
|
13
13
|
const ORIGIN = "auto.http.koa";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
+
import { _INTERNAL_skipAiProviderWrapping, defineIntegration, startInactiveSpan } from "@sentry/core";
|
|
2
3
|
import { ANTHROPIC_AI_INTEGRATION_NAME } from "../ai/anthropic-ai/constants.js";
|
|
3
4
|
import { GOOGLE_GENAI_INTEGRATION_NAME } from "../ai/google-genai/constants.js";
|
|
4
5
|
import { createLangChainCallbackHandler } from "../ai/langchain/index.js";
|
|
@@ -14,7 +15,6 @@ import { CHANNELS } from "../orchestrion/channels.js";
|
|
|
14
15
|
import { langchainEmbeddingsChannels, langchainModuleNames } from "../orchestrion/config/langchain.js";
|
|
15
16
|
import { bindTracingChannelToSpan } from "../tracing-channel.js";
|
|
16
17
|
import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
|
|
17
|
-
import { _INTERNAL_skipAiProviderWrapping, defineIntegration, startInactiveSpan } from "@sentry/core";
|
|
18
18
|
// src/integrations/langchain.ts
|
|
19
19
|
const INTEGRATION_NAME = LANGCHAIN_INTEGRATION_NAME;
|
|
20
20
|
const SKIPPED_PROVIDERS = [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
+
import { debug, defineIntegration, isObjectLike } from "@sentry/core";
|
|
2
3
|
import { createLangChainCallbackHandler } from "../ai/langchain/index.js";
|
|
3
4
|
import { instrumentCompiledGraph, isInsideManualLangGraphInstrumentation } from "../ai/langgraph/index.js";
|
|
4
5
|
import { LANGGRAPH_INTEGRATION_NAME } from "../ai/langgraph/constants.js";
|
|
@@ -7,7 +8,6 @@ import { DEBUG_BUILD } from "../debug-build.js";
|
|
|
7
8
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
8
9
|
import { langgraphModuleNames } from "../orchestrion/config/langgraph.js";
|
|
9
10
|
import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
|
|
10
|
-
import { debug, defineIntegration, isObjectLike } from "@sentry/core";
|
|
11
11
|
// src/integrations/langgraph.ts
|
|
12
12
|
const INTEGRATION_NAME = LANGGRAPH_INTEGRATION_NAME;
|
|
13
13
|
let insideCreateReactAgent = false;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
+
import { defineIntegration } from "@sentry/core";
|
|
2
3
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
3
4
|
import { bindTracingChannelToSpan } from "../tracing-channel.js";
|
|
4
5
|
import { lruMemoizerModuleNames } from "../orchestrion/config/lru-memoizer.js";
|
|
5
6
|
import { invokeOrchestrionInstrumentation } from "../orchestrion/instrumentation.js";
|
|
6
|
-
import { defineIntegration } from "@sentry/core";
|
|
7
7
|
// src/integrations/lru-memoizer.ts
|
|
8
8
|
const INTEGRATION_NAME = "LruMemoizer";
|
|
9
9
|
const _lruMemoizerIntegration = (() => {
|