@datadog/pprof 5.15.1 → 5.16.0
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/out/src/index.d.ts +7 -0
- package/out/src/index.js +12 -1
- package/out/src/index.js.map +1 -1
- package/out/src/otel-thread-ctx.d.ts +82 -0
- package/out/src/otel-thread-ctx.js +167 -0
- package/out/src/otel-thread-ctx.js.map +1 -0
- package/package.json +5 -5
- package/prebuilds/darwin-arm64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi108.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi111.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi115.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi120.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi127.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi131.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi137.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi141.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi147.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi108.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi111.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi115.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi120.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi127.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi131.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi137.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi141.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi147.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi147.node +0 -0
package/out/src/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as heapProfiler from './heap-profiler';
|
|
2
|
+
import * as otelThreadCtxModule from './otel-thread-ctx';
|
|
2
3
|
import * as timeProfiler from './time-profiler';
|
|
3
4
|
export { AllocationProfileNode, TimeProfileNode, ProfileNode, LabelSet, } from './v8-types';
|
|
4
5
|
export { encode, encodeSync } from './profile-encoder';
|
|
@@ -37,3 +38,9 @@ export declare const heap: {
|
|
|
37
38
|
Both: number;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
41
|
+
export declare const otelThreadCtx: {
|
|
42
|
+
ThreadContext: otelThreadCtxModule.ThreadContextCtor;
|
|
43
|
+
getContext: () => otelThreadCtxModule.ThreadContext | undefined;
|
|
44
|
+
clearContext: () => void;
|
|
45
|
+
getProcessContextAttributes: typeof otelThreadCtxModule.getProcessContextAttributes;
|
|
46
|
+
};
|
package/out/src/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.heap = exports.time = exports.getNativeThreadId = exports.setLogger = exports.SourceMapper = exports.encodeSync = exports.encode = void 0;
|
|
36
|
+
exports.otelThreadCtx = exports.heap = exports.time = exports.getNativeThreadId = exports.setLogger = exports.SourceMapper = exports.encodeSync = exports.encode = void 0;
|
|
37
37
|
/**
|
|
38
38
|
* Copyright 2019 Google Inc. All Rights Reserved.
|
|
39
39
|
*
|
|
@@ -51,6 +51,7 @@ exports.heap = exports.time = exports.getNativeThreadId = exports.setLogger = ex
|
|
|
51
51
|
*/
|
|
52
52
|
const fs_1 = require("fs");
|
|
53
53
|
const heapProfiler = __importStar(require("./heap-profiler"));
|
|
54
|
+
const otelThreadCtxModule = __importStar(require("./otel-thread-ctx"));
|
|
54
55
|
const profile_encoder_1 = require("./profile-encoder");
|
|
55
56
|
const timeProfiler = __importStar(require("./time-profiler"));
|
|
56
57
|
var profile_encoder_2 = require("./profile-encoder");
|
|
@@ -86,6 +87,16 @@ exports.heap = {
|
|
|
86
87
|
monitorOutOfMemory: heapProfiler.monitorOutOfMemory,
|
|
87
88
|
CallbackMode: heapProfiler.CallbackMode,
|
|
88
89
|
};
|
|
90
|
+
// Writer for the OpenTelemetry Thread Local Context Record (OTEP-4947).
|
|
91
|
+
// Linux + AsyncContextFrame (Node 22 with --experimental-async-context-frame,
|
|
92
|
+
// Node 24+ by default) only; degrades to no-ops on other platforms / Node
|
|
93
|
+
// versions.
|
|
94
|
+
exports.otelThreadCtx = {
|
|
95
|
+
ThreadContext: otelThreadCtxModule.ThreadContext,
|
|
96
|
+
getContext: otelThreadCtxModule.getContext,
|
|
97
|
+
clearContext: otelThreadCtxModule.clearContext,
|
|
98
|
+
getProcessContextAttributes: otelThreadCtxModule.getProcessContextAttributes,
|
|
99
|
+
};
|
|
89
100
|
// If loaded with --require, start profiling.
|
|
90
101
|
if (module.parent && module.parent.id === 'internal/preload') {
|
|
91
102
|
exports.time.start({});
|
package/out/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2BAAiC;AAEjC,8DAAgD;AAChD,uDAA6C;AAC7C,8DAAgD;AAQhD,qDAAqD;AAA7C,yGAAA,MAAM,OAAA;AAAE,6GAAA,UAAU,OAAA;AAC1B,4DAAyD;AAAjD,4GAAA,YAAY,OAAA;AACpB,mCAAmC;AAA3B,mGAAA,SAAS,OAAA;AACjB,iDAAkD;AAA1C,kHAAA,iBAAiB,OAAA;AAEZ,QAAA,IAAI,GAAG;IAClB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,SAAS,EAAE,YAAY,CAAC,SAAS;IACjC,UAAU,EAAE,YAAY,CAAC,UAAU;IACnC,UAAU,EAAE,YAAY,CAAC,UAAU;IACnC,cAAc,EAAE,YAAY,CAAC,cAAc;IAC3C,SAAS,EAAE,YAAY,CAAC,SAAS;IACjC,gCAAgC,EAC9B,YAAY,CAAC,gCAAgC;IAC/C,QAAQ,EAAE,YAAY,CAAC,QAAQ;IAC/B,UAAU,EAAE,YAAY,CAAC,UAAU;IACnC,SAAS,EAAE,YAAY,CAAC,SAAS;CAClC,CAAC;AAEW,QAAA,IAAI,GAAG;IAClB,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,SAAS,EAAE,YAAY,CAAC,SAAS;IACjC,cAAc,EAAE,YAAY,CAAC,cAAc;IAC3C,SAAS,EAAE,YAAY,CAAC,SAAS;IACjC,kBAAkB,EAAE,YAAY,CAAC,kBAAkB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AC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTEP-4719 process-context attributes corresponding to a particular
|
|
3
|
+
* key list. Spread this into whatever attribute map the application
|
|
4
|
+
* hands to its OTEP-4719 process-context publisher.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProcessContextAttributes {
|
|
7
|
+
readonly 'threadlocal.schema_version': 'nodejs_v1_dev';
|
|
8
|
+
readonly 'threadlocal.attribute_key_map': readonly string[];
|
|
9
|
+
readonly 'threadlocal.wrapped_object_offset': number;
|
|
10
|
+
readonly 'threadlocal.tagged_size': number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A thread-context record. Construct with `new ThreadContext(...)`; install
|
|
14
|
+
* via the {@link enter} or {@link run} instance methods. The underlying
|
|
15
|
+
* native record is GC-owned: when no JS or async-context-frame reference
|
|
16
|
+
* survives, it's freed.
|
|
17
|
+
*
|
|
18
|
+
* `appendAttributes` mutates the context's record in place. Because every
|
|
19
|
+
* async-context frame that holds the same `ThreadContext` reference observes
|
|
20
|
+
* the same native record buffer, an append is visible across all those
|
|
21
|
+
* frames even when the reallocate path runs (the context's internal
|
|
22
|
+
* pointer is updated, the JS object is not replaced).
|
|
23
|
+
*/
|
|
24
|
+
export interface ThreadContext {
|
|
25
|
+
appendAttributes(attributes: Array<string | null | undefined> | undefined): void;
|
|
26
|
+
isTruncated(): boolean;
|
|
27
|
+
/** Debug-only: returns the on-the-wire record bytes. Not stable. */
|
|
28
|
+
debugBytes(): Uint8Array;
|
|
29
|
+
/**
|
|
30
|
+
* Attach this context to the current async-context frame (and every
|
|
31
|
+
* frame derived from it until the frame ends or {@link clearContext}
|
|
32
|
+
* detaches it). Re-installing the same context reference is cheap (no
|
|
33
|
+
* allocation); per-span caching of the context on the caller side is
|
|
34
|
+
* the intended usage pattern.
|
|
35
|
+
*
|
|
36
|
+
* On non-Linux platforms this is a no-op.
|
|
37
|
+
*/
|
|
38
|
+
enter(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Attach this context for the duration of `fn`. Equivalent to
|
|
41
|
+
* `als.run(this, fn)` — after `fn` returns, the previous context is
|
|
42
|
+
* restored. Returns whatever `fn` returns; if `fn` returns a Promise,
|
|
43
|
+
* the same Promise is propagated. On non-Linux platforms simply
|
|
44
|
+
* invokes `fn`.
|
|
45
|
+
*/
|
|
46
|
+
run<T>(fn: () => T): T;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Constructor for {@link ThreadContext}. On non-Linux platforms, returns a
|
|
50
|
+
* no-op instance whose methods do nothing — the OTEP-4947 reader
|
|
51
|
+
* contract is ELF-TLSDESC, only meaningful on Linux.
|
|
52
|
+
*/
|
|
53
|
+
export interface ThreadContextCtor {
|
|
54
|
+
new (traceId: Uint8Array, spanId: Uint8Array, attributes?: Array<string | null | undefined>): ThreadContext;
|
|
55
|
+
readonly prototype: ThreadContext;
|
|
56
|
+
}
|
|
57
|
+
/** {@inheritDoc ThreadContextCtor} */
|
|
58
|
+
export declare let ThreadContext: ThreadContextCtor;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the {@link ThreadContext} currently attached to the active
|
|
61
|
+
* async-context frame, or `undefined` if none is.
|
|
62
|
+
*/
|
|
63
|
+
export declare let getContext: () => ThreadContext | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Detach any {@link ThreadContext} from the current async-context frame.
|
|
66
|
+
* Idempotent when no context is attached. On non-Linux platforms this is
|
|
67
|
+
* a no-op.
|
|
68
|
+
*/
|
|
69
|
+
export declare let clearContext: () => void;
|
|
70
|
+
export declare let _currentRecordBytes: () => Uint8Array | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the OTEP-4719 process-context attributes the caller should
|
|
73
|
+
* publish so an out-of-process reader can decode the on-the-wire uint8
|
|
74
|
+
* key indexes back to attribute names. The supplied `keys` array is the
|
|
75
|
+
* same string list the caller writes into the positional `attributes`
|
|
76
|
+
* argument of {@link ThreadContext}: index N here is the uint8 key index
|
|
77
|
+
* N in each record.
|
|
78
|
+
*
|
|
79
|
+
* `keys` is validated: must be a string array of length ≤ 256 with no
|
|
80
|
+
* duplicates.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getProcessContextAttributes(keys: string[]): ProcessContextAttributes;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 Datadog, Inc
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports._currentRecordBytes = exports.clearContext = exports.getContext = exports.ThreadContext = void 0;
|
|
19
|
+
exports.getProcessContextAttributes = getProcessContextAttributes;
|
|
20
|
+
// Vendored from https://github.com/polarsignals/custom-labels/tree/otel-thread-ctx-wip/js/
|
|
21
|
+
// (originally js/index.js + js/index.d.ts, merged into TypeScript). Kept
|
|
22
|
+
// as a near-verbatim copy: edits should ideally land upstream first and
|
|
23
|
+
// be ported here, so the two stay in sync. We plan to drop this vendored
|
|
24
|
+
// copy once the upstream package is suitable to depend on directly.
|
|
25
|
+
// Node.js writer for the OpenTelemetry Thread Local Context Record
|
|
26
|
+
// (OTEP-4947), discoverable from an out-of-process reader via the
|
|
27
|
+
// `otel_thread_ctx_nodejs_v1` thread-local symbol exported by
|
|
28
|
+
// `dd_pprof.node`.
|
|
29
|
+
//
|
|
30
|
+
// Linux only; on other platforms the exported functions degrade to no-ops.
|
|
31
|
+
const path_1 = require("path");
|
|
32
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
33
|
+
const SCHEMA_VERSION = 'nodejs_v1_dev';
|
|
34
|
+
// V8 layout constants the addon captured from the V8 headers Node bundles.
|
|
35
|
+
// On non-Linux these fall back to values matching Node's standard build
|
|
36
|
+
// (no V8 pointer compression, no sandbox); the reader is Linux-only per
|
|
37
|
+
// the OTEP anyway, so the fallbacks just keep processContextAttributes
|
|
38
|
+
// consistent in shape.
|
|
39
|
+
let WRAPPED_OBJECT_OFFSET = 24;
|
|
40
|
+
let TAGGED_SIZE = 8;
|
|
41
|
+
// Debug accessor (not part of the stable API; for tests / reader dev).
|
|
42
|
+
let _currentRecordBytes = () => undefined;
|
|
43
|
+
exports._currentRecordBytes = _currentRecordBytes;
|
|
44
|
+
if (process.platform === 'linux') {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
46
|
+
const findBinding = require('node-gyp-build');
|
|
47
|
+
const addon = findBinding((0, path_1.join)(__dirname, '..', '..'));
|
|
48
|
+
WRAPPED_OBJECT_OFFSET = addon.otelThreadCtxWrappedObjectOffset;
|
|
49
|
+
TAGGED_SIZE = addon.otelThreadCtxTaggedSize;
|
|
50
|
+
exports.ThreadContext = addon.threadContext;
|
|
51
|
+
let als;
|
|
52
|
+
function asyncContextFrameError() {
|
|
53
|
+
const [major] = process.versions.node.split('.').map(Number);
|
|
54
|
+
if (process.execArgv.includes('--no-async-context-frame')) {
|
|
55
|
+
return 'Node explicitly launched with --no-async-context-frame';
|
|
56
|
+
}
|
|
57
|
+
if (major >= 24)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (process.execArgv.includes('--experimental-async-context-frame')) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
if (major >= 22) {
|
|
63
|
+
return 'Node versions prior to v24 must be launched with --experimental-async-context-frame';
|
|
64
|
+
}
|
|
65
|
+
return 'Node major versions prior to v22 do not support the feature at all';
|
|
66
|
+
}
|
|
67
|
+
function ensureHook() {
|
|
68
|
+
if (als)
|
|
69
|
+
return als;
|
|
70
|
+
const err = asyncContextFrameError();
|
|
71
|
+
if (err) {
|
|
72
|
+
throw new Error(`otel thread-ctx writer requires async_context_frame support, which is unavailable: ${err}.`);
|
|
73
|
+
}
|
|
74
|
+
als = new node_async_hooks_1.AsyncLocalStorage();
|
|
75
|
+
addon.otelThreadCtxStoreAls(als);
|
|
76
|
+
return als;
|
|
77
|
+
}
|
|
78
|
+
exports.getContext = function () {
|
|
79
|
+
return als ? als.getStore() : undefined;
|
|
80
|
+
};
|
|
81
|
+
// Idempotent: clearing when the hook hasn't been installed (no prior
|
|
82
|
+
// enter / run on a ThreadContext) is a no-op.
|
|
83
|
+
exports.clearContext = function () {
|
|
84
|
+
if (!als)
|
|
85
|
+
return;
|
|
86
|
+
als.enterWith(undefined);
|
|
87
|
+
};
|
|
88
|
+
// Install the active-context channel on the ThreadContext prototype so
|
|
89
|
+
// the only way to push a ThreadContext into our AsyncLocalStorage is
|
|
90
|
+
// via the context itself — callers can't poison the ALS with an
|
|
91
|
+
// arbitrary object.
|
|
92
|
+
exports.ThreadContext.prototype.enter = function () {
|
|
93
|
+
ensureHook().enterWith(this);
|
|
94
|
+
};
|
|
95
|
+
exports.ThreadContext.prototype.run = function (fn) {
|
|
96
|
+
return ensureHook().run(this, fn);
|
|
97
|
+
};
|
|
98
|
+
exports._currentRecordBytes = function () {
|
|
99
|
+
if (!als)
|
|
100
|
+
return undefined;
|
|
101
|
+
const context = als.getStore();
|
|
102
|
+
return context ? context.debugBytes() : undefined;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// Non-Linux degradation. The writer's reader contract is ELF-TLSDESC,
|
|
107
|
+
// meaningful only on Linux; on other platforms we still want the API
|
|
108
|
+
// to be callable so consumers don't have to gate every call site —
|
|
109
|
+
// construction succeeds but produces an inert context, and the
|
|
110
|
+
// enter/run/clearContext entry points don't wire anything into
|
|
111
|
+
// AsyncLocalStorage.
|
|
112
|
+
class NoopThreadContext {
|
|
113
|
+
appendAttributes() { }
|
|
114
|
+
isTruncated() {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
debugBytes() {
|
|
118
|
+
return new Uint8Array(0);
|
|
119
|
+
}
|
|
120
|
+
enter() { }
|
|
121
|
+
run(fn) {
|
|
122
|
+
return fn();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.ThreadContext = NoopThreadContext;
|
|
126
|
+
exports.getContext = function () {
|
|
127
|
+
return undefined;
|
|
128
|
+
};
|
|
129
|
+
exports.clearContext = function () { };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns the OTEP-4719 process-context attributes the caller should
|
|
133
|
+
* publish so an out-of-process reader can decode the on-the-wire uint8
|
|
134
|
+
* key indexes back to attribute names. The supplied `keys` array is the
|
|
135
|
+
* same string list the caller writes into the positional `attributes`
|
|
136
|
+
* argument of {@link ThreadContext}: index N here is the uint8 key index
|
|
137
|
+
* N in each record.
|
|
138
|
+
*
|
|
139
|
+
* `keys` is validated: must be a string array of length ≤ 256 with no
|
|
140
|
+
* duplicates.
|
|
141
|
+
*/
|
|
142
|
+
function getProcessContextAttributes(keys) {
|
|
143
|
+
if (!Array.isArray(keys)) {
|
|
144
|
+
throw new TypeError('keys must be an array of attribute names');
|
|
145
|
+
}
|
|
146
|
+
if (keys.length > 256) {
|
|
147
|
+
throw new RangeError('keys array exceeds 256 entries');
|
|
148
|
+
}
|
|
149
|
+
const seen = new Set();
|
|
150
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
151
|
+
const name = keys[i];
|
|
152
|
+
if (typeof name !== 'string') {
|
|
153
|
+
throw new TypeError('every key must be a string');
|
|
154
|
+
}
|
|
155
|
+
if (seen.has(name)) {
|
|
156
|
+
throw new Error(`duplicate key name at index ${i}: ${name}`);
|
|
157
|
+
}
|
|
158
|
+
seen.add(name);
|
|
159
|
+
}
|
|
160
|
+
return Object.freeze({
|
|
161
|
+
'threadlocal.schema_version': SCHEMA_VERSION,
|
|
162
|
+
'threadlocal.attribute_key_map': Object.freeze(keys.slice()),
|
|
163
|
+
'threadlocal.wrapped_object_offset': WRAPPED_OBJECT_OFFSET,
|
|
164
|
+
'threadlocal.tagged_size': TAGGED_SIZE,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=otel-thread-ctx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel-thread-ctx.js","sourceRoot":"","sources":["../../ts/src/otel-thread-ctx.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAqOH,kEA0BC;AA7PD,2FAA2F;AAC3F,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,oEAAoE;AAEpE,mEAAmE;AACnE,kEAAkE;AAClE,8DAA8D;AAC9D,mBAAmB;AACnB,EAAE;AACF,2EAA2E;AAE3E,+BAA0B;AAC1B,uDAAmD;AA6EnD,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC,2EAA2E;AAC3E,wEAAwE;AACxE,wEAAwE;AACxE,uEAAuE;AACvE,uBAAuB;AACvB,IAAI,qBAAqB,GAAG,EAAE,CAAC;AAC/B,IAAI,WAAW,GAAG,CAAC,CAAC;AAkBpB,uEAAuE;AAChE,IAAI,mBAAmB,GAAiC,GAAG,EAAE,CAAC,SAAS,CAAC;AAApE,QAAA,mBAAmB,uBAAiD;AAE/E,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;IACjC,iEAAiE;IACjE,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAU,WAAW,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9D,qBAAqB,GAAG,KAAK,CAAC,gCA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AC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACtB,MAAM,IAAI,UAAU,CAAC,gCAAgC,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,4BAA4B,EAAE,cAAc;QAC5C,+BAA+B,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5D,mCAAmC,EAAE,qBAAqB;QAC1D,yBAAyB,EAAE,WAAW;KACvC,CAA6B,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/pprof",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.0",
|
|
4
4
|
"description": "pprof support for Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"compile": "tsc -p .",
|
|
17
17
|
"fix": "gts fix",
|
|
18
18
|
"format": "clang-format --style file -i --glob='bindings/**/*.{h,hh,cpp,cc}'",
|
|
19
|
-
"install": "exit 0",
|
|
20
19
|
"lint": "jsgl --local . && gts check && clang-format --style file -n -Werror --glob='bindings/**/*.{h,hh,cpp,cc}'",
|
|
21
20
|
"prepare": "npm run compile && npm run rebuild",
|
|
22
21
|
"pretest:js-asan": "npm run compile && npm run build:asan",
|
|
@@ -29,7 +28,8 @@
|
|
|
29
28
|
"test:js-tsan": "LD_PRELOAD=`gcc -print-file-name=libtsan.so` mocha out/test/test-*.js",
|
|
30
29
|
"test:js-valgrind": "valgrind --leak-check=full mocha out/test/test-*.js",
|
|
31
30
|
"test:js": "nyc mocha -r source-map-support/register out/test/test-*.js",
|
|
32
|
-
"test": "npm run test:js"
|
|
31
|
+
"test": "npm run test:js",
|
|
32
|
+
"test:docker": "./scripts/docker/run-in-docker.sh"
|
|
33
33
|
},
|
|
34
34
|
"author": {
|
|
35
35
|
"name": "Google Inc."
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/mocha": "^10.0.1",
|
|
45
|
-
"@types/node": "25.9.
|
|
45
|
+
"@types/node": "25.9.2",
|
|
46
46
|
"@types/semver": "^7.5.8",
|
|
47
47
|
"@types/sinon": "^21.0.1",
|
|
48
48
|
"@types/tmp": "^0.2.3",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"semver": "^7.8.1",
|
|
59
59
|
"sinon": "^22.0.0",
|
|
60
60
|
"source-map-support": "^0.5.21",
|
|
61
|
-
"tmp": "0.2.
|
|
61
|
+
"tmp": "0.2.7",
|
|
62
62
|
"typescript": "^6.0.3"
|
|
63
63
|
},
|
|
64
64
|
"files": [
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|