@jaypie/express 1.2.19 → 1.2.21
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/dist/cjs/index.cjs +52 -47
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +52 -47
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1755,15 +1755,6 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1755
1755
|
});
|
|
1756
1756
|
// Update the public logger with the request ID
|
|
1757
1757
|
const invokeUuid = getCurrentInvokeUuid(req);
|
|
1758
|
-
if (invokeUuid) {
|
|
1759
|
-
logger$1.tag({ invoke: invokeUuid });
|
|
1760
|
-
logger$1.tag({ shortInvoke: invokeUuid.slice(0, 8) });
|
|
1761
|
-
// TODO: in theory this is redundant
|
|
1762
|
-
libLogger.tag({ invoke: invokeUuid });
|
|
1763
|
-
libLogger.tag({ shortInvoke: invokeUuid.slice(0, 8) });
|
|
1764
|
-
log.tag({ invoke: invokeUuid });
|
|
1765
|
-
log.tag({ shortInvoke: invokeUuid.slice(0, 8) });
|
|
1766
|
-
}
|
|
1767
1758
|
if (!name) {
|
|
1768
1759
|
// If handler has a name, use it
|
|
1769
1760
|
if (handler.name) {
|
|
@@ -1773,10 +1764,15 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1773
1764
|
name = JAYPIE.UNKNOWN;
|
|
1774
1765
|
}
|
|
1775
1766
|
}
|
|
1776
|
-
|
|
1767
|
+
const setupTags = { handler: name };
|
|
1768
|
+
if (invokeUuid) {
|
|
1769
|
+
setupTags.invoke = invokeUuid;
|
|
1770
|
+
setupTags.shortInvoke = invokeUuid.slice(0, 8);
|
|
1771
|
+
}
|
|
1772
|
+
logger$1.setup(setupTags);
|
|
1777
1773
|
// TODO: in theory this is redundant
|
|
1778
|
-
libLogger.tag(
|
|
1779
|
-
log.tag(
|
|
1774
|
+
libLogger.tag(setupTags);
|
|
1775
|
+
log.tag(setupTags);
|
|
1780
1776
|
libLogger.trace("[jaypie] Express init");
|
|
1781
1777
|
// Set req.locals if it doesn't exist
|
|
1782
1778
|
if (!extReq.locals)
|
|
@@ -1980,22 +1976,24 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1980
1976
|
log.info.var({
|
|
1981
1977
|
res: summarizeResponse(res, extras),
|
|
1982
1978
|
});
|
|
1979
|
+
// Construct normalized path for reporting and metrics
|
|
1980
|
+
let path = (req.baseUrl || "") + (req.url || "");
|
|
1981
|
+
if (!path.startsWith("/")) {
|
|
1982
|
+
path = "/" + path;
|
|
1983
|
+
}
|
|
1984
|
+
if (path.length > 1 && path.endsWith("/")) {
|
|
1985
|
+
path = path.slice(0, -1);
|
|
1986
|
+
}
|
|
1987
|
+
// Replace UUIDs with :id for better aggregation
|
|
1988
|
+
path = path.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ":id");
|
|
1989
|
+
// Add request data to session report
|
|
1990
|
+
logger$1.report({
|
|
1991
|
+
method: req.method,
|
|
1992
|
+
path,
|
|
1993
|
+
status: String(res.statusCode),
|
|
1994
|
+
});
|
|
1983
1995
|
// Submit metric if Datadog is configured
|
|
1984
1996
|
if (hasDatadogEnv()) {
|
|
1985
|
-
// Construct path from baseUrl and url
|
|
1986
|
-
let path = (req.baseUrl || "") + (req.url || "");
|
|
1987
|
-
// Ensure path starts with /
|
|
1988
|
-
if (!path.startsWith("/")) {
|
|
1989
|
-
path = "/" + path;
|
|
1990
|
-
}
|
|
1991
|
-
// Remove trailing slash unless it's the root path
|
|
1992
|
-
if (path.length > 1 && path.endsWith("/")) {
|
|
1993
|
-
path = path.slice(0, -1);
|
|
1994
|
-
}
|
|
1995
|
-
// Replace UUIDs with :id for better aggregation
|
|
1996
|
-
// Matches standard UUID v4 format (8-4-4-4-12 hex characters)
|
|
1997
|
-
path = path.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ":id");
|
|
1998
|
-
// Determine metric name based on environment variables
|
|
1999
1997
|
let metricPrefix = "project";
|
|
2000
1998
|
if (process.env.PROJECT_SPONSOR) {
|
|
2001
1999
|
metricPrefix = process.env.PROJECT_SPONSOR;
|
|
@@ -2013,7 +2011,8 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2013
2011
|
},
|
|
2014
2012
|
});
|
|
2015
2013
|
}
|
|
2016
|
-
//
|
|
2014
|
+
// End log session and clean up
|
|
2015
|
+
logger$1.teardown();
|
|
2017
2016
|
logger$1.untag("handler");
|
|
2018
2017
|
//
|
|
2019
2018
|
//
|
|
@@ -2132,14 +2131,6 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2132
2131
|
});
|
|
2133
2132
|
// Update the public logger with the request ID
|
|
2134
2133
|
const invokeUuid = getCurrentInvokeUuid(req);
|
|
2135
|
-
if (invokeUuid) {
|
|
2136
|
-
logger.tag({ invoke: invokeUuid });
|
|
2137
|
-
logger.tag({ shortInvoke: invokeUuid.slice(0, 8) });
|
|
2138
|
-
libLogger.tag({ invoke: invokeUuid });
|
|
2139
|
-
libLogger.tag({ shortInvoke: invokeUuid.slice(0, 8) });
|
|
2140
|
-
log.tag({ invoke: invokeUuid });
|
|
2141
|
-
log.tag({ shortInvoke: invokeUuid.slice(0, 8) });
|
|
2142
|
-
}
|
|
2143
2134
|
if (!name) {
|
|
2144
2135
|
if (handler.name) {
|
|
2145
2136
|
name = handler.name;
|
|
@@ -2148,9 +2139,15 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2148
2139
|
name = JAYPIE.UNKNOWN;
|
|
2149
2140
|
}
|
|
2150
2141
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2142
|
+
const setupTags = { handler: name };
|
|
2143
|
+
if (invokeUuid) {
|
|
2144
|
+
setupTags.invoke = invokeUuid;
|
|
2145
|
+
setupTags.shortInvoke = invokeUuid.slice(0, 8);
|
|
2146
|
+
}
|
|
2147
|
+
logger.setup(setupTags);
|
|
2148
|
+
// TODO: in theory this is redundant
|
|
2149
|
+
libLogger.tag(setupTags);
|
|
2150
|
+
log.tag(setupTags);
|
|
2154
2151
|
libLogger.trace("[jaypie] Express stream init");
|
|
2155
2152
|
// Set req.locals if it doesn't exist
|
|
2156
2153
|
if (!extReq.locals)
|
|
@@ -2265,16 +2262,23 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2265
2262
|
log.info.var({
|
|
2266
2263
|
res: { statusCode: res.statusCode, streaming: true },
|
|
2267
2264
|
});
|
|
2265
|
+
// Construct normalized path for reporting and metrics
|
|
2266
|
+
let path = (req.baseUrl || "") + (req.url || "");
|
|
2267
|
+
if (!path.startsWith("/")) {
|
|
2268
|
+
path = "/" + path;
|
|
2269
|
+
}
|
|
2270
|
+
if (path.length > 1 && path.endsWith("/")) {
|
|
2271
|
+
path = path.slice(0, -1);
|
|
2272
|
+
}
|
|
2273
|
+
path = path.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ":id");
|
|
2274
|
+
// Add request data to session report
|
|
2275
|
+
logger.report({
|
|
2276
|
+
method: req.method,
|
|
2277
|
+
path,
|
|
2278
|
+
status: String(res.statusCode),
|
|
2279
|
+
});
|
|
2268
2280
|
// Submit metric if Datadog is configured
|
|
2269
2281
|
if (hasDatadogEnv()) {
|
|
2270
|
-
let path = (req.baseUrl || "") + (req.url || "");
|
|
2271
|
-
if (!path.startsWith("/")) {
|
|
2272
|
-
path = "/" + path;
|
|
2273
|
-
}
|
|
2274
|
-
if (path.length > 1 && path.endsWith("/")) {
|
|
2275
|
-
path = path.slice(0, -1);
|
|
2276
|
-
}
|
|
2277
|
-
path = path.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ":id");
|
|
2278
2282
|
let metricPrefix = "project";
|
|
2279
2283
|
if (process.env.PROJECT_SPONSOR) {
|
|
2280
2284
|
metricPrefix = process.env.PROJECT_SPONSOR;
|
|
@@ -2292,7 +2296,8 @@ function expressStreamHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2292
2296
|
},
|
|
2293
2297
|
});
|
|
2294
2298
|
}
|
|
2295
|
-
//
|
|
2299
|
+
// End log session and clean up
|
|
2300
|
+
logger.teardown();
|
|
2296
2301
|
logger.untag("handler");
|
|
2297
2302
|
}
|
|
2298
2303
|
};
|