@ohos-ports/polarsignals-pprof 0.1.3-beta.0 → 0.1.3-beta.1

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.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +22 -1
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { heap } from "@datadog/pprof"
1
+ import type { heap } from "@ohos-ports/datadog-pprof"
2
2
 
3
3
 
4
4
  export type ExportOptions = {
package/index.js CHANGED
@@ -18,6 +18,20 @@ const COLUMN_ENCODING_SOURCE_MAPPER = {
18
18
  },
19
19
  };
20
20
 
21
+ // Normalize user-supplied profile trees for the serializer.
22
+ // Trees collected by the V8 sampler contain `allocations` arrays; hand-built
23
+ // trees (e.g. synthesized from app data) may omit them. Fill in defaults so
24
+ // encodedProfileFromTree accepts both shapes.
25
+ function normalizeProfileTreeNode(node) {
26
+ if (!node || typeof node !== 'object') return node;
27
+ return {
28
+ ...node,
29
+ name: node.name ?? node.callFrame?.functionName,
30
+ allocations: node.allocations ?? [],
31
+ children: (node.children ?? []).map(normalizeProfileTreeNode),
32
+ };
33
+ }
34
+
21
35
  // Tag JS frames with a v8js Mapping + build_id so consumers can resolve them
22
36
  // against the matching sourcemap.
23
37
  function addBuildIdMappings(profile) {
@@ -74,6 +88,13 @@ async function finalize(profile, injectBuildIds) {
74
88
  module.exports = {
75
89
  heapProfiler: {
76
90
  ...heap,
91
+ // Compatibility aliases for the pre-5.x @datadog/pprof API names.
92
+ startSamplingHeapProfiler(...args) {
93
+ return heap.start(...args);
94
+ },
95
+ stopSamplingHeapProfiler(...args) {
96
+ return heap.stop(...args);
97
+ },
77
98
  async encodedProfile(options) {
78
99
  const { mapper, injectBuildIds } = await pickEncodeMode(options);
79
100
  return finalize(await heap.profile('', mapper), injectBuildIds);
@@ -81,7 +102,7 @@ module.exports = {
81
102
  },
82
103
  async encodedProfileFromTree(rootNode, options) {
83
104
  const { mapper, injectBuildIds } = await pickEncodeMode(options);
84
- return finalize(heap.convertProfile(rootNode, undefined, mapper), injectBuildIds);
105
+ return finalize(heap.convertProfile(normalizeProfileTreeNode(rootNode), undefined, mapper), injectBuildIds);
85
106
  },
86
107
  monitorOutOfMemory(config = {}) {
87
108
  heap.monitorOutOfMemory(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohos-ports/polarsignals-pprof",
3
- "version": "0.1.3-beta.0",
3
+ "version": "0.1.3-beta.1",
4
4
  "description": "Node.js profiling library that automatically uploads heap profiles to Polar Signals",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -30,14 +30,14 @@
30
30
  "bugs": {
31
31
  "url": "https://github.com/ohos-ports/ohos-ports/issues"
32
32
  },
33
- "homepage": "https://github.com/polarsignals/pprof-nodejs#readme",
33
+ "homepage": "https://github.com/ohos-ports/ohos-ports/tree/main/ports/polarsignals-pprof/0.1.3#readme",
34
34
  "publishConfig": {
35
35
  "access": "public",
36
36
  "registry": "https://registry.npmjs.org/"
37
37
  },
38
38
  "packageManager": "pnpm@10.33.0",
39
39
  "dependencies": {
40
- "@ohos-ports/datadog-pprof": "^5.17.0-beta.0",
40
+ "@ohos-ports/datadog-pprof": "^5.17.0-beta.1",
41
41
  "pprof-format": "^2.2.1"
42
42
  },
43
43
  "devDependencies": {