apitally 0.25.8 → 1.0.0-beta.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 +228 -178
- package/dist/activation.cjs +393 -0
- package/dist/activation.cjs.map +1 -0
- package/dist/activation.d.cts +42 -0
- package/dist/activation.d.ts +42 -0
- package/dist/activation.js +383 -0
- package/dist/activation.js.map +1 -0
- package/dist/adonisjs/configure.cjs +86 -30
- 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 +83 -29
- package/dist/adonisjs/configure.js.map +1 -1
- package/dist/adonisjs/index.cjs +38 -21
- package/dist/adonisjs/index.cjs.map +1 -1
- package/dist/adonisjs/index.d.cts +5 -14
- package/dist/adonisjs/index.d.ts +5 -14
- package/dist/adonisjs/index.js +39 -18
- 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 +227 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +45 -0
- package/dist/config.d.ts +45 -0
- package/dist/config.js +192 -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 +15 -0
- package/dist/consumer.d.ts +15 -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 +33 -0
- package/dist/context.d.ts +33 -0
- package/dist/context.js +40 -0
- package/dist/context.js.map +1 -0
- package/dist/elysia/index.cjs +12 -3
- package/dist/elysia/index.cjs.map +1 -1
- package/dist/elysia/index.d.cts +8 -16
- package/dist/elysia/index.d.ts +8 -16
- package/dist/elysia/index.js +10 -2
- package/dist/elysia/index.js.map +1 -1
- package/dist/elysia/middleware.cjs +261 -0
- package/dist/elysia/middleware.cjs.map +1 -0
- package/dist/elysia/middleware.d.cts +14 -0
- package/dist/elysia/middleware.d.ts +14 -0
- package/dist/elysia/middleware.js +250 -0
- package/dist/elysia/middleware.js.map +1 -0
- package/dist/{otel/index.cjs → elysia/routes.cjs} +16 -7
- 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 +81 -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 +55 -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 +7 -10
- package/dist/express/index.d.ts +7 -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 +10 -0
- package/dist/express/install.d.ts +10 -0
- package/dist/express/install.js +21 -0
- package/dist/express/install.js.map +1 -0
- package/dist/express/middleware.cjs +87 -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 +91 -327
- 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 +429 -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 +401 -0
- package/dist/express/routes.js.map +1 -0
- package/dist/fastify/index.cjs +10 -5
- package/dist/fastify/index.cjs.map +1 -1
- package/dist/fastify/index.d.cts +7 -11
- package/dist/fastify/index.d.ts +7 -11
- package/dist/fastify/index.js +9 -3
- package/dist/fastify/index.js.map +1 -1
- package/dist/{loggers/index.cjs → fastify/install.cjs} +17 -19
- package/dist/fastify/install.cjs.map +1 -0
- package/dist/fastify/install.d.cts +10 -0
- package/dist/fastify/install.d.ts +10 -0
- package/dist/fastify/install.js +15 -0
- package/dist/fastify/install.js.map +1 -0
- package/dist/fastify/middleware.cjs +135 -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 +114 -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 +8 -10
- package/dist/h3/index.d.ts +8 -10
- package/dist/h3/index.js +26 -2
- package/dist/h3/index.js.map +1 -1
- package/dist/h3/middleware.cjs +210 -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 +194 -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 -4
- package/dist/hapi/index.cjs.map +1 -1
- package/dist/hapi/index.d.cts +8 -10
- package/dist/hapi/index.d.ts +8 -10
- package/dist/hapi/index.js +13 -2
- 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 +8 -0
- package/dist/hapi/install.d.ts +8 -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/{common/logging.cjs → hapi/routes.cjs} +14 -17
- 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 +7 -10
- package/dist/hono/index.d.ts +7 -10
- package/dist/hono/index.js +13 -2
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/middleware.cjs +219 -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 +229 -126
- 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 +29 -1
- package/dist/index.d.ts +29 -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 +7 -10
- package/dist/koa/index.d.ts +7 -10
- package/dist/koa/index.js +13 -2
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/middleware.cjs +85 -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 +88 -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 +417 -0
- package/dist/logCapture.cjs.map +1 -0
- package/dist/logCapture.d.cts +18 -0
- package/dist/logCapture.d.ts +18 -0
- package/dist/logCapture.js +390 -0
- package/dist/logCapture.js.map +1 -0
- package/dist/logRecordExporter.cjs +51 -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 +27 -0
- package/dist/logRecordExporter.js.map +1 -0
- package/dist/logRecordProcessor.cjs +137 -0
- package/dist/logRecordProcessor.cjs.map +1 -0
- package/dist/logRecordProcessor.d.cts +27 -0
- package/dist/logRecordProcessor.d.ts +27 -0
- package/dist/logRecordProcessor.js +113 -0
- package/dist/logRecordProcessor.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 +26 -0
- package/dist/metrics.d.ts +26 -0
- package/dist/metrics.js +153 -0
- package/dist/metrics.js.map +1 -0
- package/dist/nestjs/index.cjs +81 -71
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.d.cts +4 -11
- package/dist/nestjs/index.d.ts +4 -11
- package/dist/nestjs/index.js +81 -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 +10 -0
- package/dist/requestAttributes.d.ts +10 -0
- package/dist/requestAttributes.js +22 -0
- package/dist/requestAttributes.js.map +1 -0
- package/dist/requestObservation.cjs +246 -0
- package/dist/requestObservation.cjs.map +1 -0
- package/dist/requestObservation.d.cts +62 -0
- package/dist/requestObservation.d.ts +62 -0
- package/dist/requestObservation.js +226 -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 +31 -0
- package/dist/requestObservationNode.d.ts +31 -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 +34 -0
- package/dist/requestObservationWeb.d.ts +34 -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/serverErrors.cjs +118 -0
- package/dist/serverErrors.cjs.map +1 -0
- package/dist/serverErrors.d.cts +8 -0
- package/dist/serverErrors.d.ts +8 -0
- package/dist/serverErrors.js +91 -0
- package/dist/serverErrors.js.map +1 -0
- package/dist/spanExporter.cjs +217 -0
- package/dist/spanExporter.cjs.map +1 -0
- package/dist/spanExporter.d.cts +34 -0
- package/dist/spanExporter.d.ts +34 -0
- package/dist/spanExporter.js +193 -0
- package/dist/spanExporter.js.map +1 -0
- package/dist/spanProcessor.cjs +535 -0
- package/dist/spanProcessor.cjs.map +1 -0
- package/dist/spanProcessor.d.cts +70 -0
- package/dist/spanProcessor.d.ts +70 -0
- package/dist/spanProcessor.js +513 -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 +98 -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 +73 -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/dist/validationErrors.cjs +229 -0
- package/dist/validationErrors.cjs.map +1 -0
- package/dist/validationErrors.d.cts +21 -0
- package/dist/validationErrors.d.ts +21 -0
- package/dist/validationErrors.js +195 -0
- package/dist/validationErrors.js.map +1 -0
- package/package.json +113 -154
- 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 -86
- 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 -62
- 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 -114
- 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 -91
- package/dist/common/requestCounter.js.map +0 -1
- package/dist/common/requestLogger.cjs +0 -543
- 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 -508
- 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 -123
- 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 -98
- package/dist/common/serverErrorCounter.js.map +0 -1
- package/dist/common/spanCollector.cjs +0 -201
- 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 -177
- package/dist/common/spanCollector.js.map +0 -1
- package/dist/common/tempGzipFile.cjs +0 -127
- 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 -103
- 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 -79
- 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 -56
- package/dist/common/validationErrorCounter.js.map +0 -1
- package/dist/elysia/plugin.cjs +0 -242
- 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 -219
- 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 -319
- 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 -284
- 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 -212
- 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 -188
- 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
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,EAAE;AAAA,MAChE;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,aAAS,4CAA4C,OAAO,KAAK,CAAC,EAAE;AAAA,EACtE;AACF;AAIA,SAAS,iCAA2D;AAClE,MAAI;AACF,UAAM,YAAY,wBAAwB,cAAc;AACxD,UAAM,SAAS,cAAc,SAAS,EAAE,SAAS;AAGjD,WAAO,OAAO,OAAO,cAAc,aAAa,eAAe,OAAO,UAAU,CAAC,IAAI;AAAA,EACvF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,SAAS,6BAAuD;AAC9D,QAAM,UAAW,WAAwC;AACzD,MAAI,CAAC,SAAS,OAAO,GAAG;AACtB,WAAO;AAAA,EACT;AACA,QAAM,MAAM,QAAQ;AACpB,MAAI,SAAS,GAAG,KAAK,OAAO,IAAI,cAAc,YAAY;AACxD,WAAO,eAAe,IAAI,UAAU,CAAC;AAAA,EACvC;AACA,QAAM,YAAY,OAAO,QAAQ,YAAY,WAAW,QAAQ,QAAQ,OAAO,IAAI;AACnF,MAAI,CAAC,SAAS,SAAS,GAAG;AACxB,WAAO;AAAA,EACT;AACA,QAAM,MAAM,UAAU;AACtB,MAAI,SAAS,GAAG,KAAK,OAAO,IAAI,oBAAoB,YAAY;AAC9D,UAAM,QAAiB,IAAI,gBAAgB;AAC3C,QAAI,SAAS,KAAK,KAAK,OAAO,MAAM,cAAc,YAAY;AAC5D,YAAM,SAAS,eAAe,MAAM,UAAU,CAAC;AAC/C,UAAI,QAAQ;AACV,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,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":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
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 serverErrors_exports = {};
|
|
20
|
+
__export(serverErrors_exports, {
|
|
21
|
+
SERVER_ERROR_EVENT_NAME: () => SERVER_ERROR_EVENT_NAME,
|
|
22
|
+
addServerError: () => addServerError,
|
|
23
|
+
drainServerErrors: () => drainServerErrors,
|
|
24
|
+
resetServerErrors: () => resetServerErrors
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(serverErrors_exports);
|
|
27
|
+
var import_exceptions = require('./exceptions.cjs');
|
|
28
|
+
const SERVER_ERROR_EVENT_NAME = "apitally.request.server_error";
|
|
29
|
+
const MAX_GROUPS = 100;
|
|
30
|
+
const MAX_CONSUMER_LENGTH = 128;
|
|
31
|
+
const MAX_PATH_LENGTH = 2e3;
|
|
32
|
+
const MAX_TYPE_LENGTH = 256;
|
|
33
|
+
const MAX_MESSAGE_LENGTH = 2048;
|
|
34
|
+
const MAX_STACKTRACE_LENGTH = 65536;
|
|
35
|
+
const MAX_COUNT = 2 ** 32 - 1;
|
|
36
|
+
const MESSAGE_TRUNCATION_SUFFIX = "... (truncated)";
|
|
37
|
+
const STACKTRACE_TRUNCATION_SUFFIX = "\n... (truncated) ...";
|
|
38
|
+
const SERVER_ERROR_GROUPS_KEY = /* @__PURE__ */ Symbol.for("apitally.serverErrorGroups");
|
|
39
|
+
const serverErrorGroupsHolder = globalThis;
|
|
40
|
+
const serverErrorGroups = serverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] ?? /* @__PURE__ */ new Map();
|
|
41
|
+
serverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] = serverErrorGroups;
|
|
42
|
+
function addServerError(consumer, method, path, error, sentryEventId) {
|
|
43
|
+
method = method.toUpperCase();
|
|
44
|
+
if (method === "OPTIONS" || !path) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const exception = (0, import_exceptions.coerceToException)(error);
|
|
48
|
+
const { name, message, stack } = typeof exception === "string" ? { name: "", message: exception, stack: "" } : exception;
|
|
49
|
+
const group = {
|
|
50
|
+
method,
|
|
51
|
+
path: path.slice(0, MAX_PATH_LENGTH),
|
|
52
|
+
type: String(name ?? "").slice(0, MAX_TYPE_LENGTH),
|
|
53
|
+
message: formatMessage(message),
|
|
54
|
+
stacktrace: formatStacktrace(stack),
|
|
55
|
+
count: 1
|
|
56
|
+
};
|
|
57
|
+
if (consumer !== void 0) {
|
|
58
|
+
group.consumer = consumer.slice(0, MAX_CONSUMER_LENGTH);
|
|
59
|
+
}
|
|
60
|
+
if (sentryEventId !== void 0) {
|
|
61
|
+
group.sentry_event_id = sentryEventId;
|
|
62
|
+
}
|
|
63
|
+
const key = [
|
|
64
|
+
group.consumer ?? "",
|
|
65
|
+
group.method,
|
|
66
|
+
group.path,
|
|
67
|
+
group.type,
|
|
68
|
+
group.message,
|
|
69
|
+
group.stacktrace
|
|
70
|
+
].join("\0");
|
|
71
|
+
const existing = serverErrorGroups.get(key);
|
|
72
|
+
if (existing) {
|
|
73
|
+
existing.count = Math.min(existing.count + 1, MAX_COUNT);
|
|
74
|
+
existing.sentry_event_id = group.sentry_event_id ?? existing.sentry_event_id;
|
|
75
|
+
} else if (serverErrorGroups.size < MAX_GROUPS) {
|
|
76
|
+
serverErrorGroups.set(key, group);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function drainServerErrors() {
|
|
80
|
+
const groups = [...serverErrorGroups.values()];
|
|
81
|
+
serverErrorGroups.clear();
|
|
82
|
+
return groups;
|
|
83
|
+
}
|
|
84
|
+
function resetServerErrors() {
|
|
85
|
+
serverErrorGroups.clear();
|
|
86
|
+
}
|
|
87
|
+
function formatMessage(message) {
|
|
88
|
+
const text = String(message ?? "").trim();
|
|
89
|
+
if (text.length <= MAX_MESSAGE_LENGTH) {
|
|
90
|
+
return text;
|
|
91
|
+
}
|
|
92
|
+
return text.slice(0, MAX_MESSAGE_LENGTH - MESSAGE_TRUNCATION_SUFFIX.length) + MESSAGE_TRUNCATION_SUFFIX;
|
|
93
|
+
}
|
|
94
|
+
function formatStacktrace(stack) {
|
|
95
|
+
const text = typeof stack === "string" ? stack.trim() : "";
|
|
96
|
+
if (text.length <= MAX_STACKTRACE_LENGTH) {
|
|
97
|
+
return text;
|
|
98
|
+
}
|
|
99
|
+
const cutoff = MAX_STACKTRACE_LENGTH - STACKTRACE_TRUNCATION_SUFFIX.length;
|
|
100
|
+
const lines = [];
|
|
101
|
+
let length = 0;
|
|
102
|
+
for (const line of text.split("\n")) {
|
|
103
|
+
if (length + line.length + 1 > cutoff) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
lines.push(line);
|
|
107
|
+
length += line.length + 1;
|
|
108
|
+
}
|
|
109
|
+
return lines.join("\n") + STACKTRACE_TRUNCATION_SUFFIX;
|
|
110
|
+
}
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
SERVER_ERROR_EVENT_NAME,
|
|
114
|
+
addServerError,
|
|
115
|
+
drainServerErrors,
|
|
116
|
+
resetServerErrors
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=serverErrors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/serverErrors.ts"],"sourcesContent":["import type { AnyValueMap } from \"@opentelemetry/api-logs\";\nimport { coerceToException } from \"./exceptions.js\";\n\nexport const SERVER_ERROR_EVENT_NAME = \"apitally.request.server_error\";\n\nconst MAX_GROUPS = 100;\nconst MAX_CONSUMER_LENGTH = 128;\nconst MAX_PATH_LENGTH = 2_000;\nconst MAX_TYPE_LENGTH = 256;\nconst MAX_MESSAGE_LENGTH = 2_048;\nconst MAX_STACKTRACE_LENGTH = 65_536;\nconst MAX_COUNT = 2 ** 32 - 1;\nconst MESSAGE_TRUNCATION_SUFFIX = \"... (truncated)\";\nconst STACKTRACE_TRUNCATION_SUFFIX = \"\\n... (truncated) ...\";\n\ntype ServerErrorGroup = {\n consumer?: string;\n method: string;\n path: string;\n type: string;\n message: string;\n stacktrace: string;\n count: number;\n sentry_event_id?: string;\n};\n\nconst SERVER_ERROR_GROUPS_KEY = Symbol.for(\"apitally.serverErrorGroups\");\nconst serverErrorGroupsHolder = globalThis as Record<\n symbol,\n Map<string, ServerErrorGroup> | undefined\n>;\nconst serverErrorGroups =\n serverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] ?? new Map<string, ServerErrorGroup>();\nserverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] = serverErrorGroups;\n\nexport function addServerError(\n consumer: string | undefined,\n method: string,\n path: string,\n error: unknown,\n sentryEventId: string | undefined,\n): void {\n method = method.toUpperCase();\n if (method === \"OPTIONS\" || !path) {\n return;\n }\n const exception = coerceToException(error);\n const { name, message, stack } =\n typeof exception === \"string\"\n ? { name: \"\", message: exception, stack: \"\" }\n : (exception as { name?: unknown; message?: unknown; stack?: unknown });\n const group: ServerErrorGroup = {\n method,\n path: path.slice(0, MAX_PATH_LENGTH),\n type: String(name ?? \"\").slice(0, MAX_TYPE_LENGTH),\n message: formatMessage(message),\n stacktrace: formatStacktrace(stack),\n count: 1,\n };\n if (consumer !== undefined) {\n group.consumer = consumer.slice(0, MAX_CONSUMER_LENGTH);\n }\n if (sentryEventId !== undefined) {\n group.sentry_event_id = sentryEventId;\n }\n const key = [\n group.consumer ?? \"\",\n group.method,\n group.path,\n group.type,\n group.message,\n group.stacktrace,\n ].join(\"\\0\");\n const existing = serverErrorGroups.get(key);\n if (existing) {\n existing.count = Math.min(existing.count + 1, MAX_COUNT);\n existing.sentry_event_id = group.sentry_event_id ?? existing.sentry_event_id;\n } else if (serverErrorGroups.size < MAX_GROUPS) {\n serverErrorGroups.set(key, group);\n }\n}\n\nexport function drainServerErrors(): AnyValueMap[] {\n const groups = [...serverErrorGroups.values()];\n serverErrorGroups.clear();\n return groups;\n}\n\nexport function resetServerErrors(): void {\n serverErrorGroups.clear();\n}\n\nfunction formatMessage(message: unknown): string {\n const text = String(message ?? \"\").trim();\n if (text.length <= MAX_MESSAGE_LENGTH) {\n return text;\n }\n return (\n text.slice(0, MAX_MESSAGE_LENGTH - MESSAGE_TRUNCATION_SUFFIX.length) + MESSAGE_TRUNCATION_SUFFIX\n );\n}\n\n// The error line and innermost frames come first in a JS stack, so the head is kept.\nfunction formatStacktrace(stack: unknown): string {\n const text = typeof stack === \"string\" ? stack.trim() : \"\";\n if (text.length <= MAX_STACKTRACE_LENGTH) {\n return text;\n }\n const cutoff = MAX_STACKTRACE_LENGTH - STACKTRACE_TRUNCATION_SUFFIX.length;\n const lines: string[] = [];\n let length = 0;\n for (const line of text.split(\"\\n\")) {\n if (length + line.length + 1 > cutoff) {\n break;\n }\n lines.push(line);\n length += line.length + 1;\n }\n return lines.join(\"\\n\") + STACKTRACE_TRUNCATION_SUFFIX;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAkC;AAE3B,MAAM,0BAA0B;AAEvC,MAAM,aAAa;AACnB,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAC9B,MAAM,YAAY,KAAK,KAAK;AAC5B,MAAM,4BAA4B;AAClC,MAAM,+BAA+B;AAarC,MAAM,0BAA0B,uBAAO,IAAI,4BAA4B;AACvE,MAAM,0BAA0B;AAIhC,MAAM,oBACJ,wBAAwB,uBAAuB,KAAK,oBAAI,IAA8B;AACxF,wBAAwB,uBAAuB,IAAI;AAE5C,SAAS,eACd,UACA,QACA,MACA,OACA,eACM;AACN,WAAS,OAAO,YAAY;AAC5B,MAAI,WAAW,aAAa,CAAC,MAAM;AACjC;AAAA,EACF;AACA,QAAM,gBAAY,qCAAkB,KAAK;AACzC,QAAM,EAAE,MAAM,SAAS,MAAM,IAC3B,OAAO,cAAc,WACjB,EAAE,MAAM,IAAI,SAAS,WAAW,OAAO,GAAG,IACzC;AACP,QAAM,QAA0B;AAAA,IAC9B;AAAA,IACA,MAAM,KAAK,MAAM,GAAG,eAAe;AAAA,IACnC,MAAM,OAAO,QAAQ,EAAE,EAAE,MAAM,GAAG,eAAe;AAAA,IACjD,SAAS,cAAc,OAAO;AAAA,IAC9B,YAAY,iBAAiB,KAAK;AAAA,IAClC,OAAO;AAAA,EACT;AACA,MAAI,aAAa,QAAW;AAC1B,UAAM,WAAW,SAAS,MAAM,GAAG,mBAAmB;AAAA,EACxD;AACA,MAAI,kBAAkB,QAAW;AAC/B,UAAM,kBAAkB;AAAA,EAC1B;AACA,QAAM,MAAM;AAAA,IACV,MAAM,YAAY;AAAA,IAClB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR,EAAE,KAAK,IAAI;AACX,QAAM,WAAW,kBAAkB,IAAI,GAAG;AAC1C,MAAI,UAAU;AACZ,aAAS,QAAQ,KAAK,IAAI,SAAS,QAAQ,GAAG,SAAS;AACvD,aAAS,kBAAkB,MAAM,mBAAmB,SAAS;AAAA,EAC/D,WAAW,kBAAkB,OAAO,YAAY;AAC9C,sBAAkB,IAAI,KAAK,KAAK;AAAA,EAClC;AACF;AAEO,SAAS,oBAAmC;AACjD,QAAM,SAAS,CAAC,GAAG,kBAAkB,OAAO,CAAC;AAC7C,oBAAkB,MAAM;AACxB,SAAO;AACT;AAEO,SAAS,oBAA0B;AACxC,oBAAkB,MAAM;AAC1B;AAEA,SAAS,cAAc,SAA0B;AAC/C,QAAM,OAAO,OAAO,WAAW,EAAE,EAAE,KAAK;AACxC,MAAI,KAAK,UAAU,oBAAoB;AACrC,WAAO;AAAA,EACT;AACA,SACE,KAAK,MAAM,GAAG,qBAAqB,0BAA0B,MAAM,IAAI;AAE3E;AAGA,SAAS,iBAAiB,OAAwB;AAChD,QAAM,OAAO,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;AACxD,MAAI,KAAK,UAAU,uBAAuB;AACxC,WAAO;AAAA,EACT;AACA,QAAM,SAAS,wBAAwB,6BAA6B;AACpE,QAAM,QAAkB,CAAC;AACzB,MAAI,SAAS;AACb,aAAW,QAAQ,KAAK,MAAM,IAAI,GAAG;AACnC,QAAI,SAAS,KAAK,SAAS,IAAI,QAAQ;AACrC;AAAA,IACF;AACA,UAAM,KAAK,IAAI;AACf,cAAU,KAAK,SAAS;AAAA,EAC1B;AACA,SAAO,MAAM,KAAK,IAAI,IAAI;AAC5B;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyValueMap } from '@opentelemetry/api-logs';
|
|
2
|
+
|
|
3
|
+
declare const SERVER_ERROR_EVENT_NAME = "apitally.request.server_error";
|
|
4
|
+
declare function addServerError(consumer: string | undefined, method: string, path: string, error: unknown, sentryEventId: string | undefined): void;
|
|
5
|
+
declare function drainServerErrors(): AnyValueMap[];
|
|
6
|
+
declare function resetServerErrors(): void;
|
|
7
|
+
|
|
8
|
+
export { SERVER_ERROR_EVENT_NAME, addServerError, drainServerErrors, resetServerErrors };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyValueMap } from '@opentelemetry/api-logs';
|
|
2
|
+
|
|
3
|
+
declare const SERVER_ERROR_EVENT_NAME = "apitally.request.server_error";
|
|
4
|
+
declare function addServerError(consumer: string | undefined, method: string, path: string, error: unknown, sentryEventId: string | undefined): void;
|
|
5
|
+
declare function drainServerErrors(): AnyValueMap[];
|
|
6
|
+
declare function resetServerErrors(): void;
|
|
7
|
+
|
|
8
|
+
export { SERVER_ERROR_EVENT_NAME, addServerError, drainServerErrors, resetServerErrors };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { coerceToException } from "./exceptions.js";
|
|
2
|
+
const SERVER_ERROR_EVENT_NAME = "apitally.request.server_error";
|
|
3
|
+
const MAX_GROUPS = 100;
|
|
4
|
+
const MAX_CONSUMER_LENGTH = 128;
|
|
5
|
+
const MAX_PATH_LENGTH = 2e3;
|
|
6
|
+
const MAX_TYPE_LENGTH = 256;
|
|
7
|
+
const MAX_MESSAGE_LENGTH = 2048;
|
|
8
|
+
const MAX_STACKTRACE_LENGTH = 65536;
|
|
9
|
+
const MAX_COUNT = 2 ** 32 - 1;
|
|
10
|
+
const MESSAGE_TRUNCATION_SUFFIX = "... (truncated)";
|
|
11
|
+
const STACKTRACE_TRUNCATION_SUFFIX = "\n... (truncated) ...";
|
|
12
|
+
const SERVER_ERROR_GROUPS_KEY = /* @__PURE__ */ Symbol.for("apitally.serverErrorGroups");
|
|
13
|
+
const serverErrorGroupsHolder = globalThis;
|
|
14
|
+
const serverErrorGroups = serverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] ?? /* @__PURE__ */ new Map();
|
|
15
|
+
serverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] = serverErrorGroups;
|
|
16
|
+
function addServerError(consumer, method, path, error, sentryEventId) {
|
|
17
|
+
method = method.toUpperCase();
|
|
18
|
+
if (method === "OPTIONS" || !path) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const exception = coerceToException(error);
|
|
22
|
+
const { name, message, stack } = typeof exception === "string" ? { name: "", message: exception, stack: "" } : exception;
|
|
23
|
+
const group = {
|
|
24
|
+
method,
|
|
25
|
+
path: path.slice(0, MAX_PATH_LENGTH),
|
|
26
|
+
type: String(name ?? "").slice(0, MAX_TYPE_LENGTH),
|
|
27
|
+
message: formatMessage(message),
|
|
28
|
+
stacktrace: formatStacktrace(stack),
|
|
29
|
+
count: 1
|
|
30
|
+
};
|
|
31
|
+
if (consumer !== void 0) {
|
|
32
|
+
group.consumer = consumer.slice(0, MAX_CONSUMER_LENGTH);
|
|
33
|
+
}
|
|
34
|
+
if (sentryEventId !== void 0) {
|
|
35
|
+
group.sentry_event_id = sentryEventId;
|
|
36
|
+
}
|
|
37
|
+
const key = [
|
|
38
|
+
group.consumer ?? "",
|
|
39
|
+
group.method,
|
|
40
|
+
group.path,
|
|
41
|
+
group.type,
|
|
42
|
+
group.message,
|
|
43
|
+
group.stacktrace
|
|
44
|
+
].join("\0");
|
|
45
|
+
const existing = serverErrorGroups.get(key);
|
|
46
|
+
if (existing) {
|
|
47
|
+
existing.count = Math.min(existing.count + 1, MAX_COUNT);
|
|
48
|
+
existing.sentry_event_id = group.sentry_event_id ?? existing.sentry_event_id;
|
|
49
|
+
} else if (serverErrorGroups.size < MAX_GROUPS) {
|
|
50
|
+
serverErrorGroups.set(key, group);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function drainServerErrors() {
|
|
54
|
+
const groups = [...serverErrorGroups.values()];
|
|
55
|
+
serverErrorGroups.clear();
|
|
56
|
+
return groups;
|
|
57
|
+
}
|
|
58
|
+
function resetServerErrors() {
|
|
59
|
+
serverErrorGroups.clear();
|
|
60
|
+
}
|
|
61
|
+
function formatMessage(message) {
|
|
62
|
+
const text = String(message ?? "").trim();
|
|
63
|
+
if (text.length <= MAX_MESSAGE_LENGTH) {
|
|
64
|
+
return text;
|
|
65
|
+
}
|
|
66
|
+
return text.slice(0, MAX_MESSAGE_LENGTH - MESSAGE_TRUNCATION_SUFFIX.length) + MESSAGE_TRUNCATION_SUFFIX;
|
|
67
|
+
}
|
|
68
|
+
function formatStacktrace(stack) {
|
|
69
|
+
const text = typeof stack === "string" ? stack.trim() : "";
|
|
70
|
+
if (text.length <= MAX_STACKTRACE_LENGTH) {
|
|
71
|
+
return text;
|
|
72
|
+
}
|
|
73
|
+
const cutoff = MAX_STACKTRACE_LENGTH - STACKTRACE_TRUNCATION_SUFFIX.length;
|
|
74
|
+
const lines = [];
|
|
75
|
+
let length = 0;
|
|
76
|
+
for (const line of text.split("\n")) {
|
|
77
|
+
if (length + line.length + 1 > cutoff) {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
lines.push(line);
|
|
81
|
+
length += line.length + 1;
|
|
82
|
+
}
|
|
83
|
+
return lines.join("\n") + STACKTRACE_TRUNCATION_SUFFIX;
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
SERVER_ERROR_EVENT_NAME,
|
|
87
|
+
addServerError,
|
|
88
|
+
drainServerErrors,
|
|
89
|
+
resetServerErrors
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=serverErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/serverErrors.ts"],"sourcesContent":["import type { AnyValueMap } from \"@opentelemetry/api-logs\";\nimport { coerceToException } from \"./exceptions.js\";\n\nexport const SERVER_ERROR_EVENT_NAME = \"apitally.request.server_error\";\n\nconst MAX_GROUPS = 100;\nconst MAX_CONSUMER_LENGTH = 128;\nconst MAX_PATH_LENGTH = 2_000;\nconst MAX_TYPE_LENGTH = 256;\nconst MAX_MESSAGE_LENGTH = 2_048;\nconst MAX_STACKTRACE_LENGTH = 65_536;\nconst MAX_COUNT = 2 ** 32 - 1;\nconst MESSAGE_TRUNCATION_SUFFIX = \"... (truncated)\";\nconst STACKTRACE_TRUNCATION_SUFFIX = \"\\n... (truncated) ...\";\n\ntype ServerErrorGroup = {\n consumer?: string;\n method: string;\n path: string;\n type: string;\n message: string;\n stacktrace: string;\n count: number;\n sentry_event_id?: string;\n};\n\nconst SERVER_ERROR_GROUPS_KEY = Symbol.for(\"apitally.serverErrorGroups\");\nconst serverErrorGroupsHolder = globalThis as Record<\n symbol,\n Map<string, ServerErrorGroup> | undefined\n>;\nconst serverErrorGroups =\n serverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] ?? new Map<string, ServerErrorGroup>();\nserverErrorGroupsHolder[SERVER_ERROR_GROUPS_KEY] = serverErrorGroups;\n\nexport function addServerError(\n consumer: string | undefined,\n method: string,\n path: string,\n error: unknown,\n sentryEventId: string | undefined,\n): void {\n method = method.toUpperCase();\n if (method === \"OPTIONS\" || !path) {\n return;\n }\n const exception = coerceToException(error);\n const { name, message, stack } =\n typeof exception === \"string\"\n ? { name: \"\", message: exception, stack: \"\" }\n : (exception as { name?: unknown; message?: unknown; stack?: unknown });\n const group: ServerErrorGroup = {\n method,\n path: path.slice(0, MAX_PATH_LENGTH),\n type: String(name ?? \"\").slice(0, MAX_TYPE_LENGTH),\n message: formatMessage(message),\n stacktrace: formatStacktrace(stack),\n count: 1,\n };\n if (consumer !== undefined) {\n group.consumer = consumer.slice(0, MAX_CONSUMER_LENGTH);\n }\n if (sentryEventId !== undefined) {\n group.sentry_event_id = sentryEventId;\n }\n const key = [\n group.consumer ?? \"\",\n group.method,\n group.path,\n group.type,\n group.message,\n group.stacktrace,\n ].join(\"\\0\");\n const existing = serverErrorGroups.get(key);\n if (existing) {\n existing.count = Math.min(existing.count + 1, MAX_COUNT);\n existing.sentry_event_id = group.sentry_event_id ?? existing.sentry_event_id;\n } else if (serverErrorGroups.size < MAX_GROUPS) {\n serverErrorGroups.set(key, group);\n }\n}\n\nexport function drainServerErrors(): AnyValueMap[] {\n const groups = [...serverErrorGroups.values()];\n serverErrorGroups.clear();\n return groups;\n}\n\nexport function resetServerErrors(): void {\n serverErrorGroups.clear();\n}\n\nfunction formatMessage(message: unknown): string {\n const text = String(message ?? \"\").trim();\n if (text.length <= MAX_MESSAGE_LENGTH) {\n return text;\n }\n return (\n text.slice(0, MAX_MESSAGE_LENGTH - MESSAGE_TRUNCATION_SUFFIX.length) + MESSAGE_TRUNCATION_SUFFIX\n );\n}\n\n// The error line and innermost frames come first in a JS stack, so the head is kept.\nfunction formatStacktrace(stack: unknown): string {\n const text = typeof stack === \"string\" ? stack.trim() : \"\";\n if (text.length <= MAX_STACKTRACE_LENGTH) {\n return text;\n }\n const cutoff = MAX_STACKTRACE_LENGTH - STACKTRACE_TRUNCATION_SUFFIX.length;\n const lines: string[] = [];\n let length = 0;\n for (const line of text.split(\"\\n\")) {\n if (length + line.length + 1 > cutoff) {\n break;\n }\n lines.push(line);\n length += line.length + 1;\n }\n return lines.join(\"\\n\") + STACKTRACE_TRUNCATION_SUFFIX;\n}\n"],"mappings":"AACA,SAAS,yBAAyB;AAE3B,MAAM,0BAA0B;AAEvC,MAAM,aAAa;AACnB,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAC9B,MAAM,YAAY,KAAK,KAAK;AAC5B,MAAM,4BAA4B;AAClC,MAAM,+BAA+B;AAarC,MAAM,0BAA0B,uBAAO,IAAI,4BAA4B;AACvE,MAAM,0BAA0B;AAIhC,MAAM,oBACJ,wBAAwB,uBAAuB,KAAK,oBAAI,IAA8B;AACxF,wBAAwB,uBAAuB,IAAI;AAE5C,SAAS,eACd,UACA,QACA,MACA,OACA,eACM;AACN,WAAS,OAAO,YAAY;AAC5B,MAAI,WAAW,aAAa,CAAC,MAAM;AACjC;AAAA,EACF;AACA,QAAM,YAAY,kBAAkB,KAAK;AACzC,QAAM,EAAE,MAAM,SAAS,MAAM,IAC3B,OAAO,cAAc,WACjB,EAAE,MAAM,IAAI,SAAS,WAAW,OAAO,GAAG,IACzC;AACP,QAAM,QAA0B;AAAA,IAC9B;AAAA,IACA,MAAM,KAAK,MAAM,GAAG,eAAe;AAAA,IACnC,MAAM,OAAO,QAAQ,EAAE,EAAE,MAAM,GAAG,eAAe;AAAA,IACjD,SAAS,cAAc,OAAO;AAAA,IAC9B,YAAY,iBAAiB,KAAK;AAAA,IAClC,OAAO;AAAA,EACT;AACA,MAAI,aAAa,QAAW;AAC1B,UAAM,WAAW,SAAS,MAAM,GAAG,mBAAmB;AAAA,EACxD;AACA,MAAI,kBAAkB,QAAW;AAC/B,UAAM,kBAAkB;AAAA,EAC1B;AACA,QAAM,MAAM;AAAA,IACV,MAAM,YAAY;AAAA,IAClB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR,EAAE,KAAK,IAAI;AACX,QAAM,WAAW,kBAAkB,IAAI,GAAG;AAC1C,MAAI,UAAU;AACZ,aAAS,QAAQ,KAAK,IAAI,SAAS,QAAQ,GAAG,SAAS;AACvD,aAAS,kBAAkB,MAAM,mBAAmB,SAAS;AAAA,EAC/D,WAAW,kBAAkB,OAAO,YAAY;AAC9C,sBAAkB,IAAI,KAAK,KAAK;AAAA,EAClC;AACF;AAEO,SAAS,oBAAmC;AACjD,QAAM,SAAS,CAAC,GAAG,kBAAkB,OAAO,CAAC;AAC7C,oBAAkB,MAAM;AACxB,SAAO;AACT;AAEO,SAAS,oBAA0B;AACxC,oBAAkB,MAAM;AAC1B;AAEA,SAAS,cAAc,SAA0B;AAC/C,QAAM,OAAO,OAAO,WAAW,EAAE,EAAE,KAAK;AACxC,MAAI,KAAK,UAAU,oBAAoB;AACrC,WAAO;AAAA,EACT;AACA,SACE,KAAK,MAAM,GAAG,qBAAqB,0BAA0B,MAAM,IAAI;AAE3E;AAGA,SAAS,iBAAiB,OAAwB;AAChD,QAAM,OAAO,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;AACxD,MAAI,KAAK,UAAU,uBAAuB;AACxC,WAAO;AAAA,EACT;AACA,QAAM,SAAS,wBAAwB,6BAA6B;AACpE,QAAM,QAAkB,CAAC;AACzB,MAAI,SAAS;AACb,aAAW,QAAQ,KAAK,MAAM,IAAI,GAAG;AACnC,QAAI,SAAS,KAAK,SAAS,IAAI,QAAQ;AACrC;AAAA,IACF;AACA,UAAM,KAAK,IAAI;AACf,cAAU,KAAK,SAAS;AAAA,EAC1B;AACA,SAAO,MAAM,KAAK,IAAI,IAAI;AAC5B;","names":[]}
|
|
@@ -0,0 +1,217 @@
|
|
|
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_exportSerialization = require('./exportSerialization.cjs');
|
|
29
|
+
var import_logger = require('./logger.cjs');
|
|
30
|
+
var import_redaction = require('./redaction.cjs');
|
|
31
|
+
var import_spanProcessor = require('./spanProcessor.cjs');
|
|
32
|
+
const QUERY_ATTRIBUTES = /* @__PURE__ */ new Set(["url.query", "url.full", "http.target", "http.url"]);
|
|
33
|
+
const REQUEST_HEADER_ATTRIBUTE_PREFIX = "http.request.header.";
|
|
34
|
+
const RESPONSE_HEADER_ATTRIBUTE_PREFIX = "http.response.header.";
|
|
35
|
+
const DEPLOYMENT_ENVIRONMENT_NAME = "deployment.environment.name";
|
|
36
|
+
const SERVICE_INSTANCE_ID = "service.instance.id";
|
|
37
|
+
class ApitallySpanExporter {
|
|
38
|
+
redaction;
|
|
39
|
+
env;
|
|
40
|
+
instanceId;
|
|
41
|
+
spool;
|
|
42
|
+
maskRequestBody;
|
|
43
|
+
maskResponseBody;
|
|
44
|
+
constructor(options) {
|
|
45
|
+
this.redaction = options.redaction;
|
|
46
|
+
this.env = options.env;
|
|
47
|
+
this.instanceId = options.instanceId;
|
|
48
|
+
this.spool = options.spool;
|
|
49
|
+
this.maskRequestBody = options.maskRequestBody;
|
|
50
|
+
this.maskResponseBody = options.maskResponseBody;
|
|
51
|
+
}
|
|
52
|
+
export(spans, resultCallback) {
|
|
53
|
+
const rewrittenResources = /* @__PURE__ */ new Map();
|
|
54
|
+
const exportCopies = [];
|
|
55
|
+
for (const span of spans) {
|
|
56
|
+
try {
|
|
57
|
+
exportCopies.push(this.buildExportCopy(span, rewrittenResources));
|
|
58
|
+
} catch {
|
|
59
|
+
(0, import_logger.logWarning)("Failed to prepare a span for export to Apitally, so the span was dropped");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
(0, import_exportSerialization.serializeInChunksToSpool)(
|
|
63
|
+
exportCopies,
|
|
64
|
+
(chunk) => import_otlp_transformer.ProtobufTraceSerializer.serializeRequest(chunk),
|
|
65
|
+
this.spool,
|
|
66
|
+
"traces",
|
|
67
|
+
resultCallback
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
forceFlush() {
|
|
71
|
+
return Promise.resolve();
|
|
72
|
+
}
|
|
73
|
+
shutdown() {
|
|
74
|
+
return Promise.resolve();
|
|
75
|
+
}
|
|
76
|
+
buildExportCopy(span, rewrittenResources) {
|
|
77
|
+
const data = span.apitallyData;
|
|
78
|
+
const stash = data?.stash;
|
|
79
|
+
const attributes = {
|
|
80
|
+
...span.attributes,
|
|
81
|
+
...data?.record?.attributes
|
|
82
|
+
};
|
|
83
|
+
this.redactQueryAndHeaderAttributes(attributes);
|
|
84
|
+
if (stash?.requestHeaders) {
|
|
85
|
+
writeCapturedHeaderAttributes(
|
|
86
|
+
attributes,
|
|
87
|
+
REQUEST_HEADER_ATTRIBUTE_PREFIX,
|
|
88
|
+
stash.requestHeaders,
|
|
89
|
+
this.redaction
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (stash?.responseHeaders) {
|
|
93
|
+
writeCapturedHeaderAttributes(
|
|
94
|
+
attributes,
|
|
95
|
+
RESPONSE_HEADER_ATTRIBUTE_PREFIX,
|
|
96
|
+
stash.responseHeaders,
|
|
97
|
+
this.redaction
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const copy = (0, import_spanProcessor.copySpan)(span);
|
|
101
|
+
copy.attributes = attributes;
|
|
102
|
+
copy.resource = this.resolveExportResource(span.resource, rewrittenResources);
|
|
103
|
+
if (data?.demoteToInternal) {
|
|
104
|
+
copy.kind = import_api.SpanKind.INTERNAL;
|
|
105
|
+
}
|
|
106
|
+
if (stash && (stash.requestBody !== void 0 || stash.responseBody !== void 0)) {
|
|
107
|
+
const snapshot = (0, import_spanProcessor.copySpan)(copy);
|
|
108
|
+
snapshot.attributes = { ...attributes };
|
|
109
|
+
if (stash.requestBody !== void 0) {
|
|
110
|
+
attributes["apitally.request.body"] = this.processBody(
|
|
111
|
+
snapshot,
|
|
112
|
+
stash.requestBody,
|
|
113
|
+
this.maskRequestBody,
|
|
114
|
+
"maskRequestBody"
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (stash.responseBody !== void 0) {
|
|
118
|
+
attributes["apitally.response.body"] = this.processBody(
|
|
119
|
+
snapshot,
|
|
120
|
+
stash.responseBody,
|
|
121
|
+
this.maskResponseBody,
|
|
122
|
+
"maskResponseBody"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return copy;
|
|
127
|
+
}
|
|
128
|
+
// OpenTelemetry HTTP instrumentations leave query and header attributes raw.
|
|
129
|
+
// Both legacy and stable HTTP attribute names are redacted before export.
|
|
130
|
+
redactQueryAndHeaderAttributes(attributes) {
|
|
131
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
132
|
+
if (QUERY_ATTRIBUTES.has(key) && typeof value === "string") {
|
|
133
|
+
attributes[key] = this.redaction.redactQueryParams(value, key === "url.query");
|
|
134
|
+
} else if (key.startsWith(REQUEST_HEADER_ATTRIBUTE_PREFIX) || key.startsWith(RESPONSE_HEADER_ATTRIBUTE_PREFIX)) {
|
|
135
|
+
const headerName = key.slice(
|
|
136
|
+
key.startsWith(REQUEST_HEADER_ATTRIBUTE_PREFIX) ? REQUEST_HEADER_ATTRIBUTE_PREFIX.length : RESPONSE_HEADER_ATTRIBUTE_PREFIX.length
|
|
137
|
+
);
|
|
138
|
+
attributes[key] = this.redaction.redactHeaderValue(headerName, value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Bodies are masked, parsed, field-redacted, and serialized in that order.
|
|
143
|
+
// Masking failures redact the entire body.
|
|
144
|
+
processBody(snapshot, body, maskCallback, optionName) {
|
|
145
|
+
if (body.equals(import_bodyCapture.BODY_TOO_LARGE_BUFFER)) {
|
|
146
|
+
return import_bodyCapture.BODY_TOO_LARGE;
|
|
147
|
+
}
|
|
148
|
+
let processed = body;
|
|
149
|
+
if (maskCallback) {
|
|
150
|
+
let masked;
|
|
151
|
+
try {
|
|
152
|
+
masked = maskCallback(body, snapshot);
|
|
153
|
+
} catch {
|
|
154
|
+
(0, import_logger.logWarning)(
|
|
155
|
+
`The Apitally ${optionName} callback threw an error, so the body was replaced with ${import_redaction.REDACTED}`
|
|
156
|
+
);
|
|
157
|
+
return import_redaction.REDACTED;
|
|
158
|
+
}
|
|
159
|
+
if (masked === null || masked === void 0) {
|
|
160
|
+
return import_redaction.REDACTED;
|
|
161
|
+
}
|
|
162
|
+
if (!Buffer.isBuffer(masked)) {
|
|
163
|
+
(0, import_logger.logWarning)(
|
|
164
|
+
`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.`
|
|
165
|
+
);
|
|
166
|
+
return import_redaction.REDACTED;
|
|
167
|
+
}
|
|
168
|
+
if (masked.length > import_bodyCapture.MAX_BODY_SIZE) {
|
|
169
|
+
return import_bodyCapture.BODY_TOO_LARGE;
|
|
170
|
+
}
|
|
171
|
+
processed = masked;
|
|
172
|
+
}
|
|
173
|
+
return this.redaction.redactBody(processed);
|
|
174
|
+
}
|
|
175
|
+
// Export resources must carry Apitally's process identity and match Apitally-Env.
|
|
176
|
+
// Rewrites apply only to Apitally's copies.
|
|
177
|
+
resolveExportResource(resource, rewrittenResources) {
|
|
178
|
+
const resourceEnv = resource.attributes[DEPLOYMENT_ENVIRONMENT_NAME];
|
|
179
|
+
const resourceInstanceId = resource.attributes[SERVICE_INSTANCE_ID];
|
|
180
|
+
const envDiffers = typeof resourceEnv === "string" && resourceEnv !== this.env;
|
|
181
|
+
const envMissing = resourceEnv === void 0;
|
|
182
|
+
const instanceIdDiffers = resourceInstanceId !== this.instanceId;
|
|
183
|
+
if (!envDiffers && !envMissing && !instanceIdDiffers) {
|
|
184
|
+
return resource;
|
|
185
|
+
}
|
|
186
|
+
const existing = rewrittenResources.get(resource);
|
|
187
|
+
if (existing) {
|
|
188
|
+
return existing;
|
|
189
|
+
}
|
|
190
|
+
if (envDiffers) {
|
|
191
|
+
(0, import_logger.logWarning)(
|
|
192
|
+
`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}".`
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
const attributes = {
|
|
196
|
+
...resource.attributes,
|
|
197
|
+
[SERVICE_INSTANCE_ID]: this.instanceId
|
|
198
|
+
};
|
|
199
|
+
if (envDiffers || envMissing) {
|
|
200
|
+
attributes[DEPLOYMENT_ENVIRONMENT_NAME] = this.env;
|
|
201
|
+
}
|
|
202
|
+
const rewritten = (0, import_resources.resourceFromAttributes)(attributes);
|
|
203
|
+
rewrittenResources.set(resource, rewritten);
|
|
204
|
+
return rewritten;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function writeCapturedHeaderAttributes(attributes, prefix, headers, redaction) {
|
|
208
|
+
for (const [name, values] of Object.entries(headers)) {
|
|
209
|
+
const redactedValues = redaction.redactHeaderValue(name, values);
|
|
210
|
+
attributes[prefix + name] = Array.isArray(redactedValues) ? redactedValues : [redactedValues];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
214
|
+
0 && (module.exports = {
|
|
215
|
+
ApitallySpanExporter
|
|
216
|
+
});
|
|
217
|
+
//# sourceMappingURL=spanExporter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/spanExporter.ts"],"sourcesContent":["import type { Attributes } from \"@opentelemetry/api\";\nimport { SpanKind } from \"@opentelemetry/api\";\nimport type { ExportResult } from \"@opentelemetry/core\";\nimport { ProtobufTraceSerializer } from \"@opentelemetry/otlp-transformer\";\nimport { type Resource, resourceFromAttributes } from \"@opentelemetry/resources\";\nimport type { ReadableSpan, SpanExporter } from \"@opentelemetry/sdk-trace-base\";\nimport { BODY_TOO_LARGE, BODY_TOO_LARGE_BUFFER, MAX_BODY_SIZE } from \"./bodyCapture.js\";\nimport type { BodyMaskingCallback } from \"./config.js\";\nimport { serializeInChunksToSpool } from \"./exportSerialization.js\";\nimport { logWarning } from \"./logger.js\";\nimport { REDACTED, type Redaction } from \"./redaction.js\";\nimport { copySpan, type SpanCopy } from \"./spanProcessor.js\";\nimport type { Spool } from \"./spool.js\";\n\nconst QUERY_ATTRIBUTES = new Set([\"url.query\", \"url.full\", \"http.target\", \"http.url\"]);\nconst REQUEST_HEADER_ATTRIBUTE_PREFIX = \"http.request.header.\";\nconst RESPONSE_HEADER_ATTRIBUTE_PREFIX = \"http.response.header.\";\nconst DEPLOYMENT_ENVIRONMENT_NAME = \"deployment.environment.name\";\nconst SERVICE_INSTANCE_ID = \"service.instance.id\";\n\nexport interface ApitallySpanExporterOptions {\n redaction: Redaction;\n env: string;\n instanceId: string;\n spool: Spool;\n maskRequestBody?: BodyMaskingCallback;\n maskResponseBody?: BodyMaskingCallback;\n}\n\n// Export copies receive transport attributes, captured data, and redaction\n// without mutating the original spans.\nexport class ApitallySpanExporter implements SpanExporter {\n private readonly redaction: Redaction;\n private readonly env: string;\n private readonly instanceId: string;\n private readonly spool: Spool;\n private readonly maskRequestBody?: BodyMaskingCallback;\n private readonly maskResponseBody?: BodyMaskingCallback;\n\n constructor(options: ApitallySpanExporterOptions) {\n this.redaction = options.redaction;\n this.env = options.env;\n this.instanceId = options.instanceId;\n this.spool = options.spool;\n this.maskRequestBody = options.maskRequestBody;\n this.maskResponseBody = options.maskResponseBody;\n }\n\n export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {\n // Rewritten resources are shared across the batch: the serializer groups\n // resourceSpans by object identity, never by attribute equality.\n const rewrittenResources = new Map<Resource, Resource>();\n const exportCopies: ReadableSpan[] = [];\n for (const span of spans) {\n try {\n exportCopies.push(this.buildExportCopy(span, rewrittenResources));\n } catch {\n // A span that failed redaction must never leave the process.\n logWarning(\"Failed to prepare a span for export to Apitally, so the span was dropped\");\n }\n }\n serializeInChunksToSpool(\n exportCopies,\n (chunk) => ProtobufTraceSerializer.serializeRequest(chunk),\n this.spool,\n \"traces\",\n resultCallback,\n );\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n shutdown(): Promise<void> {\n return Promise.resolve();\n }\n\n private buildExportCopy(\n span: ReadableSpan,\n rewrittenResources: Map<Resource, Resource>,\n ): ReadableSpan {\n const data = (span as SpanCopy).apitallyData;\n const stash = data?.stash;\n // The record is applied last: a transport-observed value wins over anything\n // the producing instrumentation set for the same key.\n const attributes: Record<string, unknown> = {\n ...span.attributes,\n ...data?.record?.attributes,\n };\n this.redactQueryAndHeaderAttributes(attributes);\n if (stash?.requestHeaders) {\n writeCapturedHeaderAttributes(\n attributes,\n REQUEST_HEADER_ATTRIBUTE_PREFIX,\n stash.requestHeaders,\n this.redaction,\n );\n }\n if (stash?.responseHeaders) {\n writeCapturedHeaderAttributes(\n attributes,\n RESPONSE_HEADER_ATTRIBUTE_PREFIX,\n stash.responseHeaders,\n this.redaction,\n );\n }\n const copy = copySpan(span);\n copy.attributes = attributes as Attributes;\n copy.resource = this.resolveExportResource(span.resource, rewrittenResources);\n if (data?.demoteToInternal) {\n copy.kind = SpanKind.INTERNAL;\n }\n if (stash && (stash.requestBody !== undefined || stash.responseBody !== undefined)) {\n // Mask callbacks receive the redacted export copy with captured headers\n // attached, but without body attributes.\n const snapshot = copySpan(copy);\n snapshot.attributes = { ...attributes } as Attributes;\n if (stash.requestBody !== undefined) {\n attributes[\"apitally.request.body\"] = this.processBody(\n snapshot,\n stash.requestBody,\n this.maskRequestBody,\n \"maskRequestBody\",\n );\n }\n if (stash.responseBody !== undefined) {\n attributes[\"apitally.response.body\"] = this.processBody(\n snapshot,\n stash.responseBody,\n this.maskResponseBody,\n \"maskResponseBody\",\n );\n }\n }\n return copy;\n }\n\n // OpenTelemetry HTTP instrumentations leave query and header attributes raw.\n // Both legacy and stable HTTP attribute names are redacted before export.\n private redactQueryAndHeaderAttributes(attributes: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(attributes)) {\n if (QUERY_ATTRIBUTES.has(key) && typeof value === \"string\") {\n attributes[key] = this.redaction.redactQueryParams(value, key === \"url.query\");\n } else if (\n key.startsWith(REQUEST_HEADER_ATTRIBUTE_PREFIX) ||\n key.startsWith(RESPONSE_HEADER_ATTRIBUTE_PREFIX)\n ) {\n const headerName = key.slice(\n key.startsWith(REQUEST_HEADER_ATTRIBUTE_PREFIX)\n ? REQUEST_HEADER_ATTRIBUTE_PREFIX.length\n : RESPONSE_HEADER_ATTRIBUTE_PREFIX.length,\n );\n attributes[key] = this.redaction.redactHeaderValue(headerName, value);\n }\n }\n }\n\n // Bodies are masked, parsed, field-redacted, and serialized in that order.\n // Masking failures redact the entire body.\n private processBody(\n snapshot: ReadableSpan,\n body: Buffer,\n maskCallback: BodyMaskingCallback | undefined,\n optionName: string,\n ): string | Buffer {\n if (body.equals(BODY_TOO_LARGE_BUFFER)) {\n return BODY_TOO_LARGE;\n }\n let processed = body;\n if (maskCallback) {\n let masked: unknown;\n try {\n masked = maskCallback(body, snapshot);\n } catch {\n logWarning(\n `The Apitally ${optionName} callback threw an error, so the body was replaced with ${REDACTED}`,\n );\n return REDACTED;\n }\n if (masked === null || masked === undefined) {\n return REDACTED;\n }\n if (!Buffer.isBuffer(masked)) {\n logWarning(\n `The Apitally ${optionName} callback returned an invalid value, so the body was replaced with ${REDACTED}. Mask callbacks must synchronously return a Buffer or null.`,\n );\n return REDACTED;\n }\n if (masked.length > MAX_BODY_SIZE) {\n return BODY_TOO_LARGE;\n }\n processed = masked;\n }\n return this.redaction.redactBody(processed);\n }\n\n // Export resources must carry Apitally's process identity and match Apitally-Env.\n // Rewrites apply only to Apitally's copies.\n private resolveExportResource(\n resource: Resource,\n rewrittenResources: Map<Resource, Resource>,\n ): Resource {\n const resourceEnv = resource.attributes[DEPLOYMENT_ENVIRONMENT_NAME];\n const resourceInstanceId = resource.attributes[SERVICE_INSTANCE_ID];\n const envDiffers = typeof resourceEnv === \"string\" && resourceEnv !== this.env;\n const envMissing = resourceEnv === undefined;\n const instanceIdDiffers = resourceInstanceId !== this.instanceId;\n if (!envDiffers && !envMissing && !instanceIdDiffers) {\n return resource;\n }\n const existing = rewrittenResources.get(resource);\n if (existing) {\n return existing;\n }\n if (envDiffers) {\n logWarning(\n `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}\".`,\n );\n }\n const attributes: Attributes = {\n ...resource.attributes,\n [SERVICE_INSTANCE_ID]: this.instanceId,\n };\n if (envDiffers || envMissing) {\n attributes[DEPLOYMENT_ENVIRONMENT_NAME] = this.env;\n }\n const rewritten = resourceFromAttributes(attributes);\n rewrittenResources.set(resource, rewritten);\n return rewritten;\n }\n}\n\nfunction writeCapturedHeaderAttributes(\n attributes: Record<string, unknown>,\n prefix: string,\n headers: Record<string, string | string[]>,\n redaction: Redaction,\n): void {\n for (const [name, values] of Object.entries(headers)) {\n const redactedValues = redaction.redactHeaderValue(name, values);\n attributes[prefix + name] = Array.isArray(redactedValues) ? redactedValues : [redactedValues];\n }\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ExportResult } from '@opentelemetry/core';
|
|
2
|
+
import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
3
|
+
import { BodyMaskingCallback } from './config.cjs';
|
|
4
|
+
import { Redaction } from './redaction.cjs';
|
|
5
|
+
import { Spool } from './spool.cjs';
|
|
6
|
+
import '@opentelemetry/sdk-logs';
|
|
7
|
+
import 'node:zlib';
|
|
8
|
+
|
|
9
|
+
interface ApitallySpanExporterOptions {
|
|
10
|
+
redaction: Redaction;
|
|
11
|
+
env: string;
|
|
12
|
+
instanceId: string;
|
|
13
|
+
spool: Spool;
|
|
14
|
+
maskRequestBody?: BodyMaskingCallback;
|
|
15
|
+
maskResponseBody?: BodyMaskingCallback;
|
|
16
|
+
}
|
|
17
|
+
declare class ApitallySpanExporter implements SpanExporter {
|
|
18
|
+
private readonly redaction;
|
|
19
|
+
private readonly env;
|
|
20
|
+
private readonly instanceId;
|
|
21
|
+
private readonly spool;
|
|
22
|
+
private readonly maskRequestBody?;
|
|
23
|
+
private readonly maskResponseBody?;
|
|
24
|
+
constructor(options: ApitallySpanExporterOptions);
|
|
25
|
+
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
26
|
+
forceFlush(): Promise<void>;
|
|
27
|
+
shutdown(): Promise<void>;
|
|
28
|
+
private buildExportCopy;
|
|
29
|
+
private redactQueryAndHeaderAttributes;
|
|
30
|
+
private processBody;
|
|
31
|
+
private resolveExportResource;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { ApitallySpanExporter, type ApitallySpanExporterOptions };
|