@vtex/api 6.49.5-beta.0 → 6.49.5
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/lib/tracing/utils.d.ts +5 -0
- package/lib/tracing/utils.js +53 -1
- package/package.json +23 -2
package/lib/tracing/utils.d.ts
CHANGED
|
@@ -3,9 +3,14 @@ export interface TraceInfo {
|
|
|
3
3
|
traceId?: string;
|
|
4
4
|
isSampled: boolean;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Headers that are interesting for tracing and debugging purposes
|
|
8
|
+
*/
|
|
9
|
+
export declare const INTERESTING_HEADERS: string[];
|
|
6
10
|
export declare function getTraceInfo(span?: Span): TraceInfo;
|
|
7
11
|
/**
|
|
8
12
|
* Do a shallow copy of a headers object and redacts sensitive information.
|
|
13
|
+
* Only includes headers that are in the INTERESTING_HEADERS whitelist.
|
|
9
14
|
*
|
|
10
15
|
* @param headersObj The headers object
|
|
11
16
|
* @param resultFieldsPrefix The prefix that will be added to each field on the result object
|
package/lib/tracing/utils.js
CHANGED
|
@@ -1,7 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cloneAndSanitizeHeaders = exports.getTraceInfo = void 0;
|
|
3
|
+
exports.cloneAndSanitizeHeaders = exports.getTraceInfo = exports.INTERESTING_HEADERS = void 0;
|
|
4
4
|
const node_error_report_1 = require("@vtex/node-error-report");
|
|
5
|
+
/**
|
|
6
|
+
* Headers that are interesting for tracing and debugging purposes
|
|
7
|
+
*/
|
|
8
|
+
exports.INTERESTING_HEADERS = [
|
|
9
|
+
// Request/Response Identification & Routing
|
|
10
|
+
'x-request-id',
|
|
11
|
+
'x-correlation-id',
|
|
12
|
+
'x-trace-id',
|
|
13
|
+
'x-span-id',
|
|
14
|
+
'x-forwarded-for',
|
|
15
|
+
'x-real-ip',
|
|
16
|
+
'host',
|
|
17
|
+
'referer',
|
|
18
|
+
// Content & Encoding
|
|
19
|
+
'content-type',
|
|
20
|
+
'content-length',
|
|
21
|
+
'content-encoding',
|
|
22
|
+
'accept',
|
|
23
|
+
'accept-encoding',
|
|
24
|
+
'accept-language',
|
|
25
|
+
// Caching & Performance
|
|
26
|
+
'cache-control',
|
|
27
|
+
'etag',
|
|
28
|
+
'if-none-match',
|
|
29
|
+
'expires',
|
|
30
|
+
'last-modified',
|
|
31
|
+
// Client Information
|
|
32
|
+
'user-agent',
|
|
33
|
+
'x-forwarded-proto',
|
|
34
|
+
'x-forwarded-host',
|
|
35
|
+
'x-forwarded-port',
|
|
36
|
+
// VTEX/E-commerce Specific (x-vtex-* headers are handled automatically)
|
|
37
|
+
'x-router-cache',
|
|
38
|
+
'x-powered-by-vtex-cache',
|
|
39
|
+
'jaeger-debug-id',
|
|
40
|
+
// API & Service Headers
|
|
41
|
+
'x-api-version',
|
|
42
|
+
'x-service-name',
|
|
43
|
+
'x-timeout',
|
|
44
|
+
'retry-after',
|
|
45
|
+
// Security (will be sanitized)
|
|
46
|
+
'authorization',
|
|
47
|
+
'cookie',
|
|
48
|
+
];
|
|
49
|
+
// Create the set once for performance
|
|
50
|
+
const INTERESTING_HEADERS_SET = new Set(exports.INTERESTING_HEADERS.map(h => h.toLowerCase()));
|
|
5
51
|
function getTraceInfo(span) {
|
|
6
52
|
var _a, _b;
|
|
7
53
|
const spanContext = span === null || span === void 0 ? void 0 : span.context();
|
|
@@ -13,6 +59,7 @@ function getTraceInfo(span) {
|
|
|
13
59
|
exports.getTraceInfo = getTraceInfo;
|
|
14
60
|
/**
|
|
15
61
|
* Do a shallow copy of a headers object and redacts sensitive information.
|
|
62
|
+
* Only includes headers that are in the INTERESTING_HEADERS whitelist.
|
|
16
63
|
*
|
|
17
64
|
* @param headersObj The headers object
|
|
18
65
|
* @param resultFieldsPrefix The prefix that will be added to each field on the result object
|
|
@@ -21,6 +68,11 @@ const cloneAndSanitizeHeaders = (headersObj, resultFieldsPrefix = '') => {
|
|
|
21
68
|
const ret = {};
|
|
22
69
|
const entries = Object.entries(headersObj);
|
|
23
70
|
for (const [key, val] of entries) {
|
|
71
|
+
const lowerKey = key.toLowerCase();
|
|
72
|
+
// Only include headers that are in our whitelist or start with x-vtex-
|
|
73
|
+
if (!INTERESTING_HEADERS_SET.has(lowerKey) && !lowerKey.startsWith('x-vtex-')) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
24
76
|
// Most of the time val is a string, but there are some cases, for example when we do a axios interceptor,
|
|
25
77
|
// that a header field can contain an object, for example:
|
|
26
78
|
// ```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex/api",
|
|
3
|
-
"version": "6.49.5
|
|
3
|
+
"version": "6.49.5",
|
|
4
4
|
"description": "VTEX I/O API client",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@types/koa": "^2.11.0",
|
|
51
51
|
"@types/koa-compose": "^3.2.3",
|
|
52
|
-
"@vtex/diagnostics-nodejs": "0.1.0-beta.
|
|
52
|
+
"@vtex/diagnostics-nodejs": "0.1.0-beta.8",
|
|
53
53
|
"@vtex/node-error-report": "^0.0.3",
|
|
54
54
|
"@wry/equality": "^0.1.9",
|
|
55
55
|
"agentkeepalive": "^4.0.2",
|
|
@@ -124,5 +124,26 @@
|
|
|
124
124
|
"typemoq": "^2.1.0",
|
|
125
125
|
"typescript": "^4.4.4",
|
|
126
126
|
"typescript-json-schema": "^0.52.0"
|
|
127
|
+
},
|
|
128
|
+
"resolutions": {
|
|
129
|
+
"@opentelemetry/core": "1.30.1",
|
|
130
|
+
"@opentelemetry/exporter-metrics-otlp-grpc": "0.57.2",
|
|
131
|
+
"@opentelemetry/exporter-metrics-otlp-http": "0.57.2",
|
|
132
|
+
"@opentelemetry/exporter-logs-otlp-grpc": "0.57.2",
|
|
133
|
+
"@opentelemetry/exporter-logs-otlp-http": "0.57.2",
|
|
134
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.57.2",
|
|
135
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.57.2",
|
|
136
|
+
"@opentelemetry/instrumentation": "0.57.2",
|
|
137
|
+
"@opentelemetry/instrumentation-http": "0.57.2",
|
|
138
|
+
"@opentelemetry/instrumentation-grpc": "0.57.2",
|
|
139
|
+
"@opentelemetry/instrumentation-net": "0.43.1",
|
|
140
|
+
"@opentelemetry/propagator-b3": "1.30.1",
|
|
141
|
+
"@opentelemetry/resource-detector-aws": "1.12.0",
|
|
142
|
+
"@opentelemetry/resources": "1.30.1",
|
|
143
|
+
"@opentelemetry/sdk-node": "0.57.2",
|
|
144
|
+
"@opentelemetry/sdk-logs": "0.57.2",
|
|
145
|
+
"@opentelemetry/sdk-metrics": "1.30.1",
|
|
146
|
+
"@opentelemetry/sdk-trace-base": "1.30.1",
|
|
147
|
+
"@opentelemetry/sdk-trace-node": "1.30.1"
|
|
127
148
|
}
|
|
128
149
|
}
|