apitally 0.25.7 → 1.0.0-alpha.1
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/README.md +191 -184
- package/dist/activation.cjs +371 -0
- package/dist/activation.cjs.map +1 -0
- package/dist/activation.d.cts +41 -0
- package/dist/activation.d.ts +41 -0
- package/dist/activation.js +357 -0
- package/dist/activation.js.map +1 -0
- package/dist/adonisjs/configure.cjs +88 -31
- package/dist/adonisjs/configure.cjs.map +1 -1
- package/dist/adonisjs/configure.d.cts +0 -4
- package/dist/adonisjs/configure.d.ts +0 -4
- package/dist/adonisjs/configure.js +85 -30
- package/dist/adonisjs/configure.js.map +1 -1
- package/dist/adonisjs/index.cjs +4 -23
- package/dist/adonisjs/index.cjs.map +1 -1
- package/dist/adonisjs/index.d.cts +3 -15
- package/dist/adonisjs/index.d.ts +3 -15
- package/dist/adonisjs/index.js +3 -20
- package/dist/adonisjs/index.js.map +1 -1
- package/dist/adonisjs/middleware.cjs +43 -109
- package/dist/adonisjs/middleware.cjs.map +1 -1
- package/dist/adonisjs/middleware.d.cts +1 -16
- package/dist/adonisjs/middleware.d.ts +1 -16
- package/dist/adonisjs/middleware.js +43 -110
- package/dist/adonisjs/middleware.js.map +1 -1
- package/dist/adonisjs/provider.cjs +19 -87
- package/dist/adonisjs/provider.cjs.map +1 -1
- package/dist/adonisjs/provider.d.cts +0 -22
- package/dist/adonisjs/provider.d.ts +0 -22
- package/dist/adonisjs/provider.js +19 -88
- package/dist/adonisjs/provider.js.map +1 -1
- package/dist/adonisjs/stubs/config/apitally.stub +11 -15
- package/dist/bodyCapture.cjs +128 -0
- package/dist/bodyCapture.cjs.map +1 -0
- package/dist/bodyCapture.d.cts +31 -0
- package/dist/bodyCapture.d.ts +31 -0
- package/dist/bodyCapture.js +101 -0
- package/dist/bodyCapture.js.map +1 -0
- package/dist/config.cjs +209 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +42 -0
- package/dist/config.d.ts +42 -0
- package/dist/config.js +174 -0
- package/dist/config.js.map +1 -0
- package/dist/consumer.cjs +98 -0
- package/dist/consumer.cjs.map +1 -0
- package/dist/consumer.d.cts +13 -0
- package/dist/consumer.d.ts +13 -0
- package/dist/consumer.js +78 -0
- package/dist/consumer.js.map +1 -0
- package/dist/context.cjs +68 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +29 -0
- package/dist/context.d.ts +29 -0
- package/dist/context.js +40 -0
- package/dist/context.js.map +1 -0
- package/dist/elysia/index.cjs +12 -13
- package/dist/elysia/index.cjs.map +1 -1
- package/dist/elysia/index.d.cts +7 -16
- package/dist/elysia/index.d.ts +7 -16
- package/dist/elysia/index.js +10 -2
- package/dist/elysia/index.js.map +1 -1
- package/dist/elysia/middleware.cjs +248 -0
- package/dist/elysia/middleware.cjs.map +1 -0
- package/dist/elysia/middleware.d.cts +13 -0
- package/dist/elysia/middleware.d.ts +13 -0
- package/dist/elysia/middleware.js +237 -0
- package/dist/elysia/middleware.js.map +1 -0
- package/dist/{loggers/index.cjs → elysia/routes.cjs} +16 -19
- package/dist/elysia/routes.cjs.map +1 -0
- package/dist/elysia/routes.d.cts +7 -0
- package/dist/elysia/routes.d.ts +7 -0
- package/dist/elysia/routes.js +14 -0
- package/dist/elysia/routes.js.map +1 -0
- package/dist/exceptions.cjs +75 -0
- package/dist/exceptions.cjs.map +1 -0
- package/dist/exceptions.d.cts +7 -0
- package/dist/exceptions.d.ts +7 -0
- package/dist/exceptions.js +49 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/exportSerialization.cjs +56 -0
- package/dist/exportSerialization.cjs.map +1 -0
- package/dist/exportSerialization.d.cts +7 -0
- package/dist/exportSerialization.d.ts +7 -0
- package/dist/exportSerialization.js +32 -0
- package/dist/exportSerialization.js.map +1 -0
- package/dist/exportWorker.cjs +305 -0
- package/dist/exportWorker.cjs.map +1 -0
- package/dist/exportWorker.d.cts +46 -0
- package/dist/exportWorker.d.ts +46 -0
- package/dist/exportWorker.js +279 -0
- package/dist/exportWorker.js.map +1 -0
- package/dist/express/index.cjs +9 -4
- package/dist/express/index.cjs.map +1 -1
- package/dist/express/index.d.cts +6 -10
- package/dist/express/index.d.ts +6 -10
- package/dist/express/index.js +8 -2
- package/dist/express/index.js.map +1 -1
- package/dist/express/install.cjs +45 -0
- package/dist/express/install.cjs.map +1 -0
- package/dist/express/install.d.cts +9 -0
- package/dist/express/install.d.ts +9 -0
- package/dist/express/install.js +21 -0
- package/dist/express/install.js.map +1 -0
- package/dist/express/middleware.cjs +80 -331
- package/dist/express/middleware.cjs.map +1 -1
- package/dist/express/middleware.d.cts +3 -21
- package/dist/express/middleware.d.ts +3 -21
- package/dist/express/middleware.js +81 -328
- package/dist/express/middleware.js.map +1 -1
- package/dist/express/register.cjs +20 -0
- package/dist/express/register.cjs.map +1 -0
- package/dist/express/register.d.cts +2 -0
- package/dist/express/register.d.ts +2 -0
- package/dist/express/register.js +19 -0
- package/dist/express/register.js.map +1 -0
- package/dist/express/routes.cjs +419 -0
- package/dist/express/routes.cjs.map +1 -0
- package/dist/express/routes.d.cts +14 -0
- package/dist/express/routes.d.ts +14 -0
- package/dist/express/routes.js +391 -0
- package/dist/express/routes.js.map +1 -0
- package/dist/fastify/index.cjs +10 -15
- package/dist/fastify/index.cjs.map +1 -1
- package/dist/fastify/index.d.cts +6 -11
- package/dist/fastify/index.d.ts +6 -11
- package/dist/fastify/index.js +9 -3
- package/dist/fastify/index.js.map +1 -1
- package/dist/{common/logging.cjs → fastify/install.cjs} +15 -16
- package/dist/fastify/install.cjs.map +1 -0
- package/dist/fastify/install.d.cts +9 -0
- package/dist/fastify/install.d.ts +9 -0
- package/dist/fastify/install.js +15 -0
- package/dist/fastify/install.js.map +1 -0
- package/dist/fastify/middleware.cjs +118 -0
- package/dist/fastify/middleware.cjs.map +1 -0
- package/dist/fastify/middleware.d.cts +7 -0
- package/dist/fastify/middleware.d.ts +7 -0
- package/dist/fastify/middleware.js +97 -0
- package/dist/fastify/middleware.js.map +1 -0
- package/dist/{common/paramValidation.cjs → fastify/routes.cjs} +15 -17
- package/dist/fastify/routes.cjs.map +1 -0
- package/dist/fastify/routes.d.cts +8 -0
- package/dist/fastify/routes.d.ts +8 -0
- package/dist/fastify/routes.js +14 -0
- package/dist/fastify/routes.js.map +1 -0
- package/dist/h3/index.cjs +28 -4
- package/dist/h3/index.cjs.map +1 -1
- package/dist/h3/index.d.cts +7 -10
- package/dist/h3/index.d.ts +7 -10
- package/dist/h3/index.js +26 -2
- package/dist/h3/index.js.map +1 -1
- package/dist/h3/middleware.cjs +204 -0
- package/dist/h3/middleware.cjs.map +1 -0
- package/dist/h3/middleware.d.cts +5 -0
- package/dist/h3/middleware.d.ts +5 -0
- package/dist/h3/middleware.js +188 -0
- package/dist/h3/middleware.js.map +1 -0
- package/dist/h3/routes.cjs +66 -0
- package/dist/h3/routes.cjs.map +1 -0
- package/dist/h3/routes.d.cts +8 -0
- package/dist/h3/routes.d.ts +8 -0
- package/dist/h3/routes.js +41 -0
- package/dist/h3/routes.js.map +1 -0
- package/dist/hapi/index.cjs +15 -14
- package/dist/hapi/index.cjs.map +1 -1
- package/dist/hapi/index.d.cts +7 -10
- package/dist/hapi/index.d.ts +7 -10
- package/dist/hapi/index.js +14 -3
- package/dist/hapi/index.js.map +1 -1
- package/dist/{loggers/hapi.cjs → hapi/install.cjs} +20 -26
- package/dist/hapi/install.cjs.map +1 -0
- package/dist/hapi/install.d.cts +7 -0
- package/dist/hapi/install.d.ts +7 -0
- package/dist/hapi/install.js +22 -0
- package/dist/hapi/install.js.map +1 -0
- package/dist/hapi/middleware.cjs +158 -0
- package/dist/hapi/middleware.cjs.map +1 -0
- package/dist/hapi/middleware.d.cts +5 -0
- package/dist/hapi/middleware.d.ts +5 -0
- package/dist/hapi/middleware.js +137 -0
- package/dist/hapi/middleware.js.map +1 -0
- package/dist/hapi/routes.cjs +37 -0
- package/dist/hapi/routes.cjs.map +1 -0
- package/dist/hapi/routes.d.cts +8 -0
- package/dist/hapi/routes.d.ts +8 -0
- package/dist/hapi/routes.js +12 -0
- package/dist/hapi/routes.js.map +1 -0
- package/dist/hono/index.cjs +13 -3
- package/dist/hono/index.cjs.map +1 -1
- package/dist/hono/index.d.cts +6 -10
- package/dist/hono/index.d.ts +6 -10
- package/dist/hono/index.js +13 -2
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/middleware.cjs +211 -127
- package/dist/hono/middleware.cjs.map +1 -1
- package/dist/hono/middleware.d.cts +3 -18
- package/dist/hono/middleware.d.ts +3 -18
- package/dist/hono/middleware.js +216 -125
- package/dist/hono/middleware.js.map +1 -1
- package/dist/hono/routes.cjs +74 -0
- package/dist/hono/routes.cjs.map +1 -0
- package/dist/hono/routes.d.cts +8 -0
- package/dist/hono/routes.d.ts +8 -0
- package/dist/hono/routes.js +49 -0
- package/dist/hono/routes.js.map +1 -0
- package/dist/index.cjs +108 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -1
- package/dist/koa/index.cjs +13 -3
- package/dist/koa/index.cjs.map +1 -1
- package/dist/koa/index.d.cts +6 -10
- package/dist/koa/index.d.ts +6 -10
- package/dist/koa/index.js +13 -2
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/middleware.cjs +75 -184
- package/dist/koa/middleware.cjs.map +1 -1
- package/dist/koa/middleware.d.cts +3 -13
- package/dist/koa/middleware.d.ts +3 -13
- package/dist/koa/middleware.js +78 -183
- package/dist/koa/middleware.js.map +1 -1
- package/dist/koa/routes.cjs +71 -0
- package/dist/koa/routes.cjs.map +1 -0
- package/dist/koa/routes.d.cts +8 -0
- package/dist/koa/routes.d.ts +8 -0
- package/dist/koa/routes.js +46 -0
- package/dist/koa/routes.js.map +1 -0
- package/dist/logCapture.cjs +410 -0
- package/dist/logCapture.cjs.map +1 -0
- package/dist/logCapture.d.cts +16 -0
- package/dist/logCapture.d.ts +16 -0
- package/dist/logCapture.js +383 -0
- package/dist/logCapture.js.map +1 -0
- package/dist/logRecordExporter.cjs +83 -0
- package/dist/logRecordExporter.cjs.map +1 -0
- package/dist/logRecordExporter.d.cts +14 -0
- package/dist/logRecordExporter.d.ts +14 -0
- package/dist/logRecordExporter.js +59 -0
- package/dist/logRecordExporter.js.map +1 -0
- package/dist/logRecordProcessor.cjs +120 -0
- package/dist/logRecordProcessor.cjs.map +1 -0
- package/dist/logRecordProcessor.d.cts +23 -0
- package/dist/logRecordProcessor.d.ts +23 -0
- package/dist/logRecordProcessor.js +96 -0
- package/dist/logRecordProcessor.js.map +1 -0
- package/dist/{otel/index.cjs → logRecordTruncation.cjs} +10 -7
- package/dist/logRecordTruncation.cjs.map +1 -0
- package/dist/logRecordTruncation.d.cts +6 -0
- package/dist/logRecordTruncation.d.ts +6 -0
- package/dist/logRecordTruncation.js +8 -0
- package/dist/logRecordTruncation.js.map +1 -0
- package/dist/logger.cjs +62 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +7 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +34 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics.cjs +171 -0
- package/dist/metrics.cjs.map +1 -0
- package/dist/metrics.d.cts +24 -0
- package/dist/metrics.d.ts +24 -0
- package/dist/metrics.js +153 -0
- package/dist/metrics.js.map +1 -0
- package/dist/nestjs/index.cjs +61 -71
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.d.cts +3 -11
- package/dist/nestjs/index.d.ts +3 -11
- package/dist/nestjs/index.js +61 -61
- package/dist/nestjs/index.js.map +1 -1
- package/dist/packageVersion.cjs +67 -0
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.cts +5 -0
- package/dist/packageVersion.d.ts +5 -0
- package/dist/packageVersion.js +39 -0
- package/dist/packageVersion.js.map +1 -0
- package/dist/providers.cjs +149 -0
- package/dist/providers.cjs.map +1 -0
- package/dist/providers.d.cts +15 -0
- package/dist/providers.d.ts +15 -0
- package/dist/providers.js +136 -0
- package/dist/providers.js.map +1 -0
- package/dist/redaction.cjs +116 -0
- package/dist/redaction.cjs.map +1 -0
- package/dist/redaction.d.cts +17 -0
- package/dist/redaction.d.ts +17 -0
- package/dist/redaction.js +98 -0
- package/dist/redaction.js.map +1 -0
- package/dist/{common/packageVersions.cjs → requestAttributes.cjs} +21 -19
- package/dist/requestAttributes.cjs.map +1 -0
- package/dist/requestAttributes.d.cts +8 -0
- package/dist/requestAttributes.d.ts +8 -0
- package/dist/requestAttributes.js +22 -0
- package/dist/requestAttributes.js.map +1 -0
- package/dist/requestObservation.cjs +228 -0
- package/dist/requestObservation.cjs.map +1 -0
- package/dist/requestObservation.d.cts +60 -0
- package/dist/requestObservation.d.ts +60 -0
- package/dist/requestObservation.js +208 -0
- package/dist/requestObservation.js.map +1 -0
- package/dist/requestObservationNode.cjs +193 -0
- package/dist/requestObservationNode.cjs.map +1 -0
- package/dist/requestObservationNode.d.cts +29 -0
- package/dist/requestObservationNode.d.ts +29 -0
- package/dist/requestObservationNode.js +170 -0
- package/dist/requestObservationNode.js.map +1 -0
- package/dist/requestObservationWeb.cjs +202 -0
- package/dist/requestObservationWeb.cjs.map +1 -0
- package/dist/requestObservationWeb.d.cts +32 -0
- package/dist/requestObservationWeb.d.ts +32 -0
- package/dist/requestObservationWeb.js +182 -0
- package/dist/requestObservationWeb.js.map +1 -0
- package/dist/sentry.cjs +103 -0
- package/dist/sentry.cjs.map +1 -0
- package/dist/sentry.d.cts +3 -0
- package/dist/sentry.d.ts +3 -0
- package/dist/sentry.js +79 -0
- package/dist/sentry.js.map +1 -0
- package/dist/spanExporter.cjs +218 -0
- package/dist/spanExporter.cjs.map +1 -0
- package/dist/spanExporter.d.cts +33 -0
- package/dist/spanExporter.d.ts +33 -0
- package/dist/spanExporter.js +194 -0
- package/dist/spanExporter.js.map +1 -0
- package/dist/spanProcessor.cjs +523 -0
- package/dist/spanProcessor.cjs.map +1 -0
- package/dist/spanProcessor.d.cts +67 -0
- package/dist/spanProcessor.d.ts +67 -0
- package/dist/spanProcessor.js +501 -0
- package/dist/spanProcessor.js.map +1 -0
- package/dist/spool.cjs +314 -0
- package/dist/spool.cjs.map +1 -0
- package/dist/spool.d.cts +49 -0
- package/dist/spool.d.ts +49 -0
- package/dist/spool.js +297 -0
- package/dist/spool.js.map +1 -0
- package/dist/startup.cjs +93 -0
- package/dist/startup.cjs.map +1 -0
- package/dist/startup.d.cts +15 -0
- package/dist/startup.d.ts +15 -0
- package/dist/startup.js +68 -0
- package/dist/startup.js.map +1 -0
- package/dist/tracing.cjs +116 -0
- package/dist/tracing.cjs.map +1 -0
- package/dist/tracing.d.cts +5 -0
- package/dist/tracing.d.ts +5 -0
- package/dist/tracing.js +96 -0
- package/dist/tracing.js.map +1 -0
- package/package.json +113 -155
- package/dist/common/client.cjs +0 -335
- package/dist/common/client.cjs.map +0 -1
- package/dist/common/client.d.cts +0 -50
- package/dist/common/client.d.ts +0 -50
- package/dist/common/client.js +0 -302
- package/dist/common/client.js.map +0 -1
- package/dist/common/consumerRegistry.cjs +0 -84
- package/dist/common/consumerRegistry.cjs.map +0 -1
- package/dist/common/consumerRegistry.d.cts +0 -20
- package/dist/common/consumerRegistry.d.ts +0 -20
- package/dist/common/consumerRegistry.js +0 -61
- package/dist/common/consumerRegistry.js.map +0 -1
- package/dist/common/headers.cjs +0 -55
- package/dist/common/headers.cjs.map +0 -1
- package/dist/common/headers.d.cts +0 -6
- package/dist/common/headers.d.ts +0 -6
- package/dist/common/headers.js +0 -31
- package/dist/common/headers.js.map +0 -1
- package/dist/common/instance.cjs +0 -158
- package/dist/common/instance.cjs.map +0 -1
- package/dist/common/instance.d.cts +0 -4
- package/dist/common/instance.d.ts +0 -4
- package/dist/common/instance.js +0 -134
- package/dist/common/instance.js.map +0 -1
- package/dist/common/logging.cjs.map +0 -1
- package/dist/common/logging.d.cts +0 -11
- package/dist/common/logging.d.ts +0 -11
- package/dist/common/logging.js +0 -17
- package/dist/common/logging.js.map +0 -1
- package/dist/common/packageVersions.cjs.map +0 -1
- package/dist/common/packageVersions.d.cts +0 -3
- package/dist/common/packageVersions.d.ts +0 -3
- package/dist/common/packageVersions.js +0 -21
- package/dist/common/packageVersions.js.map +0 -1
- package/dist/common/paramValidation.cjs.map +0 -1
- package/dist/common/paramValidation.d.cts +0 -4
- package/dist/common/paramValidation.d.ts +0 -4
- package/dist/common/paramValidation.js +0 -17
- package/dist/common/paramValidation.js.map +0 -1
- package/dist/common/requestCounter.cjs +0 -109
- package/dist/common/requestCounter.cjs.map +0 -1
- package/dist/common/requestCounter.d.cts +0 -24
- package/dist/common/requestCounter.d.ts +0 -24
- package/dist/common/requestCounter.js +0 -90
- package/dist/common/requestCounter.js.map +0 -1
- package/dist/common/requestLogger.cjs +0 -541
- package/dist/common/requestLogger.cjs.map +0 -1
- package/dist/common/requestLogger.d.cts +0 -85
- package/dist/common/requestLogger.d.ts +0 -85
- package/dist/common/requestLogger.js +0 -507
- package/dist/common/requestLogger.js.map +0 -1
- package/dist/common/resources.cjs +0 -49
- package/dist/common/resources.cjs.map +0 -1
- package/dist/common/resources.d.cts +0 -6
- package/dist/common/resources.d.ts +0 -6
- package/dist/common/resources.js +0 -26
- package/dist/common/resources.js.map +0 -1
- package/dist/common/response.cjs +0 -104
- package/dist/common/response.cjs.map +0 -1
- package/dist/common/response.d.cts +0 -15
- package/dist/common/response.d.ts +0 -15
- package/dist/common/response.js +0 -80
- package/dist/common/response.js.map +0 -1
- package/dist/common/sentry.cjs +0 -56
- package/dist/common/sentry.cjs.map +0 -1
- package/dist/common/sentry.d.cts +0 -6
- package/dist/common/sentry.d.ts +0 -6
- package/dist/common/sentry.js +0 -23
- package/dist/common/sentry.js.map +0 -1
- package/dist/common/serverErrorCounter.cjs +0 -121
- package/dist/common/serverErrorCounter.cjs.map +0 -1
- package/dist/common/serverErrorCounter.d.cts +0 -23
- package/dist/common/serverErrorCounter.d.ts +0 -23
- package/dist/common/serverErrorCounter.js +0 -97
- package/dist/common/serverErrorCounter.js.map +0 -1
- package/dist/common/spanCollector.cjs +0 -199
- package/dist/common/spanCollector.cjs.map +0 -1
- package/dist/common/spanCollector.d.cts +0 -45
- package/dist/common/spanCollector.d.ts +0 -45
- package/dist/common/spanCollector.js +0 -176
- package/dist/common/spanCollector.js.map +0 -1
- package/dist/common/tempGzipFile.cjs +0 -125
- package/dist/common/tempGzipFile.cjs.map +0 -1
- package/dist/common/tempGzipFile.d.cts +0 -19
- package/dist/common/tempGzipFile.d.ts +0 -19
- package/dist/common/tempGzipFile.js +0 -102
- package/dist/common/tempGzipFile.js.map +0 -1
- package/dist/common/types.cjs +0 -17
- package/dist/common/types.cjs.map +0 -1
- package/dist/common/types.d.cts +0 -95
- package/dist/common/types.d.ts +0 -95
- package/dist/common/types.js +0 -1
- package/dist/common/types.js.map +0 -1
- package/dist/common/validationErrorCounter.cjs +0 -74
- package/dist/common/validationErrorCounter.cjs.map +0 -1
- package/dist/common/validationErrorCounter.d.cts +0 -20
- package/dist/common/validationErrorCounter.d.ts +0 -20
- package/dist/common/validationErrorCounter.js +0 -55
- package/dist/common/validationErrorCounter.js.map +0 -1
- package/dist/elysia/plugin.cjs +0 -237
- package/dist/elysia/plugin.cjs.map +0 -1
- package/dist/elysia/plugin.d.cts +0 -70
- package/dist/elysia/plugin.d.ts +0 -70
- package/dist/elysia/plugin.js +0 -218
- package/dist/elysia/plugin.js.map +0 -1
- package/dist/elysia/utils.cjs +0 -77
- package/dist/elysia/utils.cjs.map +0 -1
- package/dist/elysia/utils.d.cts +0 -14
- package/dist/elysia/utils.d.ts +0 -14
- package/dist/elysia/utils.js +0 -54
- package/dist/elysia/utils.js.map +0 -1
- package/dist/express/utils.cjs +0 -217
- package/dist/express/utils.cjs.map +0 -1
- package/dist/express/utils.d.cts +0 -37
- package/dist/express/utils.d.ts +0 -37
- package/dist/express/utils.js +0 -189
- package/dist/express/utils.js.map +0 -1
- package/dist/fastify/plugin.cjs +0 -316
- package/dist/fastify/plugin.cjs.map +0 -1
- package/dist/fastify/plugin.d.cts +0 -34
- package/dist/fastify/plugin.d.ts +0 -34
- package/dist/fastify/plugin.js +0 -282
- package/dist/fastify/plugin.js.map +0 -1
- package/dist/h3/plugin.cjs +0 -183
- package/dist/h3/plugin.cjs.map +0 -1
- package/dist/h3/plugin.d.cts +0 -27
- package/dist/h3/plugin.d.ts +0 -27
- package/dist/h3/plugin.js +0 -159
- package/dist/h3/plugin.js.map +0 -1
- package/dist/h3/utils.cjs +0 -77
- package/dist/h3/utils.cjs.map +0 -1
- package/dist/h3/utils.d.cts +0 -14
- package/dist/h3/utils.d.ts +0 -14
- package/dist/h3/utils.js +0 -54
- package/dist/h3/utils.js.map +0 -1
- package/dist/hapi/plugin.cjs +0 -210
- package/dist/hapi/plugin.cjs.map +0 -1
- package/dist/hapi/plugin.d.cts +0 -40
- package/dist/hapi/plugin.d.ts +0 -40
- package/dist/hapi/plugin.js +0 -187
- package/dist/hapi/plugin.js.map +0 -1
- package/dist/hapi/utils.cjs +0 -77
- package/dist/hapi/utils.cjs.map +0 -1
- package/dist/hapi/utils.d.cts +0 -16
- package/dist/hapi/utils.d.ts +0 -16
- package/dist/hapi/utils.js +0 -53
- package/dist/hapi/utils.js.map +0 -1
- package/dist/hono/utils.cjs +0 -113
- package/dist/hono/utils.cjs.map +0 -1
- package/dist/hono/utils.d.cts +0 -16
- package/dist/hono/utils.d.ts +0 -16
- package/dist/hono/utils.js +0 -88
- package/dist/hono/utils.js.map +0 -1
- package/dist/loggers/console.cjs +0 -67
- package/dist/loggers/console.cjs.map +0 -1
- package/dist/loggers/console.d.cts +0 -11
- package/dist/loggers/console.d.ts +0 -11
- package/dist/loggers/console.js +0 -44
- package/dist/loggers/console.js.map +0 -1
- package/dist/loggers/hapi.cjs.map +0 -1
- package/dist/loggers/hapi.d.cts +0 -12
- package/dist/loggers/hapi.d.ts +0 -12
- package/dist/loggers/hapi.js +0 -29
- package/dist/loggers/hapi.js.map +0 -1
- package/dist/loggers/index.cjs.map +0 -1
- package/dist/loggers/index.d.cts +0 -13
- package/dist/loggers/index.d.ts +0 -13
- package/dist/loggers/index.js +0 -13
- package/dist/loggers/index.js.map +0 -1
- package/dist/loggers/nestjs.cjs +0 -104
- package/dist/loggers/nestjs.cjs.map +0 -1
- package/dist/loggers/nestjs.d.cts +0 -11
- package/dist/loggers/nestjs.d.ts +0 -11
- package/dist/loggers/nestjs.js +0 -71
- package/dist/loggers/nestjs.js.map +0 -1
- package/dist/loggers/pino.cjs +0 -152
- package/dist/loggers/pino.cjs.map +0 -1
- package/dist/loggers/pino.d.cts +0 -11
- package/dist/loggers/pino.d.ts +0 -11
- package/dist/loggers/pino.js +0 -119
- package/dist/loggers/pino.js.map +0 -1
- package/dist/loggers/utils.cjs +0 -64
- package/dist/loggers/utils.cjs.map +0 -1
- package/dist/loggers/utils.d.cts +0 -6
- package/dist/loggers/utils.d.ts +0 -6
- package/dist/loggers/utils.js +0 -40
- package/dist/loggers/utils.js.map +0 -1
- package/dist/loggers/winston.cjs +0 -101
- package/dist/loggers/winston.cjs.map +0 -1
- package/dist/loggers/winston.d.cts +0 -11
- package/dist/loggers/winston.d.ts +0 -11
- package/dist/loggers/winston.js +0 -68
- package/dist/loggers/winston.js.map +0 -1
- package/dist/otel/index.cjs.map +0 -1
- package/dist/otel/index.d.cts +0 -2
- package/dist/otel/index.d.ts +0 -2
- package/dist/otel/index.js +0 -5
- package/dist/otel/index.js.map +0 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
context,
|
|
3
|
+
propagation,
|
|
4
|
+
ROOT_CONTEXT
|
|
5
|
+
} from "@opentelemetry/api";
|
|
6
|
+
import { BodyCapture } from "./bodyCapture.js";
|
|
7
|
+
import { getConfig } from "./config.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveHttpRequestStartAttributes,
|
|
10
|
+
startRequestObservation
|
|
11
|
+
} from "./requestObservation.js";
|
|
12
|
+
const READ_TIMEOUT_MILLIS = 5e3;
|
|
13
|
+
const WEB_HEADERS_GETTER = {
|
|
14
|
+
get: (carrier, key) => carrier.get(key) ?? void 0,
|
|
15
|
+
keys: (carrier) => [...carrier.keys()]
|
|
16
|
+
};
|
|
17
|
+
function isWebSocketUpgrade(request) {
|
|
18
|
+
return request.headers.get("upgrade")?.toLowerCase() === "websocket";
|
|
19
|
+
}
|
|
20
|
+
function startWebRequestObservation(options) {
|
|
21
|
+
const { request } = options;
|
|
22
|
+
const startTimeMillis = performance.now();
|
|
23
|
+
const method = request.method.toUpperCase();
|
|
24
|
+
const requestBodyCapture = new BodyCapture({
|
|
25
|
+
captureBody: getConfig().captureRequestBody,
|
|
26
|
+
contentType: request.headers.get("content-type"),
|
|
27
|
+
contentLength: request.headers.get("content-length"),
|
|
28
|
+
transferEncoding: request.headers.get("transfer-encoding")
|
|
29
|
+
});
|
|
30
|
+
const attributeInput = {
|
|
31
|
+
method,
|
|
32
|
+
clientAddress: options.clientAddress,
|
|
33
|
+
userAgent: request.headers.get("user-agent") ?? void 0,
|
|
34
|
+
requestBodySize: requestBodyCapture.size
|
|
35
|
+
};
|
|
36
|
+
let startAttributes = resolveHttpRequestStartAttributes(attributeInput);
|
|
37
|
+
try {
|
|
38
|
+
const url = new URL(request.url);
|
|
39
|
+
startAttributes = resolveHttpRequestStartAttributes({
|
|
40
|
+
...attributeInput,
|
|
41
|
+
path: url.pathname,
|
|
42
|
+
query: url.search.slice(1) || void 0,
|
|
43
|
+
scheme: url.protocol.replace(/:$/, ""),
|
|
44
|
+
serverAddress: url.hostname,
|
|
45
|
+
fullUrl: request.url
|
|
46
|
+
});
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
const { requestRecord, requestContext, spanHandle, rpcMetadata } = startRequestObservation({
|
|
50
|
+
activeContext: context.active(),
|
|
51
|
+
extractedContext: propagation.extract(ROOT_CONTEXT, request.headers, WEB_HEADERS_GETTER),
|
|
52
|
+
tracerName: options.tracerName,
|
|
53
|
+
method,
|
|
54
|
+
startAttributes,
|
|
55
|
+
requestBodyCapture
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
observation: {
|
|
59
|
+
requestRecord,
|
|
60
|
+
spanHandle,
|
|
61
|
+
rpcMetadata,
|
|
62
|
+
requestBodyCapture,
|
|
63
|
+
requestHeaders: request.headers,
|
|
64
|
+
startTimeMillis,
|
|
65
|
+
method
|
|
66
|
+
},
|
|
67
|
+
requestContext
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function captureWebRequestBody(request, bodyCapture, readTimeoutMillis = READ_TIMEOUT_MILLIS) {
|
|
71
|
+
if (!request.body || !bodyCapture.isBuffering) {
|
|
72
|
+
return Promise.resolve();
|
|
73
|
+
}
|
|
74
|
+
let reader;
|
|
75
|
+
try {
|
|
76
|
+
reader = request.clone().body?.getReader();
|
|
77
|
+
} catch {
|
|
78
|
+
return Promise.resolve();
|
|
79
|
+
}
|
|
80
|
+
if (!reader) {
|
|
81
|
+
return Promise.resolve();
|
|
82
|
+
}
|
|
83
|
+
let isStopped = false;
|
|
84
|
+
const readPromise = (async () => {
|
|
85
|
+
try {
|
|
86
|
+
while (true) {
|
|
87
|
+
const { done, value } = await reader.read();
|
|
88
|
+
if (isStopped) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (done) {
|
|
92
|
+
bodyCapture.markComplete();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
bodyCapture.addChunk(value);
|
|
96
|
+
if (!bodyCapture.isBuffering) {
|
|
97
|
+
cancelReader(reader);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
})();
|
|
104
|
+
let readTimeout;
|
|
105
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
106
|
+
readTimeout = setTimeout(() => {
|
|
107
|
+
isStopped = true;
|
|
108
|
+
bodyCapture.stopBuffering();
|
|
109
|
+
cancelReader(reader);
|
|
110
|
+
resolve();
|
|
111
|
+
}, readTimeoutMillis);
|
|
112
|
+
readTimeout.unref();
|
|
113
|
+
});
|
|
114
|
+
return Promise.race([readPromise, timeoutPromise]).finally(() => clearTimeout(readTimeout));
|
|
115
|
+
}
|
|
116
|
+
function captureWebResponse(response, shouldCaptureBody, readTimeoutMillis = READ_TIMEOUT_MILLIS) {
|
|
117
|
+
const bodyCapture = new BodyCapture({
|
|
118
|
+
captureBody: shouldCaptureBody,
|
|
119
|
+
contentType: response.headers.get("content-type"),
|
|
120
|
+
contentLength: response.headers.get("content-length"),
|
|
121
|
+
transferEncoding: response.headers.get("transfer-encoding")
|
|
122
|
+
});
|
|
123
|
+
if (!response.body) {
|
|
124
|
+
bodyCapture.markComplete();
|
|
125
|
+
return {
|
|
126
|
+
response,
|
|
127
|
+
completion: Promise.resolve({
|
|
128
|
+
body: bodyCapture.body,
|
|
129
|
+
size: bodyCapture.size,
|
|
130
|
+
completedAtMillis: performance.now()
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
let readStarted = false;
|
|
135
|
+
const { readable, writable } = new TransformStream({
|
|
136
|
+
transform: (chunk, controller) => {
|
|
137
|
+
readStarted = true;
|
|
138
|
+
bodyCapture.addChunk(chunk);
|
|
139
|
+
controller.enqueue(chunk);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
const pipePromise = response.body.pipeTo(writable).then(
|
|
143
|
+
() => {
|
|
144
|
+
const completedAtMillis = performance.now();
|
|
145
|
+
bodyCapture.markComplete();
|
|
146
|
+
return { body: bodyCapture.body, size: bodyCapture.size, completedAtMillis };
|
|
147
|
+
},
|
|
148
|
+
() => ({ completedAtMillis: performance.now() })
|
|
149
|
+
);
|
|
150
|
+
let readTimeout;
|
|
151
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
152
|
+
readTimeout = setTimeout(() => {
|
|
153
|
+
if (!readStarted) {
|
|
154
|
+
resolve({ completedAtMillis: performance.now() });
|
|
155
|
+
}
|
|
156
|
+
}, readTimeoutMillis);
|
|
157
|
+
readTimeout.unref();
|
|
158
|
+
});
|
|
159
|
+
const capturedResponse = new Response(readable, {
|
|
160
|
+
status: response.status,
|
|
161
|
+
statusText: response.statusText,
|
|
162
|
+
headers: response.headers
|
|
163
|
+
});
|
|
164
|
+
const completion = Promise.race([pipePromise, timeoutPromise]).finally(
|
|
165
|
+
() => clearTimeout(readTimeout)
|
|
166
|
+
);
|
|
167
|
+
return { response: capturedResponse, completion };
|
|
168
|
+
}
|
|
169
|
+
function cancelReader(reader) {
|
|
170
|
+
try {
|
|
171
|
+
reader.cancel().catch(() => {
|
|
172
|
+
});
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
captureWebRequestBody,
|
|
178
|
+
captureWebResponse,
|
|
179
|
+
isWebSocketUpgrade,
|
|
180
|
+
startWebRequestObservation
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=requestObservationWeb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/requestObservationWeb.ts"],"sourcesContent":["import {\n type Context,\n context,\n propagation,\n ROOT_CONTEXT,\n type TextMapGetter,\n} from \"@opentelemetry/api\";\nimport { BodyCapture, type CapturedBody } from \"./bodyCapture.js\";\nimport { getConfig } from \"./config.js\";\nimport {\n type RequestObservation,\n resolveHttpRequestStartAttributes,\n startRequestObservation,\n} from \"./requestObservation.js\";\n\nconst READ_TIMEOUT_MILLIS = 5_000;\n\nconst WEB_HEADERS_GETTER: TextMapGetter<Headers> = {\n get: (carrier, key) => carrier.get(key) ?? undefined,\n keys: (carrier) => [...carrier.keys()],\n};\n\nexport interface StartWebRequestObservationOptions {\n request: Request;\n tracerName: string;\n clientAddress?: string;\n}\n\nexport function isWebSocketUpgrade(request: Request): boolean {\n return request.headers.get(\"upgrade\")?.toLowerCase() === \"websocket\";\n}\n\nexport interface WebRequestObservation extends RequestObservation {\n requestBodyCapture: BodyCapture;\n requestHeaders: Headers;\n}\n\nexport interface StartedWebRequestObservation {\n observation: WebRequestObservation;\n requestContext: Context;\n}\n\nexport function startWebRequestObservation(\n options: StartWebRequestObservationOptions,\n): StartedWebRequestObservation {\n const { request } = options;\n const startTimeMillis = performance.now();\n const method = request.method.toUpperCase();\n const requestBodyCapture = new BodyCapture({\n captureBody: getConfig().captureRequestBody,\n contentType: request.headers.get(\"content-type\"),\n contentLength: request.headers.get(\"content-length\"),\n transferEncoding: request.headers.get(\"transfer-encoding\"),\n });\n const attributeInput = {\n method,\n clientAddress: options.clientAddress,\n userAgent: request.headers.get(\"user-agent\") ?? undefined,\n requestBodySize: requestBodyCapture.size,\n };\n let startAttributes = resolveHttpRequestStartAttributes(attributeInput);\n try {\n const url = new URL(request.url);\n startAttributes = resolveHttpRequestStartAttributes({\n ...attributeInput,\n path: url.pathname,\n query: url.search.slice(1) || undefined,\n scheme: url.protocol.replace(/:$/, \"\"),\n serverAddress: url.hostname,\n fullUrl: request.url,\n });\n } catch {\n // An unparseable request URL leaves only attributes from other request metadata.\n }\n const { requestRecord, requestContext, spanHandle, rpcMetadata } = startRequestObservation({\n activeContext: context.active(),\n extractedContext: propagation.extract(ROOT_CONTEXT, request.headers, WEB_HEADERS_GETTER),\n tracerName: options.tracerName,\n method,\n startAttributes,\n requestBodyCapture,\n });\n return {\n observation: {\n requestRecord,\n spanHandle,\n rpcMetadata,\n requestBodyCapture,\n requestHeaders: request.headers,\n startTimeMillis,\n method,\n },\n requestContext,\n };\n}\n\nexport function captureWebRequestBody(\n request: Request,\n bodyCapture: BodyCapture,\n readTimeoutMillis: number = READ_TIMEOUT_MILLIS,\n): Promise<void> {\n if (!request.body || !bodyCapture.isBuffering) {\n return Promise.resolve();\n }\n let reader: ReadableStreamDefaultReader<Uint8Array> | undefined;\n try {\n reader = request.clone().body?.getReader();\n } catch {\n return Promise.resolve();\n }\n if (!reader) {\n return Promise.resolve();\n }\n let isStopped = false;\n const readPromise = (async () => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (isStopped) {\n return;\n }\n if (done) {\n bodyCapture.markComplete();\n return;\n }\n bodyCapture.addChunk(value);\n if (!bodyCapture.isBuffering) {\n cancelReader(reader);\n return;\n }\n }\n } catch {\n // A partial body is intentionally unavailable when the clone cannot be read.\n }\n })();\n let readTimeout: NodeJS.Timeout | undefined;\n const timeoutPromise = new Promise<void>((resolve) => {\n readTimeout = setTimeout(() => {\n isStopped = true;\n bodyCapture.stopBuffering();\n cancelReader(reader);\n resolve();\n }, readTimeoutMillis);\n readTimeout.unref();\n });\n return Promise.race([readPromise, timeoutPromise]).finally(() => clearTimeout(readTimeout));\n}\n\nexport interface WebResponseCompletion extends CapturedBody {\n completedAtMillis: number;\n}\n\nexport interface CapturedWebResponse {\n response: Response;\n completion: Promise<WebResponseCompletion>;\n}\n\n// The response is teed so capture does not consume or delay the application's\n// copy. Observation ends on completion, stream failure, or read timeout.\nexport function captureWebResponse(\n response: Response,\n shouldCaptureBody: boolean,\n readTimeoutMillis: number = READ_TIMEOUT_MILLIS,\n): CapturedWebResponse {\n const bodyCapture = new BodyCapture({\n captureBody: shouldCaptureBody,\n contentType: response.headers.get(\"content-type\"),\n contentLength: response.headers.get(\"content-length\"),\n transferEncoding: response.headers.get(\"transfer-encoding\"),\n });\n if (!response.body) {\n bodyCapture.markComplete();\n return {\n response,\n completion: Promise.resolve({\n body: bodyCapture.body,\n size: bodyCapture.size,\n completedAtMillis: performance.now(),\n }),\n };\n }\n let readStarted = false;\n const { readable, writable } = new TransformStream<Uint8Array, Uint8Array>({\n transform: (chunk, controller) => {\n readStarted = true;\n bodyCapture.addChunk(chunk);\n controller.enqueue(chunk);\n },\n });\n const pipePromise = response.body.pipeTo(writable).then(\n () => {\n const completedAtMillis = performance.now();\n bodyCapture.markComplete();\n return { body: bodyCapture.body, size: bodyCapture.size, completedAtMillis };\n },\n () => ({ completedAtMillis: performance.now() }),\n );\n let readTimeout: NodeJS.Timeout | undefined;\n const timeoutPromise = new Promise<WebResponseCompletion>((resolve) => {\n readTimeout = setTimeout(() => {\n if (!readStarted) {\n resolve({ completedAtMillis: performance.now() });\n }\n }, readTimeoutMillis);\n readTimeout.unref();\n });\n const capturedResponse = new Response(readable, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n const completion = Promise.race([pipePromise, timeoutPromise]).finally(() =>\n clearTimeout(readTimeout),\n );\n return { response: capturedResponse, completion };\n}\n\nfunction cancelReader(reader: ReadableStreamDefaultReader<Uint8Array>): void {\n try {\n reader.cancel().catch(() => {});\n } catch {\n // Cancellation is best-effort after capture has already stopped.\n }\n}\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,mBAAsC;AAC/C,SAAS,iBAAiB;AAC1B;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAEP,MAAM,sBAAsB;AAE5B,MAAM,qBAA6C;AAAA,EACjD,KAAK,CAAC,SAAS,QAAQ,QAAQ,IAAI,GAAG,KAAK;AAAA,EAC3C,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,KAAK,CAAC;AACvC;AAQO,SAAS,mBAAmB,SAA2B;AAC5D,SAAO,QAAQ,QAAQ,IAAI,SAAS,GAAG,YAAY,MAAM;AAC3D;AAYO,SAAS,2BACd,SAC8B;AAC9B,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,kBAAkB,YAAY,IAAI;AACxC,QAAM,SAAS,QAAQ,OAAO,YAAY;AAC1C,QAAM,qBAAqB,IAAI,YAAY;AAAA,IACzC,aAAa,UAAU,EAAE;AAAA,IACzB,aAAa,QAAQ,QAAQ,IAAI,cAAc;AAAA,IAC/C,eAAe,QAAQ,QAAQ,IAAI,gBAAgB;AAAA,IACnD,kBAAkB,QAAQ,QAAQ,IAAI,mBAAmB;AAAA,EAC3D,CAAC;AACD,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA,eAAe,QAAQ;AAAA,IACvB,WAAW,QAA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c,SAAS,KAAK,OAAO,QAAQ,EAAE;AAAA,IACjD,MAAM;AACJ,YAAM,oBAAoB,YAAY,IAAI;AAC1C,kBAAY,aAAa;AACzB,aAAO,EAAE,MAAM,YAAY,MAAM,MAAM,YAAY,MAAM,kBAAkB;AAAA,IAC7E;AAAA,IACA,OAAO,EAAE,mBAAmB,YAAY,IAAI,EAAE;AAAA,EAChD;AACA,MAAI;AACJ,QAAM,iBAAiB,IAAI,QAA+B,CAAC,YAAY;AACrE,kBAAc,WAAW,MAAM;AAC7B,UAAI,CAAC,aAAa;AAChB,gBAAQ,EAAE,mBAAmB,YAAY,IAAI,EAAE,CAAC;AAAA,MAClD;AAAA,IACF,GAAG,iBAAiB;AACpB,gBAAY,MAAM;AAAA,EACpB,CAAC;AACD,QAAM,mBAAmB,IAAI,SAAS,UAAU;AAAA,IAC9C,QAAQ,SAAS;AAAA,IACjB,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,EACpB,CAAC;AACD,QAAM,aAAa,QAAQ,KAAK,CAAC,aAAa,cAAc,CAAC,EAAE;AAAA,IAAQ,MACrE,aAAa,WAAW;AAAA,EAC1B;AACA,SAAO,EAAE,UAAU,kBAAkB,WAAW;AAClD;AAEA,SAAS,aAAa,QAAuD;AAC3E,MAAI;AACF,WAAO,OAAO,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EAChC,QAAQ;AAAA,EAER;AACF;","names":[]}
|
package/dist/sentry.cjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var sentry_exports = {};
|
|
20
|
+
__export(sentry_exports, {
|
|
21
|
+
installSentryEventIdRecording: () => installSentryEventIdRecording
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(sentry_exports);
|
|
24
|
+
var import_node_module = require("node:module");
|
|
25
|
+
var import_context = require('./context.cjs');
|
|
26
|
+
var import_logger = require('./logger.cjs');
|
|
27
|
+
var import_packageVersion = require('./packageVersion.cjs');
|
|
28
|
+
var import_requestAttributes = require('./requestAttributes.cjs');
|
|
29
|
+
function installSentryEventIdRecording() {
|
|
30
|
+
try {
|
|
31
|
+
const client = getClientThroughPeerResolution() ?? getClientFromGlobalCarrier();
|
|
32
|
+
if (!client) {
|
|
33
|
+
(0, import_logger.logDebug)("No Sentry client was detected");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
client.on("preprocessEvent", (event) => {
|
|
37
|
+
try {
|
|
38
|
+
if (typeof event.event_id !== "string" || !event.exception?.values?.length) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
(0, import_requestAttributes.writeRequestAttribute)(
|
|
42
|
+
(0, import_context.getServerSpan)(),
|
|
43
|
+
(0, import_context.getRequestRecord)(),
|
|
44
|
+
"apitally.exception.sentry_event_id",
|
|
45
|
+
event.event_id
|
|
46
|
+
);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
(0, import_logger.logDebug)(`Error writing the Sentry event id: ${String(error)}`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
(0, import_logger.logDebug)(`Error setting up the Sentry integration: ${String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function getClientThroughPeerResolution() {
|
|
56
|
+
try {
|
|
57
|
+
const entryPath = (0, import_packageVersion.resolvePackageEntryPath)("@sentry/node");
|
|
58
|
+
const sentry = (0, import_node_module.createRequire)(entryPath)(entryPath);
|
|
59
|
+
return typeof sentry.getClient === "function" ? asSentryClient(sentry.getClient()) : void 0;
|
|
60
|
+
} catch {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getClientFromGlobalCarrier() {
|
|
65
|
+
const carrier = globalThis.__SENTRY__;
|
|
66
|
+
if (!isRecord(carrier)) {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
const hub = carrier.hub;
|
|
70
|
+
if (isRecord(hub) && typeof hub.getClient === "function") {
|
|
71
|
+
return asSentryClient(hub.getClient());
|
|
72
|
+
}
|
|
73
|
+
const versioned = typeof carrier.version === "string" ? carrier[carrier.version] : void 0;
|
|
74
|
+
if (!isRecord(versioned)) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
const acs = versioned.acs;
|
|
78
|
+
if (isRecord(acs) && typeof acs.getCurrentScope === "function") {
|
|
79
|
+
const scope = acs.getCurrentScope();
|
|
80
|
+
if (isRecord(scope) && typeof scope.getClient === "function") {
|
|
81
|
+
const client = asSentryClient(scope.getClient());
|
|
82
|
+
if (client) {
|
|
83
|
+
return client;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const defaultScope = versioned.defaultCurrentScope;
|
|
88
|
+
if (isRecord(defaultScope) && typeof defaultScope.getClient === "function") {
|
|
89
|
+
return asSentryClient(defaultScope.getClient());
|
|
90
|
+
}
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
function asSentryClient(value) {
|
|
94
|
+
return isRecord(value) && typeof value.on === "function" ? value : void 0;
|
|
95
|
+
}
|
|
96
|
+
function isRecord(value) {
|
|
97
|
+
return typeof value === "object" && value !== null;
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
installSentryEventIdRecording
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=sentry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sentry.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { getRequestRecord, getServerSpan } from \"./context.js\";\nimport { logDebug } from \"./logger.js\";\nimport { resolvePackageEntryPath } from \"./packageVersion.js\";\nimport { writeRequestAttribute } from \"./requestAttributes.js\";\n\n// Minimal structural types: @sentry/node is an optional peer that is resolved\n// at runtime and never imported.\ninterface SentryEvent {\n event_id?: string;\n exception?: { values?: unknown[] };\n}\n\ninterface SentryClient {\n on(hook: \"preprocessEvent\", callback: (event: SentryEvent) => void): unknown;\n}\n\n// An initialized Sentry client opts in to recording exception event IDs on\n// active SERVER spans. Calls outside a request are no-ops.\nexport function installSentryEventIdRecording(): void {\n try {\n const client = getClientThroughPeerResolution() ?? getClientFromGlobalCarrier();\n if (!client) {\n logDebug(\"No Sentry client was detected\");\n return;\n }\n // preprocessEvent runs before asynchronous event processors can outlive the request.\n client.on(\"preprocessEvent\", (event) => {\n try {\n if (typeof event.event_id !== \"string\" || !event.exception?.values?.length) {\n return;\n }\n writeRequestAttribute(\n getServerSpan(),\n getRequestRecord(),\n \"apitally.exception.sentry_event_id\",\n event.event_id,\n );\n } catch (error) {\n logDebug(`Error writing the Sentry event id: ${String(error)}`);\n }\n });\n } catch (error) {\n logDebug(`Error setting up the Sentry integration: ${String(error)}`);\n }\n}\n\n// getClient() resolves wherever @sentry/node is reachable, including as the\n// transitive dependency of a Sentry wrapper package on npm-style layouts.\nfunction getClientThroughPeerResolution(): SentryClient | undefined {\n try {\n const entryPath = resolvePackageEntryPath(\"@sentry/node\");\n const sentry = createRequire(entryPath)(entryPath) as {\n getClient?: () => unknown;\n };\n return typeof sentry.getClient === \"function\" ? asSentryClient(sentry.getClient()) : undefined;\n } catch {\n return undefined;\n }\n}\n\n// Strict package layouts may prevent peer resolution. Sentry 7 to 10 still\n// expose initialized clients through two globalThis carrier shapes.\nfunction getClientFromGlobalCarrier(): SentryClient | undefined {\n const carrier = (globalThis as { __SENTRY__?: unknown }).__SENTRY__;\n if (!isRecord(carrier)) {\n return undefined;\n }\n const hub = carrier.hub;\n if (isRecord(hub) && typeof hub.getClient === \"function\") {\n return asSentryClient(hub.getClient());\n }\n const versioned = typeof carrier.version === \"string\" ? carrier[carrier.version] : undefined;\n if (!isRecord(versioned)) {\n return undefined;\n }\n const acs = versioned.acs;\n if (isRecord(acs) && typeof acs.getCurrentScope === \"function\") {\n const scope: unknown = acs.getCurrentScope();\n if (isRecord(scope) && typeof scope.getClient === \"function\") {\n const client = asSentryClient(scope.getClient());\n if (client) {\n return client;\n }\n }\n }\n const defaultScope = versioned.defaultCurrentScope;\n if (isRecord(defaultScope) && typeof defaultScope.getClient === \"function\") {\n return asSentryClient(defaultScope.getClient());\n }\n return undefined;\n}\n\nfunction asSentryClient(value: unknown): SentryClient | undefined {\n return isRecord(value) && typeof value.on === \"function\"\n ? (value as unknown as SentryClient)\n : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA8B;AAC9B,qBAAgD;AAChD,oBAAyB;AACzB,4BAAwC;AACxC,+BAAsC;AAe/B,SAAS,gCAAsC;AACpD,MAAI;AACF,UAAM,SAAS,+BAA+B,KAAK,2BAA2B;AAC9E,QAAI,CAAC,QAAQ;AACX,kCAAS,+BAA+B;AACxC;AAAA,IACF;AAEA,WAAO,GAAG,mBAAmB,CA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QAAM,eAAe,UAAU;AAC/B,MAAI,SAAS,YAAY,KAAK,OAAO,aAAa,cAAc,YAAY;AAC1E,WAAO,eAAe,aAAa,UAAU,CAAC;AAAA,EAChD;AACA,SAAO;AACT;AAEA,SAAS,eAAe,OAA0C;AAChE,SAAO,SAAS,KAAK,KAAK,OAAO,MAAM,OAAO,aACzC,QACD;AACN;AAEA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;","names":[]}
|
package/dist/sentry.d.ts
ADDED
package/dist/sentry.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { getRequestRecord, getServerSpan } from "./context.js";
|
|
3
|
+
import { logDebug } from "./logger.js";
|
|
4
|
+
import { resolvePackageEntryPath } from "./packageVersion.js";
|
|
5
|
+
import { writeRequestAttribute } from "./requestAttributes.js";
|
|
6
|
+
function installSentryEventIdRecording() {
|
|
7
|
+
try {
|
|
8
|
+
const client = getClientThroughPeerResolution() ?? getClientFromGlobalCarrier();
|
|
9
|
+
if (!client) {
|
|
10
|
+
logDebug("No Sentry client was detected");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
client.on("preprocessEvent", (event) => {
|
|
14
|
+
try {
|
|
15
|
+
if (typeof event.event_id !== "string" || !event.exception?.values?.length) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
writeRequestAttribute(
|
|
19
|
+
getServerSpan(),
|
|
20
|
+
getRequestRecord(),
|
|
21
|
+
"apitally.exception.sentry_event_id",
|
|
22
|
+
event.event_id
|
|
23
|
+
);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
logDebug(`Error writing the Sentry event id: ${String(error)}`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
} catch (error) {
|
|
29
|
+
logDebug(`Error setting up the Sentry integration: ${String(error)}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getClientThroughPeerResolution() {
|
|
33
|
+
try {
|
|
34
|
+
const entryPath = resolvePackageEntryPath("@sentry/node");
|
|
35
|
+
const sentry = createRequire(entryPath)(entryPath);
|
|
36
|
+
return typeof sentry.getClient === "function" ? asSentryClient(sentry.getClient()) : void 0;
|
|
37
|
+
} catch {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function getClientFromGlobalCarrier() {
|
|
42
|
+
const carrier = globalThis.__SENTRY__;
|
|
43
|
+
if (!isRecord(carrier)) {
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
const hub = carrier.hub;
|
|
47
|
+
if (isRecord(hub) && typeof hub.getClient === "function") {
|
|
48
|
+
return asSentryClient(hub.getClient());
|
|
49
|
+
}
|
|
50
|
+
const versioned = typeof carrier.version === "string" ? carrier[carrier.version] : void 0;
|
|
51
|
+
if (!isRecord(versioned)) {
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
const acs = versioned.acs;
|
|
55
|
+
if (isRecord(acs) && typeof acs.getCurrentScope === "function") {
|
|
56
|
+
const scope = acs.getCurrentScope();
|
|
57
|
+
if (isRecord(scope) && typeof scope.getClient === "function") {
|
|
58
|
+
const client = asSentryClient(scope.getClient());
|
|
59
|
+
if (client) {
|
|
60
|
+
return client;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const defaultScope = versioned.defaultCurrentScope;
|
|
65
|
+
if (isRecord(defaultScope) && typeof defaultScope.getClient === "function") {
|
|
66
|
+
return asSentryClient(defaultScope.getClient());
|
|
67
|
+
}
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
function asSentryClient(value) {
|
|
71
|
+
return isRecord(value) && typeof value.on === "function" ? value : void 0;
|
|
72
|
+
}
|
|
73
|
+
function isRecord(value) {
|
|
74
|
+
return typeof value === "object" && value !== null;
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
installSentryEventIdRecording
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=sentry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sentry.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { getRequestRecord, getServerSpan } from \"./context.js\";\nimport { logDebug } from \"./logger.js\";\nimport { resolvePackageEntryPath } from \"./packageVersion.js\";\nimport { writeRequestAttribute } from \"./requestAttributes.js\";\n\n// Minimal structural types: @sentry/node is an optional peer that is resolved\n// at runtime and never imported.\ninterface SentryEvent {\n event_id?: string;\n exception?: { values?: unknown[] };\n}\n\ninterface SentryClient {\n on(hook: \"preprocessEvent\", callback: (event: SentryEvent) => void): unknown;\n}\n\n// An initialized Sentry client opts in to recording exception event IDs on\n// active SERVER spans. Calls outside a request are no-ops.\nexport function installSentryEventIdRecording(): void {\n try {\n const client = getClientThroughPeerResolution() ?? getClientFromGlobalCarrier();\n if (!client) {\n logDebug(\"No Sentry client was detected\");\n return;\n }\n // preprocessEvent runs before asynchronous event processors can outlive the request.\n client.on(\"preprocessEvent\", (event) => {\n try {\n if (typeof event.event_id !== \"string\" || !event.exception?.values?.length) {\n return;\n }\n writeRequestAttribute(\n getServerSpan(),\n getRequestRecord(),\n \"apitally.exception.sentry_event_id\",\n event.event_id,\n );\n } catch (error) {\n logDebug(`Error writing the Sentry event id: ${String(error)}`);\n }\n });\n } catch (error) {\n logDebug(`Error setting up the Sentry integration: ${String(error)}`);\n }\n}\n\n// getClient() resolves wherever @sentry/node is reachable, including as the\n// transitive dependency of a Sentry wrapper package on npm-style layouts.\nfunction getClientThroughPeerResolution(): SentryClient | undefined {\n try {\n const entryPath = resolvePackageEntryPath(\"@sentry/node\");\n const sentry = createRequire(entryPath)(entryPath) as {\n getClient?: () => unknown;\n };\n return typeof sentry.getClient === \"function\" ? asSentryClient(sentry.getClient()) : undefined;\n } catch {\n return undefined;\n }\n}\n\n// Strict package layouts may prevent peer resolution. Sentry 7 to 10 still\n// expose initialized clients through two globalThis carrier shapes.\nfunction getClientFromGlobalCarrier(): SentryClient | undefined {\n const carrier = (globalThis as { __SENTRY__?: unknown }).__SENTRY__;\n if (!isRecord(carrier)) {\n return undefined;\n }\n const hub = carrier.hub;\n if (isRecord(hub) && typeof hub.getClient === \"function\") {\n return asSentryClient(hub.getClient());\n }\n const versioned = typeof carrier.version === \"string\" ? carrier[carrier.version] : undefined;\n if (!isRecord(versioned)) {\n return undefined;\n }\n const acs = versioned.acs;\n if (isRecord(acs) && typeof acs.getCurrentScope === \"function\") {\n const scope: unknown = acs.getCurrentScope();\n if (isRecord(scope) && typeof scope.getClient === \"function\") {\n const client = asSentryClient(scope.getClient());\n if (client) {\n return client;\n }\n }\n }\n const defaultScope = versioned.defaultCurrentScope;\n if (isRecord(defaultScope) && typeof defaultScope.getClient === \"function\") {\n return asSentryClient(defaultScope.getClient());\n }\n return undefined;\n}\n\nfunction asSentryClient(value: unknown): SentryClient | undefined {\n return isRecord(value) && typeof value.on === \"function\"\n ? (value as unknown as SentryClient)\n : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,gBAAgB;AACzB,SAAS,+BAA+B;AACxC,SAAS,6BAA6B;AAe/B,SAAS,gCAAsC;AACpD,MAAI;AACF,UAAM,SAAS,+BAA+B,KAAK,2BAA2B;AAC9E,QAAI,CAAC,QAAQ;AACX,eAAS,+BAA+B;AACxC;AAAA,IACF;AAEA,WAAO,GAAG,mBAAmB,CAAC,UAAU;AACtC,UAAI;AACF,YAAI,OAAO,MAAM,aAAa,YAAY,CAAC,MAAM,WAAW,QAAQ,QAAQ;AAC1E;AAAA,QACF;AACA;AAAA,UACE,cAAc;AAAA,UACd,iBAAiB;AAAA,UACjB;AAAA,UACA,MAAM;AAAA,QACR;AAAA,MACF,SAAS,OAAO;AACd,iBAAS,sCAAsC,OAAO,KAAK,CAAC,EA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E,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;","names":[]}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var spanExporter_exports = {};
|
|
20
|
+
__export(spanExporter_exports, {
|
|
21
|
+
ApitallySpanExporter: () => ApitallySpanExporter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(spanExporter_exports);
|
|
24
|
+
var import_api = require("@opentelemetry/api");
|
|
25
|
+
var import_otlp_transformer = require("@opentelemetry/otlp-transformer");
|
|
26
|
+
var import_resources = require("@opentelemetry/resources");
|
|
27
|
+
var import_bodyCapture = require('./bodyCapture.cjs');
|
|
28
|
+
var import_config = require('./config.cjs');
|
|
29
|
+
var import_exportSerialization = require('./exportSerialization.cjs');
|
|
30
|
+
var import_logger = require('./logger.cjs');
|
|
31
|
+
var import_redaction = require('./redaction.cjs');
|
|
32
|
+
var import_spanProcessor = require('./spanProcessor.cjs');
|
|
33
|
+
const QUERY_ATTRIBUTES = /* @__PURE__ */ new Set(["url.query", "url.full", "http.target", "http.url"]);
|
|
34
|
+
const REQUEST_HEADER_ATTRIBUTE_PREFIX = "http.request.header.";
|
|
35
|
+
const RESPONSE_HEADER_ATTRIBUTE_PREFIX = "http.response.header.";
|
|
36
|
+
const DEPLOYMENT_ENVIRONMENT_NAME = "deployment.environment.name";
|
|
37
|
+
const SERVICE_INSTANCE_ID = "service.instance.id";
|
|
38
|
+
class ApitallySpanExporter {
|
|
39
|
+
redaction;
|
|
40
|
+
env;
|
|
41
|
+
instanceId;
|
|
42
|
+
spool;
|
|
43
|
+
maskRequestBody;
|
|
44
|
+
maskResponseBody;
|
|
45
|
+
constructor(options) {
|
|
46
|
+
this.redaction = options.redaction;
|
|
47
|
+
this.env = options.env;
|
|
48
|
+
this.instanceId = options.instanceId;
|
|
49
|
+
this.spool = options.spool;
|
|
50
|
+
this.maskRequestBody = options.maskRequestBody;
|
|
51
|
+
this.maskResponseBody = options.maskResponseBody;
|
|
52
|
+
}
|
|
53
|
+
export(spans, resultCallback) {
|
|
54
|
+
const rewrittenResources = /* @__PURE__ */ new Map();
|
|
55
|
+
const exportCopies = [];
|
|
56
|
+
for (const span of spans) {
|
|
57
|
+
try {
|
|
58
|
+
exportCopies.push(this.buildExportCopy(span, rewrittenResources));
|
|
59
|
+
} catch {
|
|
60
|
+
(0, import_logger.logWarning)("Failed to prepare a span for export to Apitally, so the span was dropped");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
(0, import_exportSerialization.serializeInChunksToSpool)(
|
|
64
|
+
exportCopies,
|
|
65
|
+
(chunk) => import_otlp_transformer.ProtobufTraceSerializer.serializeRequest(chunk),
|
|
66
|
+
this.spool,
|
|
67
|
+
"traces",
|
|
68
|
+
resultCallback
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
forceFlush() {
|
|
72
|
+
return Promise.resolve();
|
|
73
|
+
}
|
|
74
|
+
shutdown() {
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
}
|
|
77
|
+
buildExportCopy(span, rewrittenResources) {
|
|
78
|
+
const data = span.apitallyData;
|
|
79
|
+
const stash = data?.stash;
|
|
80
|
+
const attributes = {
|
|
81
|
+
...span.attributes,
|
|
82
|
+
...data?.record?.attributes
|
|
83
|
+
};
|
|
84
|
+
this.redactQueryAndHeaderAttributes(attributes);
|
|
85
|
+
if (stash?.requestHeaders) {
|
|
86
|
+
writeCapturedHeaderAttributes(
|
|
87
|
+
attributes,
|
|
88
|
+
REQUEST_HEADER_ATTRIBUTE_PREFIX,
|
|
89
|
+
stash.requestHeaders,
|
|
90
|
+
this.redaction
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (stash?.responseHeaders) {
|
|
94
|
+
writeCapturedHeaderAttributes(
|
|
95
|
+
attributes,
|
|
96
|
+
RESPONSE_HEADER_ATTRIBUTE_PREFIX,
|
|
97
|
+
stash.responseHeaders,
|
|
98
|
+
this.redaction
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const copy = (0, import_spanProcessor.copySpan)(span);
|
|
102
|
+
copy.attributes = attributes;
|
|
103
|
+
copy.resource = this.resolveExportResource(span.resource, rewrittenResources);
|
|
104
|
+
if (data?.demoteToInternal) {
|
|
105
|
+
copy.kind = import_api.SpanKind.INTERNAL;
|
|
106
|
+
}
|
|
107
|
+
if (stash && (stash.requestBody !== void 0 || stash.responseBody !== void 0)) {
|
|
108
|
+
const snapshot = (0, import_spanProcessor.copySpan)(copy);
|
|
109
|
+
snapshot.attributes = { ...attributes };
|
|
110
|
+
if (stash.requestBody !== void 0) {
|
|
111
|
+
attributes["apitally.request.body"] = this.processBody(
|
|
112
|
+
snapshot,
|
|
113
|
+
stash.requestBody,
|
|
114
|
+
this.maskRequestBody,
|
|
115
|
+
"maskRequestBody"
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
if (stash.responseBody !== void 0) {
|
|
119
|
+
attributes["apitally.response.body"] = this.processBody(
|
|
120
|
+
snapshot,
|
|
121
|
+
stash.responseBody,
|
|
122
|
+
this.maskResponseBody,
|
|
123
|
+
"maskResponseBody"
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return copy;
|
|
128
|
+
}
|
|
129
|
+
// OpenTelemetry HTTP instrumentations leave query and header attributes raw.
|
|
130
|
+
// Both legacy and stable HTTP attribute names are redacted before export.
|
|
131
|
+
redactQueryAndHeaderAttributes(attributes) {
|
|
132
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
133
|
+
if (QUERY_ATTRIBUTES.has(key) && typeof value === "string") {
|
|
134
|
+
attributes[key] = this.redaction.redactQueryParams(value, key === "url.query");
|
|
135
|
+
} else if (key.startsWith(REQUEST_HEADER_ATTRIBUTE_PREFIX) || key.startsWith(RESPONSE_HEADER_ATTRIBUTE_PREFIX)) {
|
|
136
|
+
const headerName = key.slice(
|
|
137
|
+
key.startsWith(REQUEST_HEADER_ATTRIBUTE_PREFIX) ? REQUEST_HEADER_ATTRIBUTE_PREFIX.length : RESPONSE_HEADER_ATTRIBUTE_PREFIX.length
|
|
138
|
+
);
|
|
139
|
+
attributes[key] = this.redaction.redactHeaderValue(headerName, value);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Bodies are masked, parsed, field-redacted, and serialized in that order.
|
|
144
|
+
// Masking failures redact the entire body.
|
|
145
|
+
processBody(snapshot, body, maskCallback, optionName) {
|
|
146
|
+
if (body.equals(import_bodyCapture.BODY_TOO_LARGE_BUFFER)) {
|
|
147
|
+
return import_bodyCapture.BODY_TOO_LARGE;
|
|
148
|
+
}
|
|
149
|
+
let processed = body;
|
|
150
|
+
if (maskCallback) {
|
|
151
|
+
let masked;
|
|
152
|
+
try {
|
|
153
|
+
masked = maskCallback(body, snapshot);
|
|
154
|
+
} catch {
|
|
155
|
+
(0, import_logger.logWarning)(
|
|
156
|
+
`The Apitally ${optionName} callback threw an error, so the body was replaced with ${import_redaction.REDACTED}`
|
|
157
|
+
);
|
|
158
|
+
return import_redaction.REDACTED;
|
|
159
|
+
}
|
|
160
|
+
if (masked === null || masked === void 0) {
|
|
161
|
+
return import_redaction.REDACTED;
|
|
162
|
+
}
|
|
163
|
+
if (!Buffer.isBuffer(masked)) {
|
|
164
|
+
(0, import_logger.logWarning)(
|
|
165
|
+
`The Apitally ${optionName} callback returned an invalid value, so the body was replaced with ${import_redaction.REDACTED}. Mask callbacks must synchronously return a Buffer or null.`
|
|
166
|
+
);
|
|
167
|
+
return import_redaction.REDACTED;
|
|
168
|
+
}
|
|
169
|
+
if (masked.length > import_bodyCapture.MAX_BODY_SIZE) {
|
|
170
|
+
return import_bodyCapture.BODY_TOO_LARGE;
|
|
171
|
+
}
|
|
172
|
+
processed = masked;
|
|
173
|
+
}
|
|
174
|
+
return this.redaction.redactBody(processed);
|
|
175
|
+
}
|
|
176
|
+
// Export resources must carry Apitally's process identity and match Apitally-Env.
|
|
177
|
+
// Rewrites apply only to Apitally's copies.
|
|
178
|
+
resolveExportResource(resource, rewrittenResources) {
|
|
179
|
+
const resourceEnv = resource.attributes[DEPLOYMENT_ENVIRONMENT_NAME];
|
|
180
|
+
const resourceInstanceId = resource.attributes[SERVICE_INSTANCE_ID];
|
|
181
|
+
const envDiffers = typeof resourceEnv === "string" && resourceEnv !== this.env;
|
|
182
|
+
const envMissing = resourceEnv === void 0 && this.env !== import_config.DEFAULT_ENV;
|
|
183
|
+
const instanceIdDiffers = resourceInstanceId !== this.instanceId;
|
|
184
|
+
if (!envDiffers && !envMissing && !instanceIdDiffers) {
|
|
185
|
+
return resource;
|
|
186
|
+
}
|
|
187
|
+
const existing = rewrittenResources.get(resource);
|
|
188
|
+
if (existing) {
|
|
189
|
+
return existing;
|
|
190
|
+
}
|
|
191
|
+
if (envDiffers) {
|
|
192
|
+
(0, import_logger.logWarning)(
|
|
193
|
+
`The tracer provider's resource sets deployment.environment.name to "${resourceEnv}", which differs from the Apitally env "${this.env}". Spans are exported to Apitally with the env "${this.env}".`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
const attributes = {
|
|
197
|
+
...resource.attributes,
|
|
198
|
+
[SERVICE_INSTANCE_ID]: this.instanceId
|
|
199
|
+
};
|
|
200
|
+
if (envDiffers || envMissing) {
|
|
201
|
+
attributes[DEPLOYMENT_ENVIRONMENT_NAME] = this.env;
|
|
202
|
+
}
|
|
203
|
+
const rewritten = (0, import_resources.resourceFromAttributes)(attributes);
|
|
204
|
+
rewrittenResources.set(resource, rewritten);
|
|
205
|
+
return rewritten;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function writeCapturedHeaderAttributes(attributes, prefix, headers, redaction) {
|
|
209
|
+
for (const [name, values] of Object.entries(headers)) {
|
|
210
|
+
const redactedValues = redaction.redactHeaderValue(name, values);
|
|
211
|
+
attributes[prefix + name] = Array.isArray(redactedValues) ? redactedValues : [redactedValues];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
+
0 && (module.exports = {
|
|
216
|
+
ApitallySpanExporter
|
|
217
|
+
});
|
|
218
|
+
//# sourceMappingURL=spanExporter.cjs.map
|