@zuplo/cli 7.7.8 → 7.7.9
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/node_modules/@posthog/core/dist/error-tracking/parsers/base.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/error-tracking/parsers/base.js +19 -2
- package/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs +19 -2
- package/node_modules/@posthog/core/dist/index.d.ts +7 -0
- package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/index.js +82 -21
- package/node_modules/@posthog/core/dist/index.mjs +4 -0
- package/node_modules/@posthog/core/dist/logs/index.d.ts +3 -2
- package/node_modules/@posthog/core/dist/logs/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/logs/index.js +28 -22
- package/node_modules/@posthog/core/dist/logs/index.mjs +29 -23
- package/node_modules/@posthog/core/dist/logs/logs-utils.js +1 -1
- package/node_modules/@posthog/core/dist/logs/logs-utils.mjs +2 -2
- package/node_modules/@posthog/core/dist/logs/types.d.ts +2 -2
- package/node_modules/@posthog/core/dist/metrics/index.d.ts +5 -2
- package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/metrics/index.js +28 -14
- package/node_modules/@posthog/core/dist/metrics/index.mjs +29 -15
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.js +1 -2
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs +2 -3
- package/node_modules/@posthog/core/dist/metrics/types.d.ts +7 -0
- package/node_modules/@posthog/core/dist/metrics/types.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +32 -4
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.js +68 -20
- package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +68 -20
- package/node_modules/@posthog/core/dist/traces/config.d.ts +13 -0
- package/node_modules/@posthog/core/dist/traces/config.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/config.js +101 -0
- package/node_modules/@posthog/core/dist/traces/config.mjs +63 -0
- package/node_modules/@posthog/core/dist/traces/context.d.ts +18 -0
- package/node_modules/@posthog/core/dist/traces/context.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/context.js +53 -0
- package/node_modules/@posthog/core/dist/traces/context.mjs +15 -0
- package/node_modules/@posthog/core/dist/traces/ids.d.ts +12 -0
- package/node_modules/@posthog/core/dist/traces/ids.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/ids.js +92 -0
- package/node_modules/@posthog/core/dist/traces/ids.mjs +42 -0
- package/node_modules/@posthog/core/dist/traces/index.d.ts +150 -0
- package/node_modules/@posthog/core/dist/traces/index.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/index.js +551 -0
- package/node_modules/@posthog/core/dist/traces/index.mjs +513 -0
- package/node_modules/@posthog/core/dist/traces/otlp.d.ts +24 -0
- package/node_modules/@posthog/core/dist/traces/otlp.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/otlp.js +158 -0
- package/node_modules/@posthog/core/dist/traces/otlp.mjs +108 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.d.ts +32 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.js +93 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.mjs +43 -0
- package/node_modules/@posthog/core/dist/traces/span.d.ts +189 -0
- package/node_modules/@posthog/core/dist/traces/span.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/span.js +533 -0
- package/node_modules/@posthog/core/dist/traces/span.mjs +462 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.d.ts +51 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.js +116 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.mjs +63 -0
- package/node_modules/@posthog/core/dist/traces/types.d.ts +114 -0
- package/node_modules/@posthog/core/dist/traces/types.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/types.js +18 -0
- package/node_modules/@posthog/core/dist/traces/types.mjs +1 -0
- package/node_modules/@posthog/core/dist/utils/backoff.d.ts +23 -0
- package/node_modules/@posthog/core/dist/utils/backoff.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/utils/backoff.js +65 -0
- package/node_modules/@posthog/core/dist/utils/backoff.mjs +14 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.d.ts +26 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.js +67 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.mjs +29 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.d.ts +7 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/json-utils.js +27 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.mjs +25 -1
- package/node_modules/@posthog/core/dist/utils/otlp-resource.d.ts +13 -2
- package/node_modules/@posthog/core/dist/utils/otlp-resource.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/otlp-resource.js +34 -7
- package/node_modules/@posthog/core/dist/utils/otlp-resource.mjs +26 -2
- package/node_modules/@posthog/core/dist/utils/retry-after.d.ts +55 -0
- package/node_modules/@posthog/core/dist/utils/retry-after.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/utils/retry-after.js +95 -0
- package/node_modules/@posthog/core/dist/utils/retry-after.mjs +50 -0
- package/node_modules/@posthog/core/package.json +3 -3
- package/node_modules/@posthog/core/src/error-tracking/parsers/base.spec.ts +77 -7
- package/node_modules/@posthog/core/src/error-tracking/parsers/base.ts +42 -19
- package/node_modules/@posthog/core/src/index.ts +18 -0
- package/node_modules/@posthog/core/src/logs/index.spec.ts +490 -2
- package/node_modules/@posthog/core/src/logs/index.ts +63 -31
- package/node_modules/@posthog/core/src/logs/logs-utils.ts +2 -2
- package/node_modules/@posthog/core/src/logs/types.ts +2 -2
- package/node_modules/@posthog/core/src/metrics/index.spec.ts +304 -0
- package/node_modules/@posthog/core/src/metrics/index.ts +53 -16
- package/node_modules/@posthog/core/src/metrics/metrics-utils.ts +2 -3
- package/node_modules/@posthog/core/src/metrics/types.ts +10 -2
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +157 -38
- package/node_modules/@posthog/core/src/traces/config.spec.ts +271 -0
- package/node_modules/@posthog/core/src/traces/config.ts +142 -0
- package/node_modules/@posthog/core/src/traces/context.ts +30 -0
- package/node_modules/@posthog/core/src/traces/ids.spec.ts +115 -0
- package/node_modules/@posthog/core/src/traces/ids.ts +75 -0
- package/node_modules/@posthog/core/src/traces/index.spec.ts +3187 -0
- package/node_modules/@posthog/core/src/traces/index.ts +1060 -0
- package/node_modules/@posthog/core/src/traces/live-spans.spec.ts +69 -0
- package/node_modules/@posthog/core/src/traces/otlp.spec.ts +368 -0
- package/node_modules/@posthog/core/src/traces/otlp.ts +191 -0
- package/node_modules/@posthog/core/src/traces/sanitize.ts +116 -0
- package/node_modules/@posthog/core/src/traces/span.spec.ts +1122 -0
- package/node_modules/@posthog/core/src/traces/span.ts +822 -0
- package/node_modules/@posthog/core/src/traces/traceparent.spec.ts +184 -0
- package/node_modules/@posthog/core/src/traces/traceparent.ts +172 -0
- package/node_modules/@posthog/core/src/traces/types.ts +140 -0
- package/node_modules/@posthog/core/src/utils/backoff.ts +44 -0
- package/node_modules/@posthog/core/src/utils/flush-timer.ts +50 -0
- package/node_modules/@posthog/core/src/utils/json-utils.ts +33 -0
- package/node_modules/@posthog/core/src/utils/otlp-resource.spec.ts +55 -9
- package/node_modules/@posthog/core/src/utils/otlp-resource.ts +45 -4
- package/node_modules/@posthog/core/src/utils/retry-after.ts +135 -0
- package/node_modules/@posthog/types/dist/index.d.ts +1 -0
- package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +10 -5
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/traces.d.ts +387 -0
- package/node_modules/@posthog/types/dist/traces.d.ts.map +1 -0
- package/node_modules/@posthog/types/dist/traces.js +18 -0
- package/node_modules/@posthog/types/dist/traces.mjs +1 -0
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/index.ts +19 -0
- package/node_modules/@posthog/types/src/posthog-config.ts +10 -5
- package/node_modules/@posthog/types/src/traces.ts +429 -0
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-DRQ5CMVC.js → chunk-KNAYKBEE.js} +80 -80
- package/node_modules/@zuplo/runtime/out/esm/chunk-KNAYKBEE.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-DRQ5CMVC.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-DRQ5CMVC.js.LEGAL.txt → chunk-KNAYKBEE.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
buildOtlpSpan: ()=>buildOtlpSpan,
|
|
32
|
+
buildOtlpTracesPayload: ()=>buildOtlpTracesPayload,
|
|
33
|
+
buildTracesResourceAttributes: ()=>buildTracesResourceAttributes,
|
|
34
|
+
msToUnixNanoString: ()=>msToUnixNanoString,
|
|
35
|
+
spanKindToOtlp: ()=>spanKindToOtlp
|
|
36
|
+
});
|
|
37
|
+
const external_span_js_namespaceObject = require("./span.js");
|
|
38
|
+
const otlp_any_value_js_namespaceObject = require("../utils/otlp-any-value.js");
|
|
39
|
+
const json_utils_js_namespaceObject = require("../utils/json-utils.js");
|
|
40
|
+
const otlp_resource_js_namespaceObject = require("../utils/otlp-resource.js");
|
|
41
|
+
const SPAN_KIND_TO_OTLP = {
|
|
42
|
+
internal: 1,
|
|
43
|
+
server: 2,
|
|
44
|
+
client: 3,
|
|
45
|
+
producer: 4,
|
|
46
|
+
consumer: 5
|
|
47
|
+
};
|
|
48
|
+
const SPAN_STATUS_TO_OTLP = {
|
|
49
|
+
ok: 1,
|
|
50
|
+
error: 2
|
|
51
|
+
};
|
|
52
|
+
const TRACE_FLAGS_SAMPLED = 0x01;
|
|
53
|
+
const SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE = 0x100;
|
|
54
|
+
const SPAN_FLAGS_CONTEXT_IS_REMOTE = 0x200;
|
|
55
|
+
function spanFlags(record) {
|
|
56
|
+
const traceFlags = parseInt(record.traceFlags, 16);
|
|
57
|
+
const w3c = Number.isFinite(traceFlags) ? 0xff & traceFlags : TRACE_FLAGS_SAMPLED;
|
|
58
|
+
return w3c | SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE | (record.parentIsRemote ? SPAN_FLAGS_CONTEXT_IS_REMOTE : 0);
|
|
59
|
+
}
|
|
60
|
+
function wireString(value) {
|
|
61
|
+
if ('string' == typeof value) return (0, json_utils_js_namespaceObject.sanitizeString)(value);
|
|
62
|
+
try {
|
|
63
|
+
return (0, json_utils_js_namespaceObject.sanitizeString)(String(value));
|
|
64
|
+
} catch {
|
|
65
|
+
return json_utils_js_namespaceObject.UNSERIALIZABLE_VALUE;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function spanKindToOtlp(kind) {
|
|
69
|
+
if (kind && Object.prototype.hasOwnProperty.call(SPAN_KIND_TO_OTLP, kind)) return SPAN_KIND_TO_OTLP[kind];
|
|
70
|
+
return SPAN_KIND_TO_OTLP.internal;
|
|
71
|
+
}
|
|
72
|
+
function msToUnixNanoString(ms) {
|
|
73
|
+
let whole = Math.floor(ms);
|
|
74
|
+
let fractionalNanos = Math.round((ms - whole) * 1e6);
|
|
75
|
+
if (fractionalNanos >= 1e6) {
|
|
76
|
+
whole += 1;
|
|
77
|
+
fractionalNanos = 0;
|
|
78
|
+
}
|
|
79
|
+
return String(whole) + String(fractionalNanos).padStart(6, '0');
|
|
80
|
+
}
|
|
81
|
+
function toOtlpEvent(event, logger) {
|
|
82
|
+
const encoded = {
|
|
83
|
+
name: wireString(event.name),
|
|
84
|
+
timeUnixNano: msToUnixNanoString(event.timestamp)
|
|
85
|
+
};
|
|
86
|
+
if (event.attributes) {
|
|
87
|
+
const attributes = (0, otlp_any_value_js_namespaceObject.toOtlpKeyValueList)(event.attributes, logger);
|
|
88
|
+
if (attributes.length) encoded.attributes = attributes;
|
|
89
|
+
}
|
|
90
|
+
const dropped = (0, external_span_js_namespaceObject.nonNegativeCount)(event.droppedAttributesCount);
|
|
91
|
+
if (dropped) encoded.droppedAttributesCount = dropped;
|
|
92
|
+
return encoded;
|
|
93
|
+
}
|
|
94
|
+
function buildOtlpSpan(record, logger) {
|
|
95
|
+
const span = {
|
|
96
|
+
traceId: record.traceId,
|
|
97
|
+
spanId: record.spanId,
|
|
98
|
+
name: wireString(record.name),
|
|
99
|
+
kind: spanKindToOtlp(record.kind),
|
|
100
|
+
startTimeUnixNano: msToUnixNanoString(record.startTime),
|
|
101
|
+
endTimeUnixNano: msToUnixNanoString(record.endTime),
|
|
102
|
+
flags: spanFlags(record)
|
|
103
|
+
};
|
|
104
|
+
if (record.parentSpanId) span.parentSpanId = record.parentSpanId;
|
|
105
|
+
if (record.traceState) span.traceState = wireString(record.traceState);
|
|
106
|
+
const attributes = (0, otlp_any_value_js_namespaceObject.toOtlpKeyValueList)(record.attributes, logger);
|
|
107
|
+
if (attributes.length) span.attributes = attributes;
|
|
108
|
+
if (record.events.length) span.events = record.events.map((event)=>toOtlpEvent(event, logger));
|
|
109
|
+
const droppedAttributes = (0, external_span_js_namespaceObject.nonNegativeCount)(record.droppedAttributesCount);
|
|
110
|
+
if (droppedAttributes) span.droppedAttributesCount = droppedAttributes;
|
|
111
|
+
const droppedEvents = (0, external_span_js_namespaceObject.nonNegativeCount)(record.droppedEventsCount);
|
|
112
|
+
if (droppedEvents) span.droppedEventsCount = droppedEvents;
|
|
113
|
+
if (record.status) span.status = {
|
|
114
|
+
code: SPAN_STATUS_TO_OTLP[record.status.code],
|
|
115
|
+
...record.status.message && {
|
|
116
|
+
message: wireString(record.status.message)
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return span;
|
|
120
|
+
}
|
|
121
|
+
function buildTracesResourceAttributes(config, sdkName, sdkVersion) {
|
|
122
|
+
return (0, otlp_resource_js_namespaceObject.buildOtlpResourceAttributes)(config, sdkName, sdkVersion);
|
|
123
|
+
}
|
|
124
|
+
function buildOtlpTracesPayload(spans, resourceAttributes, scopeName, scopeVersion, logger) {
|
|
125
|
+
return {
|
|
126
|
+
resourceSpans: [
|
|
127
|
+
{
|
|
128
|
+
resource: {
|
|
129
|
+
attributes: (0, otlp_resource_js_namespaceObject.toOtlpResourceKeyValueList)(resourceAttributes, logger)
|
|
130
|
+
},
|
|
131
|
+
scopeSpans: [
|
|
132
|
+
{
|
|
133
|
+
scope: {
|
|
134
|
+
name: scopeName,
|
|
135
|
+
version: scopeVersion
|
|
136
|
+
},
|
|
137
|
+
spans
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
exports.buildOtlpSpan = __webpack_exports__.buildOtlpSpan;
|
|
145
|
+
exports.buildOtlpTracesPayload = __webpack_exports__.buildOtlpTracesPayload;
|
|
146
|
+
exports.buildTracesResourceAttributes = __webpack_exports__.buildTracesResourceAttributes;
|
|
147
|
+
exports.msToUnixNanoString = __webpack_exports__.msToUnixNanoString;
|
|
148
|
+
exports.spanKindToOtlp = __webpack_exports__.spanKindToOtlp;
|
|
149
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
150
|
+
"buildOtlpSpan",
|
|
151
|
+
"buildOtlpTracesPayload",
|
|
152
|
+
"buildTracesResourceAttributes",
|
|
153
|
+
"msToUnixNanoString",
|
|
154
|
+
"spanKindToOtlp"
|
|
155
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
156
|
+
Object.defineProperty(exports, '__esModule', {
|
|
157
|
+
value: true
|
|
158
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { nonNegativeCount } from "./span.mjs";
|
|
2
|
+
import { toOtlpKeyValueList } from "../utils/otlp-any-value.mjs";
|
|
3
|
+
import { UNSERIALIZABLE_VALUE, sanitizeString } from "../utils/json-utils.mjs";
|
|
4
|
+
import { buildOtlpResourceAttributes, toOtlpResourceKeyValueList } from "../utils/otlp-resource.mjs";
|
|
5
|
+
const SPAN_KIND_TO_OTLP = {
|
|
6
|
+
internal: 1,
|
|
7
|
+
server: 2,
|
|
8
|
+
client: 3,
|
|
9
|
+
producer: 4,
|
|
10
|
+
consumer: 5
|
|
11
|
+
};
|
|
12
|
+
const SPAN_STATUS_TO_OTLP = {
|
|
13
|
+
ok: 1,
|
|
14
|
+
error: 2
|
|
15
|
+
};
|
|
16
|
+
const TRACE_FLAGS_SAMPLED = 0x01;
|
|
17
|
+
const SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE = 0x100;
|
|
18
|
+
const SPAN_FLAGS_CONTEXT_IS_REMOTE = 0x200;
|
|
19
|
+
function spanFlags(record) {
|
|
20
|
+
const traceFlags = parseInt(record.traceFlags, 16);
|
|
21
|
+
const w3c = Number.isFinite(traceFlags) ? 0xff & traceFlags : TRACE_FLAGS_SAMPLED;
|
|
22
|
+
return w3c | SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE | (record.parentIsRemote ? SPAN_FLAGS_CONTEXT_IS_REMOTE : 0);
|
|
23
|
+
}
|
|
24
|
+
function wireString(value) {
|
|
25
|
+
if ('string' == typeof value) return sanitizeString(value);
|
|
26
|
+
try {
|
|
27
|
+
return sanitizeString(String(value));
|
|
28
|
+
} catch {
|
|
29
|
+
return UNSERIALIZABLE_VALUE;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function spanKindToOtlp(kind) {
|
|
33
|
+
if (kind && Object.prototype.hasOwnProperty.call(SPAN_KIND_TO_OTLP, kind)) return SPAN_KIND_TO_OTLP[kind];
|
|
34
|
+
return SPAN_KIND_TO_OTLP.internal;
|
|
35
|
+
}
|
|
36
|
+
function msToUnixNanoString(ms) {
|
|
37
|
+
let whole = Math.floor(ms);
|
|
38
|
+
let fractionalNanos = Math.round((ms - whole) * 1e6);
|
|
39
|
+
if (fractionalNanos >= 1e6) {
|
|
40
|
+
whole += 1;
|
|
41
|
+
fractionalNanos = 0;
|
|
42
|
+
}
|
|
43
|
+
return String(whole) + String(fractionalNanos).padStart(6, '0');
|
|
44
|
+
}
|
|
45
|
+
function toOtlpEvent(event, logger) {
|
|
46
|
+
const encoded = {
|
|
47
|
+
name: wireString(event.name),
|
|
48
|
+
timeUnixNano: msToUnixNanoString(event.timestamp)
|
|
49
|
+
};
|
|
50
|
+
if (event.attributes) {
|
|
51
|
+
const attributes = toOtlpKeyValueList(event.attributes, logger);
|
|
52
|
+
if (attributes.length) encoded.attributes = attributes;
|
|
53
|
+
}
|
|
54
|
+
const dropped = nonNegativeCount(event.droppedAttributesCount);
|
|
55
|
+
if (dropped) encoded.droppedAttributesCount = dropped;
|
|
56
|
+
return encoded;
|
|
57
|
+
}
|
|
58
|
+
function buildOtlpSpan(record, logger) {
|
|
59
|
+
const span = {
|
|
60
|
+
traceId: record.traceId,
|
|
61
|
+
spanId: record.spanId,
|
|
62
|
+
name: wireString(record.name),
|
|
63
|
+
kind: spanKindToOtlp(record.kind),
|
|
64
|
+
startTimeUnixNano: msToUnixNanoString(record.startTime),
|
|
65
|
+
endTimeUnixNano: msToUnixNanoString(record.endTime),
|
|
66
|
+
flags: spanFlags(record)
|
|
67
|
+
};
|
|
68
|
+
if (record.parentSpanId) span.parentSpanId = record.parentSpanId;
|
|
69
|
+
if (record.traceState) span.traceState = wireString(record.traceState);
|
|
70
|
+
const attributes = toOtlpKeyValueList(record.attributes, logger);
|
|
71
|
+
if (attributes.length) span.attributes = attributes;
|
|
72
|
+
if (record.events.length) span.events = record.events.map((event)=>toOtlpEvent(event, logger));
|
|
73
|
+
const droppedAttributes = nonNegativeCount(record.droppedAttributesCount);
|
|
74
|
+
if (droppedAttributes) span.droppedAttributesCount = droppedAttributes;
|
|
75
|
+
const droppedEvents = nonNegativeCount(record.droppedEventsCount);
|
|
76
|
+
if (droppedEvents) span.droppedEventsCount = droppedEvents;
|
|
77
|
+
if (record.status) span.status = {
|
|
78
|
+
code: SPAN_STATUS_TO_OTLP[record.status.code],
|
|
79
|
+
...record.status.message && {
|
|
80
|
+
message: wireString(record.status.message)
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return span;
|
|
84
|
+
}
|
|
85
|
+
function buildTracesResourceAttributes(config, sdkName, sdkVersion) {
|
|
86
|
+
return buildOtlpResourceAttributes(config, sdkName, sdkVersion);
|
|
87
|
+
}
|
|
88
|
+
function buildOtlpTracesPayload(spans, resourceAttributes, scopeName, scopeVersion, logger) {
|
|
89
|
+
return {
|
|
90
|
+
resourceSpans: [
|
|
91
|
+
{
|
|
92
|
+
resource: {
|
|
93
|
+
attributes: toOtlpResourceKeyValueList(resourceAttributes, logger)
|
|
94
|
+
},
|
|
95
|
+
scopeSpans: [
|
|
96
|
+
{
|
|
97
|
+
scope: {
|
|
98
|
+
name: scopeName,
|
|
99
|
+
version: scopeVersion
|
|
100
|
+
},
|
|
101
|
+
spans
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export { buildOtlpSpan, buildOtlpTracesPayload, buildTracesResourceAttributes, msToUnixNanoString, spanKindToOtlp };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Logger } from '../types';
|
|
2
|
+
import type { SpanTimeInput } from '@posthog/types';
|
|
3
|
+
/**
|
|
4
|
+
* Span and event names must be non-empty. An empty or non-string name is
|
|
5
|
+
* replaced rather than dropped, so a mis-instrumented call site loses its name,
|
|
6
|
+
* not its span. `label` names what is being sanitized in the warning.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sanitizeName(name: unknown, label: string, maxLength: number, logger?: Logger): string;
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes a caller-supplied time to a millisecond epoch.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` for anything unusable — the wrong type, `NaN`, or outside
|
|
13
|
+
* the representable range — leaving the caller to fall back to a derived time.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toEpochMs(value: SpanTimeInput | undefined): number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a caller-supplied start time, warning when it is deep enough in the
|
|
18
|
+
* past that the server will clamp it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveStartTime(value: SpanTimeInput | undefined, now: number, logger?: Logger): number;
|
|
21
|
+
/**
|
|
22
|
+
* Corrects an end time that precedes its start, producing a zero-duration span
|
|
23
|
+
* rather than a negative one the server would reject.
|
|
24
|
+
*/
|
|
25
|
+
export declare function clampEndTime(endTime: number, startTime: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Keeps a caller-supplied end or event time inside the representable range,
|
|
28
|
+
* falling back to the span's own clock basis when it is unusable. `label` names
|
|
29
|
+
* what is being sanitized in the warning.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveSuppliedTime(value: SpanTimeInput | undefined, derived: number, label: string, logger?: Logger): number;
|
|
32
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/traces/sanitize.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAanE;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CASrG;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAoB9E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBvG;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CASR"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const FALLBACK_SPAN_NAME = 'unknown';
|
|
31
|
+
const MAX_TIMESTAMP_MS = 9223372036854;
|
|
32
|
+
const MIN_TIMESTAMP_MS = 0;
|
|
33
|
+
const DEEP_BACKDATE_WARNING_MS = 86400000;
|
|
34
|
+
function sanitizeName(name, label, maxLength, logger) {
|
|
35
|
+
if ('string' == typeof name && name.trim()) return name.length > maxLength ? name.slice(0, maxLength) : name;
|
|
36
|
+
logger?.debug(`${label} must be a non-empty string; using "${FALLBACK_SPAN_NAME}"`);
|
|
37
|
+
return FALLBACK_SPAN_NAME;
|
|
38
|
+
}
|
|
39
|
+
function toEpochMs(value) {
|
|
40
|
+
if (null == value) return;
|
|
41
|
+
let ms = value;
|
|
42
|
+
if (value instanceof Date) try {
|
|
43
|
+
ms = value.getTime();
|
|
44
|
+
} catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if ('number' != typeof ms || !Number.isFinite(ms)) return;
|
|
48
|
+
if (ms < MIN_TIMESTAMP_MS || ms > MAX_TIMESTAMP_MS) return;
|
|
49
|
+
return ms;
|
|
50
|
+
}
|
|
51
|
+
function resolveStartTime(value, now, logger) {
|
|
52
|
+
const supplied = toEpochMs(value);
|
|
53
|
+
if (void 0 === supplied) {
|
|
54
|
+
if (void 0 !== value) logger?.debug('Span startTime is out of range or not a valid time; using the current time');
|
|
55
|
+
return now;
|
|
56
|
+
}
|
|
57
|
+
if (now - supplied > DEEP_BACKDATE_WARNING_MS) logger?.debug('Span startTime is more than 24 hours in the past; the server will clamp it to receive time and keep the original in $originalTimestamp');
|
|
58
|
+
else if (supplied > now) logger?.debug('Span startTime is in the future; the span may export with a zero duration');
|
|
59
|
+
return supplied;
|
|
60
|
+
}
|
|
61
|
+
function clampEndTime(endTime, startTime) {
|
|
62
|
+
return endTime < startTime ? startTime : endTime;
|
|
63
|
+
}
|
|
64
|
+
function resolveSuppliedTime(value, derived, label, logger) {
|
|
65
|
+
const supplied = toEpochMs(value);
|
|
66
|
+
if (void 0 === supplied) {
|
|
67
|
+
if (void 0 !== value) logger?.debug(`Span ${label} is out of range or not a valid time; using the derived time`);
|
|
68
|
+
return derived;
|
|
69
|
+
}
|
|
70
|
+
return supplied;
|
|
71
|
+
}
|
|
72
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
73
|
+
clampEndTime: ()=>clampEndTime,
|
|
74
|
+
resolveStartTime: ()=>resolveStartTime,
|
|
75
|
+
resolveSuppliedTime: ()=>resolveSuppliedTime,
|
|
76
|
+
sanitizeName: ()=>sanitizeName,
|
|
77
|
+
toEpochMs: ()=>toEpochMs
|
|
78
|
+
});
|
|
79
|
+
exports.clampEndTime = __webpack_exports__.clampEndTime;
|
|
80
|
+
exports.resolveStartTime = __webpack_exports__.resolveStartTime;
|
|
81
|
+
exports.resolveSuppliedTime = __webpack_exports__.resolveSuppliedTime;
|
|
82
|
+
exports.sanitizeName = __webpack_exports__.sanitizeName;
|
|
83
|
+
exports.toEpochMs = __webpack_exports__.toEpochMs;
|
|
84
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
85
|
+
"clampEndTime",
|
|
86
|
+
"resolveStartTime",
|
|
87
|
+
"resolveSuppliedTime",
|
|
88
|
+
"sanitizeName",
|
|
89
|
+
"toEpochMs"
|
|
90
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
91
|
+
Object.defineProperty(exports, '__esModule', {
|
|
92
|
+
value: true
|
|
93
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const FALLBACK_SPAN_NAME = 'unknown';
|
|
2
|
+
const MAX_TIMESTAMP_MS = 9223372036854;
|
|
3
|
+
const MIN_TIMESTAMP_MS = 0;
|
|
4
|
+
const DEEP_BACKDATE_WARNING_MS = 86400000;
|
|
5
|
+
function sanitizeName(name, label, maxLength, logger) {
|
|
6
|
+
if ('string' == typeof name && name.trim()) return name.length > maxLength ? name.slice(0, maxLength) : name;
|
|
7
|
+
logger?.debug(`${label} must be a non-empty string; using "${FALLBACK_SPAN_NAME}"`);
|
|
8
|
+
return FALLBACK_SPAN_NAME;
|
|
9
|
+
}
|
|
10
|
+
function toEpochMs(value) {
|
|
11
|
+
if (null == value) return;
|
|
12
|
+
let ms = value;
|
|
13
|
+
if (value instanceof Date) try {
|
|
14
|
+
ms = value.getTime();
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if ('number' != typeof ms || !Number.isFinite(ms)) return;
|
|
19
|
+
if (ms < MIN_TIMESTAMP_MS || ms > MAX_TIMESTAMP_MS) return;
|
|
20
|
+
return ms;
|
|
21
|
+
}
|
|
22
|
+
function resolveStartTime(value, now, logger) {
|
|
23
|
+
const supplied = toEpochMs(value);
|
|
24
|
+
if (void 0 === supplied) {
|
|
25
|
+
if (void 0 !== value) logger?.debug('Span startTime is out of range or not a valid time; using the current time');
|
|
26
|
+
return now;
|
|
27
|
+
}
|
|
28
|
+
if (now - supplied > DEEP_BACKDATE_WARNING_MS) logger?.debug('Span startTime is more than 24 hours in the past; the server will clamp it to receive time and keep the original in $originalTimestamp');
|
|
29
|
+
else if (supplied > now) logger?.debug('Span startTime is in the future; the span may export with a zero duration');
|
|
30
|
+
return supplied;
|
|
31
|
+
}
|
|
32
|
+
function clampEndTime(endTime, startTime) {
|
|
33
|
+
return endTime < startTime ? startTime : endTime;
|
|
34
|
+
}
|
|
35
|
+
function resolveSuppliedTime(value, derived, label, logger) {
|
|
36
|
+
const supplied = toEpochMs(value);
|
|
37
|
+
if (void 0 === supplied) {
|
|
38
|
+
if (void 0 !== value) logger?.debug(`Span ${label} is out of range or not a valid time; using the derived time`);
|
|
39
|
+
return derived;
|
|
40
|
+
}
|
|
41
|
+
return supplied;
|
|
42
|
+
}
|
|
43
|
+
export { clampEndTime, resolveStartTime, resolveSuppliedTime, sanitizeName, toEpochMs };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { Span, SpanAttributes, SpanAttributeValue, SpanKind, SpanStatusCode, SpanTimeInput } from '@posthog/types';
|
|
2
|
+
import type { Logger } from '../types';
|
|
3
|
+
import type { SpanContextManager, SpanRecord } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* A monotonic millisecond reading where the platform has one, so an NTP
|
|
6
|
+
* correction mid-span can't produce a negative duration.
|
|
7
|
+
*/
|
|
8
|
+
export declare function monotonicNow(): number | undefined;
|
|
9
|
+
export interface SpanInit {
|
|
10
|
+
traceId: string;
|
|
11
|
+
spanId: string;
|
|
12
|
+
parentSpanId?: string;
|
|
13
|
+
traceState?: string;
|
|
14
|
+
/** The trace-flags byte to propagate; the inbound one when continuing a remote trace. */
|
|
15
|
+
traceFlags?: string;
|
|
16
|
+
/** True when the parent came from a `traceparent` header rather than a local handle. */
|
|
17
|
+
parentIsRemote?: boolean;
|
|
18
|
+
name: string;
|
|
19
|
+
kind: SpanKind;
|
|
20
|
+
attributes: SpanAttributes;
|
|
21
|
+
/** ms epoch. */
|
|
22
|
+
startTime: number;
|
|
23
|
+
/** True when the caller supplied an explicit `startTime`. */
|
|
24
|
+
backdated: boolean;
|
|
25
|
+
/** Keys the SDK attached itself. Exempt from the attribute cap and never evicted. */
|
|
26
|
+
autoAttributeKeys: string[];
|
|
27
|
+
maxAttributes: number;
|
|
28
|
+
maxEvents: number;
|
|
29
|
+
maxAttributesPerEvent: number;
|
|
30
|
+
maxAttributeValueLength: number;
|
|
31
|
+
}
|
|
32
|
+
export declare class PostHogSpan implements Span {
|
|
33
|
+
private readonly _onEnd;
|
|
34
|
+
private readonly _logger?;
|
|
35
|
+
private readonly _traceId;
|
|
36
|
+
private readonly _spanId;
|
|
37
|
+
private readonly _parentSpanId?;
|
|
38
|
+
private readonly _traceState?;
|
|
39
|
+
private readonly _traceFlags;
|
|
40
|
+
private readonly _parentIsRemote;
|
|
41
|
+
private readonly _startTime;
|
|
42
|
+
private readonly _startMono?;
|
|
43
|
+
private _name;
|
|
44
|
+
private _kind;
|
|
45
|
+
private _attributes;
|
|
46
|
+
private _events;
|
|
47
|
+
private _status?;
|
|
48
|
+
private _ended;
|
|
49
|
+
private readonly _autoKeys;
|
|
50
|
+
private readonly _maxAttributes;
|
|
51
|
+
private readonly _maxEvents;
|
|
52
|
+
private readonly _maxAttributesPerEvent;
|
|
53
|
+
private readonly _maxAttributeValueLength;
|
|
54
|
+
private _userAttributeCount;
|
|
55
|
+
private _userEventCount;
|
|
56
|
+
private _droppedAttributes;
|
|
57
|
+
private _droppedEvents;
|
|
58
|
+
constructor(init: SpanInit, _onEnd: (record: SpanRecord, autoKeys: ReadonlySet<string>) => void, _logger?: Logger | undefined);
|
|
59
|
+
/**
|
|
60
|
+
* "Now" on this span's clock basis: start plus monotonic elapsed where we
|
|
61
|
+
* have it, wall clock otherwise.
|
|
62
|
+
*/
|
|
63
|
+
private _now;
|
|
64
|
+
/** Guards every mutator: operations after `end()` no-op with a debug warning. */
|
|
65
|
+
private _mutable;
|
|
66
|
+
/**
|
|
67
|
+
* Writes an attribute unless the span is already at its user-attribute cap.
|
|
68
|
+
*
|
|
69
|
+
* Overwriting a key already on the span always succeeds — the cap counts
|
|
70
|
+
* distinct user keys, not writes — and SDK-attached keys never count toward
|
|
71
|
+
* it, so a span at the cap still carries its person and session ids.
|
|
72
|
+
*/
|
|
73
|
+
private _writeAttribute;
|
|
74
|
+
setAttribute(key: string, value: SpanAttributeValue): this;
|
|
75
|
+
setAttributes(attributes: SpanAttributes): this;
|
|
76
|
+
addEvent(name: string, attributes?: SpanAttributes, timestamp?: SpanTimeInput): this;
|
|
77
|
+
setStatus(status: SpanStatusCode, message?: string): this;
|
|
78
|
+
/** True when the caller explicitly marked the span `ok`; `withSpan` treats that as final. */
|
|
79
|
+
get statusIsExplicitlyOk(): boolean;
|
|
80
|
+
recordException(error: unknown): this;
|
|
81
|
+
updateName(name: string): this;
|
|
82
|
+
traceparent(): string | null;
|
|
83
|
+
tracestate(): string | null;
|
|
84
|
+
/** Context a child span inherits when this handle is its parent. */
|
|
85
|
+
childContext(): {
|
|
86
|
+
traceId: string;
|
|
87
|
+
parentSpanId: string;
|
|
88
|
+
traceState?: string;
|
|
89
|
+
traceFlags: string;
|
|
90
|
+
};
|
|
91
|
+
end(endTime?: SpanTimeInput): void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A caller-visible counter read back as a number, or 0 for anything else.
|
|
95
|
+
* Clamped to the `uint32` the OTLP field is declared as: a `beforeSpanSend` hook
|
|
96
|
+
* can write a larger number onto an event, and one that overflows the field is
|
|
97
|
+
* refused for the whole request.
|
|
98
|
+
*/
|
|
99
|
+
export declare function nonNegativeCount(value: unknown): number;
|
|
100
|
+
/**
|
|
101
|
+
* Re-applies the per-span caps to a record a `beforeSpanSend` hook has already
|
|
102
|
+
* seen. The hook writes to the plain record, not through the span's own guarded
|
|
103
|
+
* writer, so an enriching hook would otherwise push a span past the cap it was
|
|
104
|
+
* trimmed to and back into the 413 path the cap exists to avoid.
|
|
105
|
+
*
|
|
106
|
+
* Earliest-set entries win, matching the span-side rule; SDK-attached keys are
|
|
107
|
+
* exempt. Counts add to whatever the span already dropped.
|
|
108
|
+
*/
|
|
109
|
+
export declare function applySpanLimits(record: SpanRecord, autoKeys: ReadonlySet<string>, maxAttributes: number, maxEvents: number, maxAttributesPerEvent: number, maxAttributeValueLength: number, keysBeforeHook?: readonly string[]): void;
|
|
110
|
+
/**
|
|
111
|
+
* An inert handle returned whenever tracing cannot run — traces unconfigured,
|
|
112
|
+
* SDK disabled, user opted out. Supports the full surface so caller code never
|
|
113
|
+
* branches, and returns `null` from `traceparent()` so an id this SDK never
|
|
114
|
+
* recorded cannot propagate.
|
|
115
|
+
*/
|
|
116
|
+
export declare class NoopSpan implements Span {
|
|
117
|
+
setAttribute(): this;
|
|
118
|
+
setAttributes(): this;
|
|
119
|
+
addEvent(): this;
|
|
120
|
+
setStatus(): this;
|
|
121
|
+
recordException(): this;
|
|
122
|
+
updateName(): this;
|
|
123
|
+
traceparent(): string | null;
|
|
124
|
+
tracestate(): string | null;
|
|
125
|
+
end(): void;
|
|
126
|
+
}
|
|
127
|
+
export declare const NOOP_SPAN: Span;
|
|
128
|
+
/**
|
|
129
|
+
* An inert handle that carries an inbound trace context. Records nothing, and
|
|
130
|
+
* echoes the `traceparent` it was handed — including the caller's version and
|
|
131
|
+
* sampled flag — so a service with tracing off still forwards the trace it
|
|
132
|
+
* received rather than severing it. The ids it propagates are the upstream
|
|
133
|
+
* caller's own; this SDK invents none.
|
|
134
|
+
*/
|
|
135
|
+
export declare class PassThroughSpan extends NoopSpan {
|
|
136
|
+
private readonly _traceparent;
|
|
137
|
+
private readonly _tracestate?;
|
|
138
|
+
constructor(_traceparent: string, _tracestate?: string | undefined);
|
|
139
|
+
traceparent(): string;
|
|
140
|
+
tracestate(): string | null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The handle to return when a span cannot be recorded: a pass-through when a
|
|
144
|
+
* context is available, the shared no-op otherwise. With no explicit `parent`
|
|
145
|
+
* the active handle supplies it, so an inbound trace survives nesting.
|
|
146
|
+
*
|
|
147
|
+
* @internal Exposed for cross-package use within this SDK; not part of the stable public API.
|
|
148
|
+
*/
|
|
149
|
+
export declare function inertSpan(options?: {
|
|
150
|
+
parent?: unknown;
|
|
151
|
+
tracestate?: unknown;
|
|
152
|
+
}, active?: Span): Span;
|
|
153
|
+
/**
|
|
154
|
+
* Bounds every string reachable from an attribute value to `maxLength`
|
|
155
|
+
* characters, including the strings nested inside arrays and objects. Numbers
|
|
156
|
+
* and booleans are bounded already.
|
|
157
|
+
*
|
|
158
|
+
* An unbounded value is the one thing the per-span caps do not stop: a single
|
|
159
|
+
* multi-MB attribute makes the whole span too large for the ingestion endpoint,
|
|
160
|
+
* and the 413 path then drops that span whole. `setAttribute('payload', { body })`
|
|
161
|
+
* is the usual way one arrives, so the bound has to reach inside the value.
|
|
162
|
+
*
|
|
163
|
+
* Returns the value it was given when nothing needed shortening, so the common
|
|
164
|
+
* case allocates nothing.
|
|
165
|
+
*/
|
|
166
|
+
export declare function truncateAttributeValue(value: SpanAttributeValue, maxLength: number): SpanAttributeValue;
|
|
167
|
+
/** `truncateAttributeValue` across an attribute bag, in place. */
|
|
168
|
+
export declare function truncateAttributes(attributes: SpanAttributes, maxLength: number): SpanAttributes;
|
|
169
|
+
/**
|
|
170
|
+
* Runs `fn` with `span` active, which every scoped helper does the same way.
|
|
171
|
+
*
|
|
172
|
+
* The shared no-op is never activated, so `getActiveSpan()` inside the callback
|
|
173
|
+
* reads null — callbacks should use the handle they're given. A pass-through
|
|
174
|
+
* handle is activated, so `getActiveSpan()?.traceparent()` still propagates an
|
|
175
|
+
* inbound trace through a service with tracing off.
|
|
176
|
+
*
|
|
177
|
+
* @internal Exposed for cross-package use within this SDK; not part of the stable public API.
|
|
178
|
+
*/
|
|
179
|
+
export declare function runWithActiveSpan<T>(contextManager: SpanContextManager, span: Span, fn: (span: Span) => T): T;
|
|
180
|
+
/**
|
|
181
|
+
* Extracts the OTel `exception.type` / `exception.message` pair from whatever was
|
|
182
|
+
* thrown. Anything can be thrown in JS, so non-Errors are described by type.
|
|
183
|
+
*/
|
|
184
|
+
export declare function describeError(error: unknown): {
|
|
185
|
+
type: string;
|
|
186
|
+
message: string;
|
|
187
|
+
stack?: string;
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=span.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../src/traces/span.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACvH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,kBAA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