@compas/server
Advanced tools
Comparing version 0.11.0 to 0.11.1
{ | ||
"name": "@compas/server", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "Koa server and common middleware", | ||
@@ -24,3 +24,3 @@ "exports": { | ||
"dependencies": { | ||
"@compas/stdlib": "0.11.0", | ||
"@compas/stdlib": "0.11.1", | ||
"@types/formidable": "2.0.6", | ||
@@ -27,0 +27,0 @@ "@types/koa": "2.15.0", |
@@ -1,2 +0,2 @@ | ||
import { _compasSentryExport } from "@compas/stdlib"; | ||
import { _compasSentryExport, isNil, uuid } from "@compas/stdlib"; | ||
@@ -24,3 +24,3 @@ /** | ||
return async (ctx, next) => { | ||
return (ctx, next) => { | ||
if (ctx.method === "OPTIONS" || ctx.method === "HEAD") { | ||
@@ -30,19 +30,23 @@ return next(); | ||
let traceParentData = { | ||
forceTransaction: true, | ||
}; | ||
if (ctx.request.get("sentry-trace")) { | ||
// @ts-expect-error | ||
traceParentData = _compasSentryExport.extractTraceparentData( | ||
ctx.request.get("sentry-trace"), | ||
); | ||
if (!_compasSentryExport) { | ||
return next(); | ||
} | ||
// @ts-expect-error | ||
return await _compasSentryExport.startSpanManual( | ||
const traceHeader = ctx.request.get("sentry-trace"); | ||
/** @type {any} */ | ||
const traceParentData = | ||
_compasSentryExport.extractTraceparentData(traceHeader) ?? {}; | ||
// Use a manual span, so we can end it right after the body is send. | ||
return _compasSentryExport.startSpanManual( | ||
{ | ||
// Force a new trace for every request. This keeps the traces view usable. | ||
traceId: uuid().replace(/-/g, ""), | ||
...traceParentData, | ||
spanId: uuid().replace(/-/g, "").slice(16), | ||
forceTransaction: isNil(traceParentData.parentSpanId), | ||
op: "http.server", | ||
name: "http", | ||
description: "http", | ||
...traceParentData, | ||
attributes: { | ||
@@ -49,0 +53,0 @@ "http.request.method": ctx.method, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40266
1137
+ Added@compas/stdlib@0.11.1(transitive)
- Removed@compas/stdlib@0.11.0(transitive)
Updated@compas/stdlib@0.11.1