observability-toolkit-hooks 0.0.0-stage → 1.0.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.
- package/CONFIG.md +144 -0
- package/LICENSE +95 -0
- package/README.md +201 -2
- package/dist/handlers/compact.js +38 -0
- package/dist/handlers/mcp-status.js +66 -0
- package/dist/handlers/notification.js +45 -0
- package/dist/handlers/post-tool-agent.js +157 -0
- package/dist/handlers/post-tool-changelog-sync.js +148 -0
- package/dist/handlers/post-tool-code-structure.js +116 -0
- package/dist/handlers/post-tool-edit-ledger.js +15 -0
- package/dist/handlers/post-tool-failure.js +83 -0
- package/dist/handlers/post-tool-git.js +79 -0
- package/dist/handlers/post-tool-mcp.js +105 -0
- package/dist/handlers/post-tool-outcome.js +48 -0
- package/dist/handlers/post-tool-task-state.js +74 -0
- package/dist/handlers/post-tool.js +132 -0
- package/dist/handlers/pre-tool-agent.js +192 -0
- package/dist/handlers/pre-tool.js +218 -0
- package/dist/handlers/session-end.js +39 -0
- package/dist/handlers/session-start.js +262 -0
- package/dist/handlers/stop-error-reminder.js +195 -0
- package/dist/handlers/stop-quality-evaluation.js +58 -0
- package/dist/handlers/stop-session-summary.js +62 -0
- package/dist/handlers/stop-token-metrics.js +83 -0
- package/dist/handlers/stop.js +25 -0
- package/dist/handlers/subagent.js +105 -0
- package/dist/handlers/tool-event-router.js +39 -0
- package/dist/handlers/user-prompt.js +218 -0
- package/dist/hook-runner.js +10 -0
- package/dist/hook-runner.js.map +7 -0
- package/dist/lib/agent/agent-context.js +123 -0
- package/dist/lib/agent/agent-evaluations.js +155 -0
- package/dist/lib/agent/agent-file-budget.js +65 -0
- package/dist/lib/agent/agent-sources.js +165 -0
- package/dist/lib/agent/synth-spans.js +51 -0
- package/dist/lib/core/bounded-label.js +6 -0
- package/dist/lib/core/category-rules.js +11 -0
- package/dist/lib/core/child-result.js +19 -0
- package/dist/lib/core/config-dir-recovery.js +22 -0
- package/dist/lib/core/constants.js +171 -0
- package/dist/lib/core/detached-runner.js +55 -0
- package/dist/lib/core/file-utils.js +353 -0
- package/dist/lib/core/format-utils.js +51 -0
- package/dist/lib/core/http-utils.js +74 -0
- package/dist/lib/core/http1-fetch.js +14 -0
- package/dist/lib/core/identity-key-resolver.js +149 -0
- package/dist/lib/core/jsonl-tail.js +207 -0
- package/dist/lib/core/load-envrc.js +72 -0
- package/dist/lib/core/parsers.js +43 -0
- package/dist/lib/core/regex.js +27 -0
- package/dist/lib/core/settings-env.js +31 -0
- package/dist/lib/core/shell-command.js +122 -0
- package/dist/lib/core/units.js +97 -0
- package/dist/lib/git/git-cache.js +158 -0
- package/dist/lib/git/git-commit.js +189 -0
- package/dist/lib/git/git-exec.js +30 -0
- package/dist/lib/mcp/mcp-completeness.js +40 -0
- package/dist/lib/mcp/mcp-config.js +118 -0
- package/dist/lib/mcp/mcp-failure-latch.js +22 -0
- package/dist/lib/mcp/mcp-identity-launcher.js +43 -0
- package/dist/lib/otel/attributes.js +322 -0
- package/dist/lib/otel/evaluation-attrs.js +51 -0
- package/dist/lib/otel/file-exporters.js +169 -0
- package/dist/lib/otel/host-resource.js +61 -0
- package/dist/lib/otel/otel-headers-helper.js +26 -0
- package/dist/lib/otel/otel-monitor.js +181 -0
- package/dist/lib/otel/otel.js +235 -0
- package/dist/lib/otel/otlp-headers.js +101 -0
- package/dist/lib/otel/otlp-post.js +122 -0
- package/dist/lib/otel/otlp-serialize.js +142 -0
- package/dist/lib/otel/otlp-signal.js +2 -0
- package/dist/lib/otel/remote-spans.js +142 -0
- package/dist/lib/otel/service-identity.js +10 -0
- package/dist/lib/otel/telemetry-alerts.js +43 -0
- package/dist/lib/otel/token-metrics.js +122 -0
- package/dist/lib/otel/trace-context.js +81 -0
- package/dist/lib/quality/judge-meta-eval.js +70 -0
- package/dist/lib/quality/judge-prompts.js +104 -0
- package/dist/lib/quality/judge-providers.js +193 -0
- package/dist/lib/quality/judge-transport.js +93 -0
- package/dist/lib/quality/llm-judge.js +170 -0
- package/dist/lib/quality/quality-budget.js +99 -0
- package/dist/lib/quality/quality-degradation.js +156 -0
- package/dist/lib/quality/quality-eval-handoff.js +74 -0
- package/dist/lib/quality/quality-evaluator.js +178 -0
- package/dist/lib/quality/quality-sampler.js +43 -0
- package/dist/lib/quality/quality-signals.js +150 -0
- package/dist/lib/runtime/categorizers.js +101 -0
- package/dist/lib/runtime/hook-input.js +16 -0
- package/dist/lib/runtime/hook-output.js +50 -0
- package/dist/lib/runtime/output-analyzer.js +160 -0
- package/dist/lib/runtime/run-handlers.js +32 -0
- package/dist/lib/runtime/tool-input.js +111 -0
- package/dist/lib/runtime/tool-output.js +44 -0
- package/dist/lib/runtime/unknown-tool.js +32 -0
- package/dist/lib/session/edit-ledger.js +29 -0
- package/dist/lib/session/forked-skill.js +39 -0
- package/dist/lib/session/handoffs.js +77 -0
- package/dist/lib/session/session-state.js +169 -0
- package/dist/lib/session/skill-rules.js +196 -0
- package/dist/lib/session/task-tracker.js +83 -0
- package/dist/lib/shipper/shipper-credentials.js +38 -0
- package/dist/lib/shipper/shipper-cursor.js +89 -0
- package/dist/lib/shipper/shipper-status.js +174 -0
- package/dist/lib/shipper/span-shipper.js +272 -0
- package/dist/lib/shipper/telemetry-shipper.js +39 -0
- package/dist/lib/transcript/agent-transcript-metrics.js +34 -0
- package/dist/lib/transcript/context-breakdown.js +134 -0
- package/dist/lib/transcript/context-history.js +69 -0
- package/dist/lib/transcript/context-tracker.js +226 -0
- package/dist/lib/transcript/message-count.js +49 -0
- package/dist/lib/transcript/model-ids.js +36 -0
- package/dist/lib/transcript/model-pricing.js +153 -0
- package/dist/lib/transcript/token-metrics-checkpoint.js +152 -0
- package/dist/lib/transcript/tool-call-durations.js +64 -0
- package/dist/lib/transcript/transcript-entry.js +67 -0
- package/dist/lib/transcript/transcript-fold.js +130 -0
- package/dist/lib/transcript/transcript-layout.js +39 -0
- package/dist/lib/transcript/transcript-parser.js +117 -0
- package/dist/runner/agent-context-4XTCLMLZ.js +23 -0
- package/dist/runner/agent-context-4XTCLMLZ.js.map +7 -0
- package/dist/runner/agent-file-budget-Q33ESBBE.js +68 -0
- package/dist/runner/agent-file-budget-Q33ESBBE.js.map +7 -0
- package/dist/runner/agent-transcript-metrics-W5CZZFMI.js +39 -0
- package/dist/runner/agent-transcript-metrics-W5CZZFMI.js.map +7 -0
- package/dist/runner/chunk-2NTNAJZE.js +49 -0
- package/dist/runner/chunk-2NTNAJZE.js.map +7 -0
- package/dist/runner/chunk-4KWBQTTG.js +78 -0
- package/dist/runner/chunk-4KWBQTTG.js.map +7 -0
- package/dist/runner/chunk-52RY6LQT.js +699 -0
- package/dist/runner/chunk-52RY6LQT.js.map +7 -0
- package/dist/runner/chunk-7OM5CYES.js +8695 -0
- package/dist/runner/chunk-7OM5CYES.js.map +7 -0
- package/dist/runner/chunk-7PEOKGYR.js +1568 -0
- package/dist/runner/chunk-7PEOKGYR.js.map +7 -0
- package/dist/runner/chunk-AGSGKELQ.js +126 -0
- package/dist/runner/chunk-AGSGKELQ.js.map +7 -0
- package/dist/runner/chunk-AVM7PJFW.js +12 -0
- package/dist/runner/chunk-AVM7PJFW.js.map +7 -0
- package/dist/runner/chunk-C3WHUMU5.js +178 -0
- package/dist/runner/chunk-C3WHUMU5.js.map +7 -0
- package/dist/runner/chunk-DGB4NSSD.js +157 -0
- package/dist/runner/chunk-DGB4NSSD.js.map +7 -0
- package/dist/runner/chunk-DNSTWC26.js +151 -0
- package/dist/runner/chunk-DNSTWC26.js.map +7 -0
- package/dist/runner/chunk-FDJJ3TYU.js +449 -0
- package/dist/runner/chunk-FDJJ3TYU.js.map +7 -0
- package/dist/runner/chunk-FGKYDQHZ.js +137 -0
- package/dist/runner/chunk-FGKYDQHZ.js.map +7 -0
- package/dist/runner/chunk-GG2I4TGI.js +582 -0
- package/dist/runner/chunk-GG2I4TGI.js.map +7 -0
- package/dist/runner/chunk-GNNKUMRF.js +60 -0
- package/dist/runner/chunk-GNNKUMRF.js.map +7 -0
- package/dist/runner/chunk-I7TD2QVR.js +118 -0
- package/dist/runner/chunk-I7TD2QVR.js.map +7 -0
- package/dist/runner/chunk-IJ4SLUBV.js +78 -0
- package/dist/runner/chunk-IJ4SLUBV.js.map +7 -0
- package/dist/runner/chunk-IY7AP7NA.js +32 -0
- package/dist/runner/chunk-IY7AP7NA.js.map +7 -0
- package/dist/runner/chunk-J3F3Z3EQ.js +177 -0
- package/dist/runner/chunk-J3F3Z3EQ.js.map +7 -0
- package/dist/runner/chunk-JLEO5OHU.js +104 -0
- package/dist/runner/chunk-JLEO5OHU.js.map +7 -0
- package/dist/runner/chunk-JRNNLOPR.js +168 -0
- package/dist/runner/chunk-JRNNLOPR.js.map +7 -0
- package/dist/runner/chunk-KGSA5JYP.js +82 -0
- package/dist/runner/chunk-KGSA5JYP.js.map +7 -0
- package/dist/runner/chunk-LBCZAYFR.js +125 -0
- package/dist/runner/chunk-LBCZAYFR.js.map +7 -0
- package/dist/runner/chunk-LHWRXY2G.js +41 -0
- package/dist/runner/chunk-LHWRXY2G.js.map +7 -0
- package/dist/runner/chunk-LQ2LGUYJ.js +41 -0
- package/dist/runner/chunk-LQ2LGUYJ.js.map +7 -0
- package/dist/runner/chunk-LYY6RCIE.js +158 -0
- package/dist/runner/chunk-LYY6RCIE.js.map +7 -0
- package/dist/runner/chunk-M4R4QIQH.js +41 -0
- package/dist/runner/chunk-M4R4QIQH.js.map +7 -0
- package/dist/runner/chunk-MC75VXMX.js +207 -0
- package/dist/runner/chunk-MC75VXMX.js.map +7 -0
- package/dist/runner/chunk-NKZU4RRG.js +104 -0
- package/dist/runner/chunk-NKZU4RRG.js.map +7 -0
- package/dist/runner/chunk-PJHWHJ3K.js +56 -0
- package/dist/runner/chunk-PJHWHJ3K.js.map +7 -0
- package/dist/runner/chunk-RIGVYJ2O.js +114 -0
- package/dist/runner/chunk-RIGVYJ2O.js.map +7 -0
- package/dist/runner/chunk-RWRGC7ZK.js +93 -0
- package/dist/runner/chunk-RWRGC7ZK.js.map +7 -0
- package/dist/runner/chunk-SRMAJQMV.js +54 -0
- package/dist/runner/chunk-SRMAJQMV.js.map +7 -0
- package/dist/runner/chunk-TRMFD36J.js +47 -0
- package/dist/runner/chunk-TRMFD36J.js.map +7 -0
- package/dist/runner/chunk-U4IOZYQ3.js +21 -0
- package/dist/runner/chunk-U4IOZYQ3.js.map +7 -0
- package/dist/runner/chunk-UEXDE3WP.js +83 -0
- package/dist/runner/chunk-UEXDE3WP.js.map +7 -0
- package/dist/runner/chunk-UW3GQZSM.js +50 -0
- package/dist/runner/chunk-UW3GQZSM.js.map +7 -0
- package/dist/runner/chunk-V2GSP6VR.js +46 -0
- package/dist/runner/chunk-V2GSP6VR.js.map +7 -0
- package/dist/runner/chunk-VOV4Y5VU.js +81 -0
- package/dist/runner/chunk-VOV4Y5VU.js.map +7 -0
- package/dist/runner/chunk-VT5T6OEI.js +65 -0
- package/dist/runner/chunk-VT5T6OEI.js.map +7 -0
- package/dist/runner/chunk-VUYVFWIN.js +12 -0
- package/dist/runner/chunk-VUYVFWIN.js.map +7 -0
- package/dist/runner/chunk-VVGOPPEN.js +36 -0
- package/dist/runner/chunk-VVGOPPEN.js.map +7 -0
- package/dist/runner/chunk-VXFSLM6P.js +14 -0
- package/dist/runner/chunk-VXFSLM6P.js.map +7 -0
- package/dist/runner/chunk-W3EK7JUT.js +26125 -0
- package/dist/runner/chunk-W3EK7JUT.js.map +7 -0
- package/dist/runner/chunk-WJHNCOUF.js +52 -0
- package/dist/runner/chunk-WJHNCOUF.js.map +7 -0
- package/dist/runner/chunk-WU7ANGCW.js +269 -0
- package/dist/runner/chunk-WU7ANGCW.js.map +7 -0
- package/dist/runner/chunk-X7XLMSZX.js +44 -0
- package/dist/runner/chunk-X7XLMSZX.js.map +7 -0
- package/dist/runner/chunk-XSO3B4QN.js +124 -0
- package/dist/runner/chunk-XSO3B4QN.js.map +7 -0
- package/dist/runner/chunk-YGFN3LN2.js +174 -0
- package/dist/runner/chunk-YGFN3LN2.js.map +7 -0
- package/dist/runner/chunk-YHYDBLVB.js +33 -0
- package/dist/runner/chunk-YHYDBLVB.js.map +7 -0
- package/dist/runner/compact-36NP3PKT.js +60 -0
- package/dist/runner/compact-36NP3PKT.js.map +7 -0
- package/dist/runner/getMachineId-bsd-AGENNHN6.js +42 -0
- package/dist/runner/getMachineId-bsd-AGENNHN6.js.map +7 -0
- package/dist/runner/getMachineId-bsd-I5WZGCL4.js +33 -0
- package/dist/runner/getMachineId-bsd-I5WZGCL4.js.map +7 -0
- package/dist/runner/getMachineId-bsd-ZXK225P7.js +33 -0
- package/dist/runner/getMachineId-bsd-ZXK225P7.js.map +7 -0
- package/dist/runner/getMachineId-darwin-47GDLEXL.js +42 -0
- package/dist/runner/getMachineId-darwin-47GDLEXL.js.map +7 -0
- package/dist/runner/getMachineId-darwin-5CRLMDD6.js +33 -0
- package/dist/runner/getMachineId-darwin-5CRLMDD6.js.map +7 -0
- package/dist/runner/getMachineId-darwin-ADG4I32N.js +33 -0
- package/dist/runner/getMachineId-darwin-ADG4I32N.js.map +7 -0
- package/dist/runner/getMachineId-linux-5KVS3T2M.js +27 -0
- package/dist/runner/getMachineId-linux-5KVS3T2M.js.map +7 -0
- package/dist/runner/getMachineId-linux-GDFB5GSO.js +34 -0
- package/dist/runner/getMachineId-linux-GDFB5GSO.js.map +7 -0
- package/dist/runner/getMachineId-linux-NQMWCRO3.js +27 -0
- package/dist/runner/getMachineId-linux-NQMWCRO3.js.map +7 -0
- package/dist/runner/getMachineId-unsupported-5PFIGMVX.js +18 -0
- package/dist/runner/getMachineId-unsupported-5PFIGMVX.js.map +7 -0
- package/dist/runner/getMachineId-unsupported-DW27K3ZX.js +18 -0
- package/dist/runner/getMachineId-unsupported-DW27K3ZX.js.map +7 -0
- package/dist/runner/getMachineId-unsupported-XV3FHTHD.js +25 -0
- package/dist/runner/getMachineId-unsupported-XV3FHTHD.js.map +7 -0
- package/dist/runner/getMachineId-win-5JVMW3EI.js +44 -0
- package/dist/runner/getMachineId-win-5JVMW3EI.js.map +7 -0
- package/dist/runner/getMachineId-win-SNESQF7R.js +35 -0
- package/dist/runner/getMachineId-win-SNESQF7R.js.map +7 -0
- package/dist/runner/getMachineId-win-UJYHSBM2.js +35 -0
- package/dist/runner/getMachineId-win-UJYHSBM2.js.map +7 -0
- package/dist/runner/git-commit-BA53DOJQ.js +30 -0
- package/dist/runner/git-commit-BA53DOJQ.js.map +7 -0
- package/dist/runner/hook-runner-JHH6PGKE.js +220 -0
- package/dist/runner/hook-runner-JHH6PGKE.js.map +7 -0
- package/dist/runner/judge-transport-R4TF5LEH.js +91 -0
- package/dist/runner/judge-transport-R4TF5LEH.js.map +7 -0
- package/dist/runner/mcp-status-QEUH2KGX.js +89 -0
- package/dist/runner/mcp-status-QEUH2KGX.js.map +7 -0
- package/dist/runner/notification-FKMBCSXF.js +69 -0
- package/dist/runner/notification-FKMBCSXF.js.map +7 -0
- package/dist/runner/post-tool-3MRHTBKH.js +192 -0
- package/dist/runner/post-tool-3MRHTBKH.js.map +7 -0
- package/dist/runner/post-tool-agent-BB34MNHI.js +370 -0
- package/dist/runner/post-tool-agent-BB34MNHI.js.map +7 -0
- package/dist/runner/post-tool-changelog-sync-OP2TT2I7.js +147 -0
- package/dist/runner/post-tool-changelog-sync-OP2TT2I7.js.map +7 -0
- package/dist/runner/post-tool-code-structure-LE7J2SC2.js +130 -0
- package/dist/runner/post-tool-code-structure-LE7J2SC2.js.map +7 -0
- package/dist/runner/post-tool-edit-ledger-IJMEYHKF.js +30 -0
- package/dist/runner/post-tool-edit-ledger-IJMEYHKF.js.map +7 -0
- package/dist/runner/post-tool-failure-XTH2I2Z7.js +111 -0
- package/dist/runner/post-tool-failure-XTH2I2Z7.js.map +7 -0
- package/dist/runner/post-tool-git-E46HZGZO.js +94 -0
- package/dist/runner/post-tool-git-E46HZGZO.js.map +7 -0
- package/dist/runner/post-tool-mcp-AMCDY5GH.js +144 -0
- package/dist/runner/post-tool-mcp-AMCDY5GH.js.map +7 -0
- package/dist/runner/post-tool-task-state-TLDOI33H.js +100 -0
- package/dist/runner/post-tool-task-state-TLDOI33H.js.map +7 -0
- package/dist/runner/pre-tool-SQE2FZQO.js +245 -0
- package/dist/runner/pre-tool-SQE2FZQO.js.map +7 -0
- package/dist/runner/pre-tool-agent-OZUPVFUI.js +218 -0
- package/dist/runner/pre-tool-agent-OZUPVFUI.js.map +7 -0
- package/dist/runner/quality-evaluator-XYNDKDRG.js +901 -0
- package/dist/runner/quality-evaluator-XYNDKDRG.js.map +7 -0
- package/dist/runner/session-end-3MJTDLLA.js +57 -0
- package/dist/runner/session-end-3MJTDLLA.js.map +7 -0
- package/dist/runner/session-start-5ZMCLKBS.js +352 -0
- package/dist/runner/session-start-5ZMCLKBS.js.map +7 -0
- package/dist/runner/shipper-status-MADX6SPG.js +37 -0
- package/dist/runner/shipper-status-MADX6SPG.js.map +7 -0
- package/dist/runner/span-shipper-4HQDHC47.js +3408 -0
- package/dist/runner/span-shipper-4HQDHC47.js.map +7 -0
- package/dist/runner/stop-RTKSIYJV.js +596 -0
- package/dist/runner/stop-RTKSIYJV.js.map +7 -0
- package/dist/runner/subagent-CBCG4OLZ.js +116 -0
- package/dist/runner/subagent-CBCG4OLZ.js.map +7 -0
- package/dist/runner/token-metrics-AD2RAFGM.js +31 -0
- package/dist/runner/token-metrics-AD2RAFGM.js.map +7 -0
- package/dist/runner/user-prompt-T5NZ2UJD.js +376 -0
- package/dist/runner/user-prompt-T5NZ2UJD.js.map +7 -0
- package/package.json +70 -5
|
@@ -0,0 +1,3408 @@
|
|
|
1
|
+
import { createRequire as __hookRunnerCreateRequire } from 'node:module';
|
|
2
|
+
const require = __hookRunnerCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
http1Fetch
|
|
5
|
+
} from "./chunk-W3EK7JUT.js";
|
|
6
|
+
import {
|
|
7
|
+
candidateFiles,
|
|
8
|
+
cursorPath,
|
|
9
|
+
describeOtlpCredentialConflict,
|
|
10
|
+
hasOtlpAuth,
|
|
11
|
+
loadCursor,
|
|
12
|
+
otlpAuthHeaders,
|
|
13
|
+
saveCursor
|
|
14
|
+
} from "./chunk-JRNNLOPR.js";
|
|
15
|
+
import {
|
|
16
|
+
addCount,
|
|
17
|
+
hasCounts,
|
|
18
|
+
recordShipperBusy,
|
|
19
|
+
recordShipperStatus,
|
|
20
|
+
shipPreflight,
|
|
21
|
+
shipperErrorDetail,
|
|
22
|
+
shipperErrorKind,
|
|
23
|
+
sumCounts
|
|
24
|
+
} from "./chunk-YGFN3LN2.js";
|
|
25
|
+
import {
|
|
26
|
+
CONTENT_TYPE_HEADER,
|
|
27
|
+
bearerHeaders,
|
|
28
|
+
errorCauseChain,
|
|
29
|
+
errorCode,
|
|
30
|
+
fetchWithTimeout
|
|
31
|
+
} from "./chunk-IJ4SLUBV.js";
|
|
32
|
+
import {
|
|
33
|
+
ATTR_SERVICE_NAME,
|
|
34
|
+
ATTR_SERVICE_VERSION,
|
|
35
|
+
SERVICE_VERSION,
|
|
36
|
+
SeverityNumber,
|
|
37
|
+
getServiceName,
|
|
38
|
+
init_esm as init_esm2,
|
|
39
|
+
pruneGitCache,
|
|
40
|
+
readMappedKey,
|
|
41
|
+
resolveKeySecretName,
|
|
42
|
+
resolveOtlpEndpoint
|
|
43
|
+
} from "./chunk-GG2I4TGI.js";
|
|
44
|
+
import "./chunk-SRMAJQMV.js";
|
|
45
|
+
import {
|
|
46
|
+
pruneSessionState
|
|
47
|
+
} from "./chunk-DNSTWC26.js";
|
|
48
|
+
import {
|
|
49
|
+
SHIPPER_LIMITS,
|
|
50
|
+
TELEMETRY_DIR,
|
|
51
|
+
THRESHOLDS,
|
|
52
|
+
ensureDirExists,
|
|
53
|
+
isJsonObject,
|
|
54
|
+
readBoundedLines
|
|
55
|
+
} from "./chunk-52RY6LQT.js";
|
|
56
|
+
import {
|
|
57
|
+
DURATION_MS,
|
|
58
|
+
TIME_MS
|
|
59
|
+
} from "./chunk-RWRGC7ZK.js";
|
|
60
|
+
import {
|
|
61
|
+
SpanKind,
|
|
62
|
+
SpanStatusCode,
|
|
63
|
+
TraceFlags,
|
|
64
|
+
ValueType,
|
|
65
|
+
diag,
|
|
66
|
+
init_esm
|
|
67
|
+
} from "./chunk-7PEOKGYR.js";
|
|
68
|
+
import {
|
|
69
|
+
__commonJS,
|
|
70
|
+
__require,
|
|
71
|
+
__toESM
|
|
72
|
+
} from "./chunk-GNNKUMRF.js";
|
|
73
|
+
|
|
74
|
+
// node_modules/graceful-fs/polyfills.js
|
|
75
|
+
var require_polyfills = __commonJS({
|
|
76
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module) {
|
|
77
|
+
var constants = __require("constants");
|
|
78
|
+
var origCwd = process.cwd;
|
|
79
|
+
var cwd = null;
|
|
80
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
81
|
+
process.cwd = function() {
|
|
82
|
+
if (!cwd)
|
|
83
|
+
cwd = origCwd.call(process);
|
|
84
|
+
return cwd;
|
|
85
|
+
};
|
|
86
|
+
try {
|
|
87
|
+
process.cwd();
|
|
88
|
+
} catch (er) {
|
|
89
|
+
}
|
|
90
|
+
if (typeof process.chdir === "function") {
|
|
91
|
+
chdir = process.chdir;
|
|
92
|
+
process.chdir = function(d) {
|
|
93
|
+
cwd = null;
|
|
94
|
+
chdir.call(process, d);
|
|
95
|
+
};
|
|
96
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
97
|
+
}
|
|
98
|
+
var chdir;
|
|
99
|
+
module.exports = patch;
|
|
100
|
+
function patch(fs) {
|
|
101
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
102
|
+
patchLchmod(fs);
|
|
103
|
+
}
|
|
104
|
+
if (!fs.lutimes) {
|
|
105
|
+
patchLutimes(fs);
|
|
106
|
+
}
|
|
107
|
+
fs.chown = chownFix(fs.chown);
|
|
108
|
+
fs.fchown = chownFix(fs.fchown);
|
|
109
|
+
fs.lchown = chownFix(fs.lchown);
|
|
110
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
111
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
112
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
113
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
114
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
115
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
116
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
117
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
118
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
119
|
+
fs.stat = statFix(fs.stat);
|
|
120
|
+
fs.fstat = statFix(fs.fstat);
|
|
121
|
+
fs.lstat = statFix(fs.lstat);
|
|
122
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
123
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
124
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
125
|
+
if (fs.chmod && !fs.lchmod) {
|
|
126
|
+
fs.lchmod = function(path, mode, cb) {
|
|
127
|
+
if (cb) process.nextTick(cb);
|
|
128
|
+
};
|
|
129
|
+
fs.lchmodSync = function() {
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (fs.chown && !fs.lchown) {
|
|
133
|
+
fs.lchown = function(path, uid, gid, cb) {
|
|
134
|
+
if (cb) process.nextTick(cb);
|
|
135
|
+
};
|
|
136
|
+
fs.lchownSync = function() {
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (platform === "win32") {
|
|
140
|
+
fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
|
|
141
|
+
function rename(from, to, cb) {
|
|
142
|
+
var start = Date.now();
|
|
143
|
+
var backoff = 0;
|
|
144
|
+
fs$rename(from, to, function CB(er) {
|
|
145
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
146
|
+
setTimeout(function() {
|
|
147
|
+
fs.stat(to, function(stater, st) {
|
|
148
|
+
if (stater && stater.code === "ENOENT")
|
|
149
|
+
fs$rename(from, to, CB);
|
|
150
|
+
else
|
|
151
|
+
cb(er);
|
|
152
|
+
});
|
|
153
|
+
}, backoff);
|
|
154
|
+
if (backoff < 100)
|
|
155
|
+
backoff += 10;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (cb) cb(er);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
162
|
+
return rename;
|
|
163
|
+
})(fs.rename);
|
|
164
|
+
}
|
|
165
|
+
fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
|
|
166
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
167
|
+
var callback;
|
|
168
|
+
if (callback_ && typeof callback_ === "function") {
|
|
169
|
+
var eagCounter = 0;
|
|
170
|
+
callback = function(er, _, __) {
|
|
171
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
172
|
+
eagCounter++;
|
|
173
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
174
|
+
}
|
|
175
|
+
callback_.apply(this, arguments);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
179
|
+
}
|
|
180
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
181
|
+
return read;
|
|
182
|
+
})(fs.read);
|
|
183
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
184
|
+
return function(fd, buffer, offset, length, position) {
|
|
185
|
+
var eagCounter = 0;
|
|
186
|
+
while (true) {
|
|
187
|
+
try {
|
|
188
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
189
|
+
} catch (er) {
|
|
190
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
191
|
+
eagCounter++;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
throw er;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
})(fs.readSync);
|
|
199
|
+
function patchLchmod(fs2) {
|
|
200
|
+
fs2.lchmod = function(path, mode, callback) {
|
|
201
|
+
fs2.open(
|
|
202
|
+
path,
|
|
203
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
204
|
+
mode,
|
|
205
|
+
function(err, fd) {
|
|
206
|
+
if (err) {
|
|
207
|
+
if (callback) callback(err);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
fs2.fchmod(fd, mode, function(err2) {
|
|
211
|
+
fs2.close(fd, function(err22) {
|
|
212
|
+
if (callback) callback(err2 || err22);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
fs2.lchmodSync = function(path, mode) {
|
|
219
|
+
var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
220
|
+
var threw = true;
|
|
221
|
+
var ret;
|
|
222
|
+
try {
|
|
223
|
+
ret = fs2.fchmodSync(fd, mode);
|
|
224
|
+
threw = false;
|
|
225
|
+
} finally {
|
|
226
|
+
if (threw) {
|
|
227
|
+
try {
|
|
228
|
+
fs2.closeSync(fd);
|
|
229
|
+
} catch (er) {
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
fs2.closeSync(fd);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return ret;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function patchLutimes(fs2) {
|
|
239
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
240
|
+
fs2.lutimes = function(path, at, mt, cb) {
|
|
241
|
+
fs2.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
242
|
+
if (er) {
|
|
243
|
+
if (cb) cb(er);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
fs2.futimes(fd, at, mt, function(er2) {
|
|
247
|
+
fs2.close(fd, function(er22) {
|
|
248
|
+
if (cb) cb(er2 || er22);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
fs2.lutimesSync = function(path, at, mt) {
|
|
254
|
+
var fd = fs2.openSync(path, constants.O_SYMLINK);
|
|
255
|
+
var ret;
|
|
256
|
+
var threw = true;
|
|
257
|
+
try {
|
|
258
|
+
ret = fs2.futimesSync(fd, at, mt);
|
|
259
|
+
threw = false;
|
|
260
|
+
} finally {
|
|
261
|
+
if (threw) {
|
|
262
|
+
try {
|
|
263
|
+
fs2.closeSync(fd);
|
|
264
|
+
} catch (er) {
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
fs2.closeSync(fd);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return ret;
|
|
271
|
+
};
|
|
272
|
+
} else if (fs2.futimes) {
|
|
273
|
+
fs2.lutimes = function(_a, _b, _c, cb) {
|
|
274
|
+
if (cb) process.nextTick(cb);
|
|
275
|
+
};
|
|
276
|
+
fs2.lutimesSync = function() {
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function chmodFix(orig) {
|
|
281
|
+
if (!orig) return orig;
|
|
282
|
+
return function(target, mode, cb) {
|
|
283
|
+
return orig.call(fs, target, mode, function(er) {
|
|
284
|
+
if (chownErOk(er)) er = null;
|
|
285
|
+
if (cb) cb.apply(this, arguments);
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function chmodFixSync(orig) {
|
|
290
|
+
if (!orig) return orig;
|
|
291
|
+
return function(target, mode) {
|
|
292
|
+
try {
|
|
293
|
+
return orig.call(fs, target, mode);
|
|
294
|
+
} catch (er) {
|
|
295
|
+
if (!chownErOk(er)) throw er;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function chownFix(orig) {
|
|
300
|
+
if (!orig) return orig;
|
|
301
|
+
return function(target, uid, gid, cb) {
|
|
302
|
+
return orig.call(fs, target, uid, gid, function(er) {
|
|
303
|
+
if (chownErOk(er)) er = null;
|
|
304
|
+
if (cb) cb.apply(this, arguments);
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function chownFixSync(orig) {
|
|
309
|
+
if (!orig) return orig;
|
|
310
|
+
return function(target, uid, gid) {
|
|
311
|
+
try {
|
|
312
|
+
return orig.call(fs, target, uid, gid);
|
|
313
|
+
} catch (er) {
|
|
314
|
+
if (!chownErOk(er)) throw er;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function statFix(orig) {
|
|
319
|
+
if (!orig) return orig;
|
|
320
|
+
return function(target, options, cb) {
|
|
321
|
+
if (typeof options === "function") {
|
|
322
|
+
cb = options;
|
|
323
|
+
options = null;
|
|
324
|
+
}
|
|
325
|
+
function callback(er, stats) {
|
|
326
|
+
if (stats) {
|
|
327
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
328
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
329
|
+
}
|
|
330
|
+
if (cb) cb.apply(this, arguments);
|
|
331
|
+
}
|
|
332
|
+
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function statFixSync(orig) {
|
|
336
|
+
if (!orig) return orig;
|
|
337
|
+
return function(target, options) {
|
|
338
|
+
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
339
|
+
if (stats) {
|
|
340
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
341
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
342
|
+
}
|
|
343
|
+
return stats;
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function chownErOk(er) {
|
|
347
|
+
if (!er)
|
|
348
|
+
return true;
|
|
349
|
+
if (er.code === "ENOSYS")
|
|
350
|
+
return true;
|
|
351
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
352
|
+
if (nonroot) {
|
|
353
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
363
|
+
var require_legacy_streams = __commonJS({
|
|
364
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
365
|
+
var Stream = __require("stream").Stream;
|
|
366
|
+
module.exports = legacy;
|
|
367
|
+
function legacy(fs) {
|
|
368
|
+
return {
|
|
369
|
+
ReadStream,
|
|
370
|
+
WriteStream
|
|
371
|
+
};
|
|
372
|
+
function ReadStream(path, options) {
|
|
373
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
|
374
|
+
Stream.call(this);
|
|
375
|
+
var self = this;
|
|
376
|
+
this.path = path;
|
|
377
|
+
this.fd = null;
|
|
378
|
+
this.readable = true;
|
|
379
|
+
this.paused = false;
|
|
380
|
+
this.flags = "r";
|
|
381
|
+
this.mode = 438;
|
|
382
|
+
this.bufferSize = 64 * 1024;
|
|
383
|
+
options = options || {};
|
|
384
|
+
var keys = Object.keys(options);
|
|
385
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
386
|
+
var key = keys[index];
|
|
387
|
+
this[key] = options[key];
|
|
388
|
+
}
|
|
389
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
390
|
+
if (this.start !== void 0) {
|
|
391
|
+
if ("number" !== typeof this.start) {
|
|
392
|
+
throw TypeError("start must be a Number");
|
|
393
|
+
}
|
|
394
|
+
if (this.end === void 0) {
|
|
395
|
+
this.end = Infinity;
|
|
396
|
+
} else if ("number" !== typeof this.end) {
|
|
397
|
+
throw TypeError("end must be a Number");
|
|
398
|
+
}
|
|
399
|
+
if (this.start > this.end) {
|
|
400
|
+
throw new Error("start must be <= end");
|
|
401
|
+
}
|
|
402
|
+
this.pos = this.start;
|
|
403
|
+
}
|
|
404
|
+
if (this.fd !== null) {
|
|
405
|
+
process.nextTick(function() {
|
|
406
|
+
self._read();
|
|
407
|
+
});
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
411
|
+
if (err) {
|
|
412
|
+
self.emit("error", err);
|
|
413
|
+
self.readable = false;
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
self.fd = fd;
|
|
417
|
+
self.emit("open", fd);
|
|
418
|
+
self._read();
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function WriteStream(path, options) {
|
|
422
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
|
423
|
+
Stream.call(this);
|
|
424
|
+
this.path = path;
|
|
425
|
+
this.fd = null;
|
|
426
|
+
this.writable = true;
|
|
427
|
+
this.flags = "w";
|
|
428
|
+
this.encoding = "binary";
|
|
429
|
+
this.mode = 438;
|
|
430
|
+
this.bytesWritten = 0;
|
|
431
|
+
options = options || {};
|
|
432
|
+
var keys = Object.keys(options);
|
|
433
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
434
|
+
var key = keys[index];
|
|
435
|
+
this[key] = options[key];
|
|
436
|
+
}
|
|
437
|
+
if (this.start !== void 0) {
|
|
438
|
+
if ("number" !== typeof this.start) {
|
|
439
|
+
throw TypeError("start must be a Number");
|
|
440
|
+
}
|
|
441
|
+
if (this.start < 0) {
|
|
442
|
+
throw new Error("start must be >= zero");
|
|
443
|
+
}
|
|
444
|
+
this.pos = this.start;
|
|
445
|
+
}
|
|
446
|
+
this.busy = false;
|
|
447
|
+
this._queue = [];
|
|
448
|
+
if (this.fd === null) {
|
|
449
|
+
this._open = fs.open;
|
|
450
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
451
|
+
this.flush();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// node_modules/graceful-fs/clone.js
|
|
459
|
+
var require_clone = __commonJS({
|
|
460
|
+
"node_modules/graceful-fs/clone.js"(exports, module) {
|
|
461
|
+
"use strict";
|
|
462
|
+
module.exports = clone;
|
|
463
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
464
|
+
return obj.__proto__;
|
|
465
|
+
};
|
|
466
|
+
function clone(obj) {
|
|
467
|
+
if (obj === null || typeof obj !== "object")
|
|
468
|
+
return obj;
|
|
469
|
+
if (obj instanceof Object)
|
|
470
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
471
|
+
else
|
|
472
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
473
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
474
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
475
|
+
});
|
|
476
|
+
return copy;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
482
|
+
var require_graceful_fs = __commonJS({
|
|
483
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
484
|
+
var fs = __require("fs");
|
|
485
|
+
var polyfills = require_polyfills();
|
|
486
|
+
var legacy = require_legacy_streams();
|
|
487
|
+
var clone = require_clone();
|
|
488
|
+
var util = __require("util");
|
|
489
|
+
var gracefulQueue;
|
|
490
|
+
var previousSymbol;
|
|
491
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
492
|
+
gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
|
|
493
|
+
previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
|
|
494
|
+
} else {
|
|
495
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
496
|
+
previousSymbol = "___graceful-fs.previous";
|
|
497
|
+
}
|
|
498
|
+
function noop() {
|
|
499
|
+
}
|
|
500
|
+
function publishQueue(context, queue2) {
|
|
501
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
502
|
+
get: function() {
|
|
503
|
+
return queue2;
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
var debug = noop;
|
|
508
|
+
if (util.debuglog)
|
|
509
|
+
debug = util.debuglog("gfs4");
|
|
510
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
511
|
+
debug = function() {
|
|
512
|
+
var m = util.format.apply(util, arguments);
|
|
513
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
514
|
+
console.error(m);
|
|
515
|
+
};
|
|
516
|
+
if (!fs[gracefulQueue]) {
|
|
517
|
+
queue = global[gracefulQueue] || [];
|
|
518
|
+
publishQueue(fs, queue);
|
|
519
|
+
fs.close = (function(fs$close) {
|
|
520
|
+
function close(fd, cb) {
|
|
521
|
+
return fs$close.call(fs, fd, function(err) {
|
|
522
|
+
if (!err) {
|
|
523
|
+
resetQueue();
|
|
524
|
+
}
|
|
525
|
+
if (typeof cb === "function")
|
|
526
|
+
cb.apply(this, arguments);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
Object.defineProperty(close, previousSymbol, {
|
|
530
|
+
value: fs$close
|
|
531
|
+
});
|
|
532
|
+
return close;
|
|
533
|
+
})(fs.close);
|
|
534
|
+
fs.closeSync = (function(fs$closeSync) {
|
|
535
|
+
function closeSync(fd) {
|
|
536
|
+
fs$closeSync.apply(fs, arguments);
|
|
537
|
+
resetQueue();
|
|
538
|
+
}
|
|
539
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
540
|
+
value: fs$closeSync
|
|
541
|
+
});
|
|
542
|
+
return closeSync;
|
|
543
|
+
})(fs.closeSync);
|
|
544
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
545
|
+
process.on("exit", function() {
|
|
546
|
+
debug(fs[gracefulQueue]);
|
|
547
|
+
__require("assert").equal(fs[gracefulQueue].length, 0);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
var queue;
|
|
552
|
+
if (!global[gracefulQueue]) {
|
|
553
|
+
publishQueue(global, fs[gracefulQueue]);
|
|
554
|
+
}
|
|
555
|
+
module.exports = patch(clone(fs));
|
|
556
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
557
|
+
module.exports = patch(fs);
|
|
558
|
+
fs.__patched = true;
|
|
559
|
+
}
|
|
560
|
+
function patch(fs2) {
|
|
561
|
+
polyfills(fs2);
|
|
562
|
+
fs2.gracefulify = patch;
|
|
563
|
+
fs2.createReadStream = createReadStream;
|
|
564
|
+
fs2.createWriteStream = createWriteStream;
|
|
565
|
+
var fs$readFile = fs2.readFile;
|
|
566
|
+
fs2.readFile = readFile;
|
|
567
|
+
function readFile(path, options, cb) {
|
|
568
|
+
if (typeof options === "function")
|
|
569
|
+
cb = options, options = null;
|
|
570
|
+
return go$readFile(path, options, cb);
|
|
571
|
+
function go$readFile(path2, options2, cb2, startTime) {
|
|
572
|
+
return fs$readFile(path2, options2, function(err) {
|
|
573
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
574
|
+
enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
575
|
+
else {
|
|
576
|
+
if (typeof cb2 === "function")
|
|
577
|
+
cb2.apply(this, arguments);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
var fs$writeFile = fs2.writeFile;
|
|
583
|
+
fs2.writeFile = writeFile;
|
|
584
|
+
function writeFile(path, data, options, cb) {
|
|
585
|
+
if (typeof options === "function")
|
|
586
|
+
cb = options, options = null;
|
|
587
|
+
return go$writeFile(path, data, options, cb);
|
|
588
|
+
function go$writeFile(path2, data2, options2, cb2, startTime) {
|
|
589
|
+
return fs$writeFile(path2, data2, options2, function(err) {
|
|
590
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
591
|
+
enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
592
|
+
else {
|
|
593
|
+
if (typeof cb2 === "function")
|
|
594
|
+
cb2.apply(this, arguments);
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
var fs$appendFile = fs2.appendFile;
|
|
600
|
+
if (fs$appendFile)
|
|
601
|
+
fs2.appendFile = appendFile;
|
|
602
|
+
function appendFile(path, data, options, cb) {
|
|
603
|
+
if (typeof options === "function")
|
|
604
|
+
cb = options, options = null;
|
|
605
|
+
return go$appendFile(path, data, options, cb);
|
|
606
|
+
function go$appendFile(path2, data2, options2, cb2, startTime) {
|
|
607
|
+
return fs$appendFile(path2, data2, options2, function(err) {
|
|
608
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
609
|
+
enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
610
|
+
else {
|
|
611
|
+
if (typeof cb2 === "function")
|
|
612
|
+
cb2.apply(this, arguments);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
var fs$copyFile = fs2.copyFile;
|
|
618
|
+
if (fs$copyFile)
|
|
619
|
+
fs2.copyFile = copyFile;
|
|
620
|
+
function copyFile(src, dest, flags, cb) {
|
|
621
|
+
if (typeof flags === "function") {
|
|
622
|
+
cb = flags;
|
|
623
|
+
flags = 0;
|
|
624
|
+
}
|
|
625
|
+
return go$copyFile(src, dest, flags, cb);
|
|
626
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
627
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
628
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
629
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
630
|
+
else {
|
|
631
|
+
if (typeof cb2 === "function")
|
|
632
|
+
cb2.apply(this, arguments);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
var fs$readdir = fs2.readdir;
|
|
638
|
+
fs2.readdir = readdir;
|
|
639
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
640
|
+
function readdir(path, options, cb) {
|
|
641
|
+
if (typeof options === "function")
|
|
642
|
+
cb = options, options = null;
|
|
643
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
|
|
644
|
+
return fs$readdir(path2, fs$readdirCallback(
|
|
645
|
+
path2,
|
|
646
|
+
options2,
|
|
647
|
+
cb2,
|
|
648
|
+
startTime
|
|
649
|
+
));
|
|
650
|
+
} : function go$readdir2(path2, options2, cb2, startTime) {
|
|
651
|
+
return fs$readdir(path2, options2, fs$readdirCallback(
|
|
652
|
+
path2,
|
|
653
|
+
options2,
|
|
654
|
+
cb2,
|
|
655
|
+
startTime
|
|
656
|
+
));
|
|
657
|
+
};
|
|
658
|
+
return go$readdir(path, options, cb);
|
|
659
|
+
function fs$readdirCallback(path2, options2, cb2, startTime) {
|
|
660
|
+
return function(err, files) {
|
|
661
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
662
|
+
enqueue([
|
|
663
|
+
go$readdir,
|
|
664
|
+
[path2, options2, cb2],
|
|
665
|
+
err,
|
|
666
|
+
startTime || Date.now(),
|
|
667
|
+
Date.now()
|
|
668
|
+
]);
|
|
669
|
+
else {
|
|
670
|
+
if (files && files.sort)
|
|
671
|
+
files.sort();
|
|
672
|
+
if (typeof cb2 === "function")
|
|
673
|
+
cb2.call(this, err, files);
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
679
|
+
var legStreams = legacy(fs2);
|
|
680
|
+
ReadStream = legStreams.ReadStream;
|
|
681
|
+
WriteStream = legStreams.WriteStream;
|
|
682
|
+
}
|
|
683
|
+
var fs$ReadStream = fs2.ReadStream;
|
|
684
|
+
if (fs$ReadStream) {
|
|
685
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
686
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
687
|
+
}
|
|
688
|
+
var fs$WriteStream = fs2.WriteStream;
|
|
689
|
+
if (fs$WriteStream) {
|
|
690
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
691
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
692
|
+
}
|
|
693
|
+
Object.defineProperty(fs2, "ReadStream", {
|
|
694
|
+
get: function() {
|
|
695
|
+
return ReadStream;
|
|
696
|
+
},
|
|
697
|
+
set: function(val) {
|
|
698
|
+
ReadStream = val;
|
|
699
|
+
},
|
|
700
|
+
enumerable: true,
|
|
701
|
+
configurable: true
|
|
702
|
+
});
|
|
703
|
+
Object.defineProperty(fs2, "WriteStream", {
|
|
704
|
+
get: function() {
|
|
705
|
+
return WriteStream;
|
|
706
|
+
},
|
|
707
|
+
set: function(val) {
|
|
708
|
+
WriteStream = val;
|
|
709
|
+
},
|
|
710
|
+
enumerable: true,
|
|
711
|
+
configurable: true
|
|
712
|
+
});
|
|
713
|
+
var FileReadStream = ReadStream;
|
|
714
|
+
Object.defineProperty(fs2, "FileReadStream", {
|
|
715
|
+
get: function() {
|
|
716
|
+
return FileReadStream;
|
|
717
|
+
},
|
|
718
|
+
set: function(val) {
|
|
719
|
+
FileReadStream = val;
|
|
720
|
+
},
|
|
721
|
+
enumerable: true,
|
|
722
|
+
configurable: true
|
|
723
|
+
});
|
|
724
|
+
var FileWriteStream = WriteStream;
|
|
725
|
+
Object.defineProperty(fs2, "FileWriteStream", {
|
|
726
|
+
get: function() {
|
|
727
|
+
return FileWriteStream;
|
|
728
|
+
},
|
|
729
|
+
set: function(val) {
|
|
730
|
+
FileWriteStream = val;
|
|
731
|
+
},
|
|
732
|
+
enumerable: true,
|
|
733
|
+
configurable: true
|
|
734
|
+
});
|
|
735
|
+
function ReadStream(path, options) {
|
|
736
|
+
if (this instanceof ReadStream)
|
|
737
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
738
|
+
else
|
|
739
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
740
|
+
}
|
|
741
|
+
function ReadStream$open() {
|
|
742
|
+
var that = this;
|
|
743
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
744
|
+
if (err) {
|
|
745
|
+
if (that.autoClose)
|
|
746
|
+
that.destroy();
|
|
747
|
+
that.emit("error", err);
|
|
748
|
+
} else {
|
|
749
|
+
that.fd = fd;
|
|
750
|
+
that.emit("open", fd);
|
|
751
|
+
that.read();
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
function WriteStream(path, options) {
|
|
756
|
+
if (this instanceof WriteStream)
|
|
757
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
758
|
+
else
|
|
759
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
760
|
+
}
|
|
761
|
+
function WriteStream$open() {
|
|
762
|
+
var that = this;
|
|
763
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
764
|
+
if (err) {
|
|
765
|
+
that.destroy();
|
|
766
|
+
that.emit("error", err);
|
|
767
|
+
} else {
|
|
768
|
+
that.fd = fd;
|
|
769
|
+
that.emit("open", fd);
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
function createReadStream(path, options) {
|
|
774
|
+
return new fs2.ReadStream(path, options);
|
|
775
|
+
}
|
|
776
|
+
function createWriteStream(path, options) {
|
|
777
|
+
return new fs2.WriteStream(path, options);
|
|
778
|
+
}
|
|
779
|
+
var fs$open = fs2.open;
|
|
780
|
+
fs2.open = open;
|
|
781
|
+
function open(path, flags, mode, cb) {
|
|
782
|
+
if (typeof mode === "function")
|
|
783
|
+
cb = mode, mode = null;
|
|
784
|
+
return go$open(path, flags, mode, cb);
|
|
785
|
+
function go$open(path2, flags2, mode2, cb2, startTime) {
|
|
786
|
+
return fs$open(path2, flags2, mode2, function(err, fd) {
|
|
787
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
788
|
+
enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
789
|
+
else {
|
|
790
|
+
if (typeof cb2 === "function")
|
|
791
|
+
cb2.apply(this, arguments);
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return fs2;
|
|
797
|
+
}
|
|
798
|
+
function enqueue(elem) {
|
|
799
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
800
|
+
fs[gracefulQueue].push(elem);
|
|
801
|
+
retry();
|
|
802
|
+
}
|
|
803
|
+
var retryTimer;
|
|
804
|
+
function resetQueue() {
|
|
805
|
+
var now = Date.now();
|
|
806
|
+
for (var i = 0; i < fs[gracefulQueue].length; ++i) {
|
|
807
|
+
if (fs[gracefulQueue][i].length > 2) {
|
|
808
|
+
fs[gracefulQueue][i][3] = now;
|
|
809
|
+
fs[gracefulQueue][i][4] = now;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
retry();
|
|
813
|
+
}
|
|
814
|
+
function retry() {
|
|
815
|
+
clearTimeout(retryTimer);
|
|
816
|
+
retryTimer = void 0;
|
|
817
|
+
if (fs[gracefulQueue].length === 0)
|
|
818
|
+
return;
|
|
819
|
+
var elem = fs[gracefulQueue].shift();
|
|
820
|
+
var fn = elem[0];
|
|
821
|
+
var args = elem[1];
|
|
822
|
+
var err = elem[2];
|
|
823
|
+
var startTime = elem[3];
|
|
824
|
+
var lastTime = elem[4];
|
|
825
|
+
if (startTime === void 0) {
|
|
826
|
+
debug("RETRY", fn.name, args);
|
|
827
|
+
fn.apply(null, args);
|
|
828
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
829
|
+
debug("TIMEOUT", fn.name, args);
|
|
830
|
+
var cb = args.pop();
|
|
831
|
+
if (typeof cb === "function")
|
|
832
|
+
cb.call(null, err);
|
|
833
|
+
} else {
|
|
834
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
835
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
836
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
837
|
+
if (sinceAttempt >= desiredDelay) {
|
|
838
|
+
debug("RETRY", fn.name, args);
|
|
839
|
+
fn.apply(null, args.concat([startTime]));
|
|
840
|
+
} else {
|
|
841
|
+
fs[gracefulQueue].push(elem);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (retryTimer === void 0) {
|
|
845
|
+
retryTimer = setTimeout(retry, 0);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
// node_modules/retry/lib/retry_operation.js
|
|
852
|
+
var require_retry_operation = __commonJS({
|
|
853
|
+
"node_modules/retry/lib/retry_operation.js"(exports, module) {
|
|
854
|
+
function RetryOperation(timeouts, options) {
|
|
855
|
+
if (typeof options === "boolean") {
|
|
856
|
+
options = { forever: options };
|
|
857
|
+
}
|
|
858
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
859
|
+
this._timeouts = timeouts;
|
|
860
|
+
this._options = options || {};
|
|
861
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
862
|
+
this._fn = null;
|
|
863
|
+
this._errors = [];
|
|
864
|
+
this._attempts = 1;
|
|
865
|
+
this._operationTimeout = null;
|
|
866
|
+
this._operationTimeoutCb = null;
|
|
867
|
+
this._timeout = null;
|
|
868
|
+
this._operationStart = null;
|
|
869
|
+
if (this._options.forever) {
|
|
870
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
module.exports = RetryOperation;
|
|
874
|
+
RetryOperation.prototype.reset = function() {
|
|
875
|
+
this._attempts = 1;
|
|
876
|
+
this._timeouts = this._originalTimeouts;
|
|
877
|
+
};
|
|
878
|
+
RetryOperation.prototype.stop = function() {
|
|
879
|
+
if (this._timeout) {
|
|
880
|
+
clearTimeout(this._timeout);
|
|
881
|
+
}
|
|
882
|
+
this._timeouts = [];
|
|
883
|
+
this._cachedTimeouts = null;
|
|
884
|
+
};
|
|
885
|
+
RetryOperation.prototype.retry = function(err) {
|
|
886
|
+
if (this._timeout) {
|
|
887
|
+
clearTimeout(this._timeout);
|
|
888
|
+
}
|
|
889
|
+
if (!err) {
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
893
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
894
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
895
|
+
return false;
|
|
896
|
+
}
|
|
897
|
+
this._errors.push(err);
|
|
898
|
+
var timeout = this._timeouts.shift();
|
|
899
|
+
if (timeout === void 0) {
|
|
900
|
+
if (this._cachedTimeouts) {
|
|
901
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
902
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
903
|
+
timeout = this._timeouts.shift();
|
|
904
|
+
} else {
|
|
905
|
+
return false;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
var self = this;
|
|
909
|
+
var timer = setTimeout(function() {
|
|
910
|
+
self._attempts++;
|
|
911
|
+
if (self._operationTimeoutCb) {
|
|
912
|
+
self._timeout = setTimeout(function() {
|
|
913
|
+
self._operationTimeoutCb(self._attempts);
|
|
914
|
+
}, self._operationTimeout);
|
|
915
|
+
if (self._options.unref) {
|
|
916
|
+
self._timeout.unref();
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
self._fn(self._attempts);
|
|
920
|
+
}, timeout);
|
|
921
|
+
if (this._options.unref) {
|
|
922
|
+
timer.unref();
|
|
923
|
+
}
|
|
924
|
+
return true;
|
|
925
|
+
};
|
|
926
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
927
|
+
this._fn = fn;
|
|
928
|
+
if (timeoutOps) {
|
|
929
|
+
if (timeoutOps.timeout) {
|
|
930
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
931
|
+
}
|
|
932
|
+
if (timeoutOps.cb) {
|
|
933
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
var self = this;
|
|
937
|
+
if (this._operationTimeoutCb) {
|
|
938
|
+
this._timeout = setTimeout(function() {
|
|
939
|
+
self._operationTimeoutCb();
|
|
940
|
+
}, self._operationTimeout);
|
|
941
|
+
}
|
|
942
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
943
|
+
this._fn(this._attempts);
|
|
944
|
+
};
|
|
945
|
+
RetryOperation.prototype.try = function(fn) {
|
|
946
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
947
|
+
this.attempt(fn);
|
|
948
|
+
};
|
|
949
|
+
RetryOperation.prototype.start = function(fn) {
|
|
950
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
951
|
+
this.attempt(fn);
|
|
952
|
+
};
|
|
953
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
954
|
+
RetryOperation.prototype.errors = function() {
|
|
955
|
+
return this._errors;
|
|
956
|
+
};
|
|
957
|
+
RetryOperation.prototype.attempts = function() {
|
|
958
|
+
return this._attempts;
|
|
959
|
+
};
|
|
960
|
+
RetryOperation.prototype.mainError = function() {
|
|
961
|
+
if (this._errors.length === 0) {
|
|
962
|
+
return null;
|
|
963
|
+
}
|
|
964
|
+
var counts = {};
|
|
965
|
+
var mainError = null;
|
|
966
|
+
var mainErrorCount = 0;
|
|
967
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
968
|
+
var error = this._errors[i];
|
|
969
|
+
var message = error.message;
|
|
970
|
+
var count = (counts[message] || 0) + 1;
|
|
971
|
+
counts[message] = count;
|
|
972
|
+
if (count >= mainErrorCount) {
|
|
973
|
+
mainError = error;
|
|
974
|
+
mainErrorCount = count;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return mainError;
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
// node_modules/retry/lib/retry.js
|
|
983
|
+
var require_retry = __commonJS({
|
|
984
|
+
"node_modules/retry/lib/retry.js"(exports) {
|
|
985
|
+
var RetryOperation = require_retry_operation();
|
|
986
|
+
exports.operation = function(options) {
|
|
987
|
+
var timeouts = exports.timeouts(options);
|
|
988
|
+
return new RetryOperation(timeouts, {
|
|
989
|
+
forever: options && options.forever,
|
|
990
|
+
unref: options && options.unref,
|
|
991
|
+
maxRetryTime: options && options.maxRetryTime
|
|
992
|
+
});
|
|
993
|
+
};
|
|
994
|
+
exports.timeouts = function(options) {
|
|
995
|
+
if (options instanceof Array) {
|
|
996
|
+
return [].concat(options);
|
|
997
|
+
}
|
|
998
|
+
var opts = {
|
|
999
|
+
retries: 10,
|
|
1000
|
+
factor: 2,
|
|
1001
|
+
minTimeout: 1 * 1e3,
|
|
1002
|
+
maxTimeout: Infinity,
|
|
1003
|
+
randomize: false
|
|
1004
|
+
};
|
|
1005
|
+
for (var key in options) {
|
|
1006
|
+
opts[key] = options[key];
|
|
1007
|
+
}
|
|
1008
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
1009
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
1010
|
+
}
|
|
1011
|
+
var timeouts = [];
|
|
1012
|
+
for (var i = 0; i < opts.retries; i++) {
|
|
1013
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
1014
|
+
}
|
|
1015
|
+
if (options && options.forever && !timeouts.length) {
|
|
1016
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
1017
|
+
}
|
|
1018
|
+
timeouts.sort(function(a, b) {
|
|
1019
|
+
return a - b;
|
|
1020
|
+
});
|
|
1021
|
+
return timeouts;
|
|
1022
|
+
};
|
|
1023
|
+
exports.createTimeout = function(attempt, opts) {
|
|
1024
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
1025
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
1026
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
1027
|
+
return timeout;
|
|
1028
|
+
};
|
|
1029
|
+
exports.wrap = function(obj, options, methods) {
|
|
1030
|
+
if (options instanceof Array) {
|
|
1031
|
+
methods = options;
|
|
1032
|
+
options = null;
|
|
1033
|
+
}
|
|
1034
|
+
if (!methods) {
|
|
1035
|
+
methods = [];
|
|
1036
|
+
for (var key in obj) {
|
|
1037
|
+
if (typeof obj[key] === "function") {
|
|
1038
|
+
methods.push(key);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
for (var i = 0; i < methods.length; i++) {
|
|
1043
|
+
var method = methods[i];
|
|
1044
|
+
var original = obj[method];
|
|
1045
|
+
obj[method] = function retryWrapper(original2) {
|
|
1046
|
+
var op = exports.operation(options);
|
|
1047
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
1048
|
+
var callback = args.pop();
|
|
1049
|
+
args.push(function(err) {
|
|
1050
|
+
if (op.retry(err)) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
if (err) {
|
|
1054
|
+
arguments[0] = op.mainError();
|
|
1055
|
+
}
|
|
1056
|
+
callback.apply(this, arguments);
|
|
1057
|
+
});
|
|
1058
|
+
op.attempt(function() {
|
|
1059
|
+
original2.apply(obj, args);
|
|
1060
|
+
});
|
|
1061
|
+
}.bind(obj, original);
|
|
1062
|
+
obj[method].options = options;
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
// node_modules/retry/index.js
|
|
1069
|
+
var require_retry2 = __commonJS({
|
|
1070
|
+
"node_modules/retry/index.js"(exports, module) {
|
|
1071
|
+
module.exports = require_retry();
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
// node_modules/signal-exit/signals.js
|
|
1076
|
+
var require_signals = __commonJS({
|
|
1077
|
+
"node_modules/signal-exit/signals.js"(exports, module) {
|
|
1078
|
+
module.exports = [
|
|
1079
|
+
"SIGABRT",
|
|
1080
|
+
"SIGALRM",
|
|
1081
|
+
"SIGHUP",
|
|
1082
|
+
"SIGINT",
|
|
1083
|
+
"SIGTERM"
|
|
1084
|
+
];
|
|
1085
|
+
if (process.platform !== "win32") {
|
|
1086
|
+
module.exports.push(
|
|
1087
|
+
"SIGVTALRM",
|
|
1088
|
+
"SIGXCPU",
|
|
1089
|
+
"SIGXFSZ",
|
|
1090
|
+
"SIGUSR2",
|
|
1091
|
+
"SIGTRAP",
|
|
1092
|
+
"SIGSYS",
|
|
1093
|
+
"SIGQUIT",
|
|
1094
|
+
"SIGIOT"
|
|
1095
|
+
// should detect profiler and enable/disable accordingly.
|
|
1096
|
+
// see #21
|
|
1097
|
+
// 'SIGPROF'
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
if (process.platform === "linux") {
|
|
1101
|
+
module.exports.push(
|
|
1102
|
+
"SIGIO",
|
|
1103
|
+
"SIGPOLL",
|
|
1104
|
+
"SIGPWR",
|
|
1105
|
+
"SIGSTKFLT",
|
|
1106
|
+
"SIGUNUSED"
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
// node_modules/signal-exit/index.js
|
|
1113
|
+
var require_signal_exit = __commonJS({
|
|
1114
|
+
"node_modules/signal-exit/index.js"(exports, module) {
|
|
1115
|
+
var process2 = global.process;
|
|
1116
|
+
var processOk = function(process3) {
|
|
1117
|
+
return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
1118
|
+
};
|
|
1119
|
+
if (!processOk(process2)) {
|
|
1120
|
+
module.exports = function() {
|
|
1121
|
+
return function() {
|
|
1122
|
+
};
|
|
1123
|
+
};
|
|
1124
|
+
} else {
|
|
1125
|
+
assert = __require("assert");
|
|
1126
|
+
signals = require_signals();
|
|
1127
|
+
isWin = /^win/i.test(process2.platform);
|
|
1128
|
+
EE = __require("events");
|
|
1129
|
+
if (typeof EE !== "function") {
|
|
1130
|
+
EE = EE.EventEmitter;
|
|
1131
|
+
}
|
|
1132
|
+
if (process2.__signal_exit_emitter__) {
|
|
1133
|
+
emitter = process2.__signal_exit_emitter__;
|
|
1134
|
+
} else {
|
|
1135
|
+
emitter = process2.__signal_exit_emitter__ = new EE();
|
|
1136
|
+
emitter.count = 0;
|
|
1137
|
+
emitter.emitted = {};
|
|
1138
|
+
}
|
|
1139
|
+
if (!emitter.infinite) {
|
|
1140
|
+
emitter.setMaxListeners(Infinity);
|
|
1141
|
+
emitter.infinite = true;
|
|
1142
|
+
}
|
|
1143
|
+
module.exports = function(cb, opts) {
|
|
1144
|
+
if (!processOk(global.process)) {
|
|
1145
|
+
return function() {
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1149
|
+
if (loaded === false) {
|
|
1150
|
+
load();
|
|
1151
|
+
}
|
|
1152
|
+
var ev = "exit";
|
|
1153
|
+
if (opts && opts.alwaysLast) {
|
|
1154
|
+
ev = "afterexit";
|
|
1155
|
+
}
|
|
1156
|
+
var remove = function() {
|
|
1157
|
+
emitter.removeListener(ev, cb);
|
|
1158
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1159
|
+
unload();
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
emitter.on(ev, cb);
|
|
1163
|
+
return remove;
|
|
1164
|
+
};
|
|
1165
|
+
unload = function unload2() {
|
|
1166
|
+
if (!loaded || !processOk(global.process)) {
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
loaded = false;
|
|
1170
|
+
signals.forEach(function(sig) {
|
|
1171
|
+
try {
|
|
1172
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
1173
|
+
} catch (er) {
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
process2.emit = originalProcessEmit;
|
|
1177
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
1178
|
+
emitter.count -= 1;
|
|
1179
|
+
};
|
|
1180
|
+
module.exports.unload = unload;
|
|
1181
|
+
emit = function emit2(event, code, signal) {
|
|
1182
|
+
if (emitter.emitted[event]) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
emitter.emitted[event] = true;
|
|
1186
|
+
emitter.emit(event, code, signal);
|
|
1187
|
+
};
|
|
1188
|
+
sigListeners = {};
|
|
1189
|
+
signals.forEach(function(sig) {
|
|
1190
|
+
sigListeners[sig] = function listener() {
|
|
1191
|
+
if (!processOk(global.process)) {
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
var listeners = process2.listeners(sig);
|
|
1195
|
+
if (listeners.length === emitter.count) {
|
|
1196
|
+
unload();
|
|
1197
|
+
emit("exit", null, sig);
|
|
1198
|
+
emit("afterexit", null, sig);
|
|
1199
|
+
if (isWin && sig === "SIGHUP") {
|
|
1200
|
+
sig = "SIGINT";
|
|
1201
|
+
}
|
|
1202
|
+
process2.kill(process2.pid, sig);
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
});
|
|
1206
|
+
module.exports.signals = function() {
|
|
1207
|
+
return signals;
|
|
1208
|
+
};
|
|
1209
|
+
loaded = false;
|
|
1210
|
+
load = function load2() {
|
|
1211
|
+
if (loaded || !processOk(global.process)) {
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
loaded = true;
|
|
1215
|
+
emitter.count += 1;
|
|
1216
|
+
signals = signals.filter(function(sig) {
|
|
1217
|
+
try {
|
|
1218
|
+
process2.on(sig, sigListeners[sig]);
|
|
1219
|
+
return true;
|
|
1220
|
+
} catch (er) {
|
|
1221
|
+
return false;
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
process2.emit = processEmit;
|
|
1225
|
+
process2.reallyExit = processReallyExit;
|
|
1226
|
+
};
|
|
1227
|
+
module.exports.load = load;
|
|
1228
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
1229
|
+
processReallyExit = function processReallyExit2(code) {
|
|
1230
|
+
if (!processOk(global.process)) {
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
process2.exitCode = code || /* istanbul ignore next */
|
|
1234
|
+
0;
|
|
1235
|
+
emit("exit", process2.exitCode, null);
|
|
1236
|
+
emit("afterexit", process2.exitCode, null);
|
|
1237
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
1238
|
+
};
|
|
1239
|
+
originalProcessEmit = process2.emit;
|
|
1240
|
+
processEmit = function processEmit2(ev, arg) {
|
|
1241
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1242
|
+
if (arg !== void 0) {
|
|
1243
|
+
process2.exitCode = arg;
|
|
1244
|
+
}
|
|
1245
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1246
|
+
emit("exit", process2.exitCode, null);
|
|
1247
|
+
emit("afterexit", process2.exitCode, null);
|
|
1248
|
+
return ret;
|
|
1249
|
+
} else {
|
|
1250
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
var assert;
|
|
1255
|
+
var signals;
|
|
1256
|
+
var isWin;
|
|
1257
|
+
var EE;
|
|
1258
|
+
var emitter;
|
|
1259
|
+
var unload;
|
|
1260
|
+
var emit;
|
|
1261
|
+
var sigListeners;
|
|
1262
|
+
var loaded;
|
|
1263
|
+
var load;
|
|
1264
|
+
var originalProcessReallyExit;
|
|
1265
|
+
var processReallyExit;
|
|
1266
|
+
var originalProcessEmit;
|
|
1267
|
+
var processEmit;
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1272
|
+
var require_mtime_precision = __commonJS({
|
|
1273
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1274
|
+
"use strict";
|
|
1275
|
+
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
1276
|
+
function probe(file, fs, callback) {
|
|
1277
|
+
const cachedPrecision = fs[cacheSymbol];
|
|
1278
|
+
if (cachedPrecision) {
|
|
1279
|
+
return fs.stat(file, (err, stat) => {
|
|
1280
|
+
if (err) {
|
|
1281
|
+
return callback(err);
|
|
1282
|
+
}
|
|
1283
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1287
|
+
fs.utimes(file, mtime, mtime, (err) => {
|
|
1288
|
+
if (err) {
|
|
1289
|
+
return callback(err);
|
|
1290
|
+
}
|
|
1291
|
+
fs.stat(file, (err2, stat) => {
|
|
1292
|
+
if (err2) {
|
|
1293
|
+
return callback(err2);
|
|
1294
|
+
}
|
|
1295
|
+
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1296
|
+
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
1297
|
+
callback(null, stat.mtime, precision);
|
|
1298
|
+
});
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
function getMtime(precision) {
|
|
1302
|
+
let now = Date.now();
|
|
1303
|
+
if (precision === "s") {
|
|
1304
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1305
|
+
}
|
|
1306
|
+
return new Date(now);
|
|
1307
|
+
}
|
|
1308
|
+
module.exports.probe = probe;
|
|
1309
|
+
module.exports.getMtime = getMtime;
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
|
|
1313
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1314
|
+
var require_lockfile = __commonJS({
|
|
1315
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1316
|
+
"use strict";
|
|
1317
|
+
var path = __require("path");
|
|
1318
|
+
var fs = require_graceful_fs();
|
|
1319
|
+
var retry = require_retry2();
|
|
1320
|
+
var onExit = require_signal_exit();
|
|
1321
|
+
var mtimePrecision = require_mtime_precision();
|
|
1322
|
+
var locks = {};
|
|
1323
|
+
function getLockFile(file, options) {
|
|
1324
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1325
|
+
}
|
|
1326
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1327
|
+
if (!options.realpath) {
|
|
1328
|
+
return callback(null, path.resolve(file));
|
|
1329
|
+
}
|
|
1330
|
+
options.fs.realpath(file, callback);
|
|
1331
|
+
}
|
|
1332
|
+
function acquireLock(file, options, callback) {
|
|
1333
|
+
const lockfilePath = getLockFile(file, options);
|
|
1334
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
1335
|
+
if (!err) {
|
|
1336
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
|
|
1337
|
+
if (err2) {
|
|
1338
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1339
|
+
});
|
|
1340
|
+
return callback(err2);
|
|
1341
|
+
}
|
|
1342
|
+
callback(null, mtime, mtimePrecision2);
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
if (err.code !== "EEXIST") {
|
|
1346
|
+
return callback(err);
|
|
1347
|
+
}
|
|
1348
|
+
if (options.stale <= 0) {
|
|
1349
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1350
|
+
}
|
|
1351
|
+
options.fs.stat(lockfilePath, (err2, stat) => {
|
|
1352
|
+
if (err2) {
|
|
1353
|
+
if (err2.code === "ENOENT") {
|
|
1354
|
+
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1355
|
+
}
|
|
1356
|
+
return callback(err2);
|
|
1357
|
+
}
|
|
1358
|
+
if (!isLockStale(stat, options)) {
|
|
1359
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1360
|
+
}
|
|
1361
|
+
removeLock(file, options, (err3) => {
|
|
1362
|
+
if (err3) {
|
|
1363
|
+
return callback(err3);
|
|
1364
|
+
}
|
|
1365
|
+
acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1366
|
+
});
|
|
1367
|
+
});
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
function isLockStale(stat, options) {
|
|
1371
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
1372
|
+
}
|
|
1373
|
+
function removeLock(file, options, callback) {
|
|
1374
|
+
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
1375
|
+
if (err && err.code !== "ENOENT") {
|
|
1376
|
+
return callback(err);
|
|
1377
|
+
}
|
|
1378
|
+
callback();
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
function updateLock(file, options) {
|
|
1382
|
+
const lock2 = locks[file];
|
|
1383
|
+
if (lock2.updateTimeout) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
1387
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
1388
|
+
lock2.updateTimeout = null;
|
|
1389
|
+
options.fs.stat(lock2.lockfilePath, (err, stat) => {
|
|
1390
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
1391
|
+
if (err) {
|
|
1392
|
+
if (err.code === "ENOENT" || isOverThreshold) {
|
|
1393
|
+
return setLockAsCompromised(file, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1394
|
+
}
|
|
1395
|
+
lock2.updateDelay = 1e3;
|
|
1396
|
+
return updateLock(file, options);
|
|
1397
|
+
}
|
|
1398
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
|
|
1399
|
+
if (!isMtimeOurs) {
|
|
1400
|
+
return setLockAsCompromised(
|
|
1401
|
+
file,
|
|
1402
|
+
lock2,
|
|
1403
|
+
Object.assign(
|
|
1404
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
1405
|
+
{ code: "ECOMPROMISED" }
|
|
1406
|
+
)
|
|
1407
|
+
);
|
|
1408
|
+
}
|
|
1409
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
1410
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
|
|
1411
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
1412
|
+
if (lock2.released) {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
if (err2) {
|
|
1416
|
+
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
1417
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1418
|
+
}
|
|
1419
|
+
lock2.updateDelay = 1e3;
|
|
1420
|
+
return updateLock(file, options);
|
|
1421
|
+
}
|
|
1422
|
+
lock2.mtime = mtime;
|
|
1423
|
+
lock2.lastUpdate = Date.now();
|
|
1424
|
+
lock2.updateDelay = null;
|
|
1425
|
+
updateLock(file, options);
|
|
1426
|
+
});
|
|
1427
|
+
});
|
|
1428
|
+
}, lock2.updateDelay);
|
|
1429
|
+
if (lock2.updateTimeout.unref) {
|
|
1430
|
+
lock2.updateTimeout.unref();
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
function setLockAsCompromised(file, lock2, err) {
|
|
1434
|
+
lock2.released = true;
|
|
1435
|
+
if (lock2.updateTimeout) {
|
|
1436
|
+
clearTimeout(lock2.updateTimeout);
|
|
1437
|
+
}
|
|
1438
|
+
if (locks[file] === lock2) {
|
|
1439
|
+
delete locks[file];
|
|
1440
|
+
}
|
|
1441
|
+
lock2.options.onCompromised(err);
|
|
1442
|
+
}
|
|
1443
|
+
function lock(file, options, callback) {
|
|
1444
|
+
options = {
|
|
1445
|
+
stale: 1e4,
|
|
1446
|
+
update: null,
|
|
1447
|
+
realpath: true,
|
|
1448
|
+
retries: 0,
|
|
1449
|
+
fs,
|
|
1450
|
+
onCompromised: (err) => {
|
|
1451
|
+
throw err;
|
|
1452
|
+
},
|
|
1453
|
+
...options
|
|
1454
|
+
};
|
|
1455
|
+
options.retries = options.retries || 0;
|
|
1456
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1457
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1458
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1459
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1460
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1461
|
+
if (err) {
|
|
1462
|
+
return callback(err);
|
|
1463
|
+
}
|
|
1464
|
+
const operation = retry.operation(options.retries);
|
|
1465
|
+
operation.attempt(() => {
|
|
1466
|
+
acquireLock(file2, options, (err2, mtime, mtimePrecision2) => {
|
|
1467
|
+
if (operation.retry(err2)) {
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
if (err2) {
|
|
1471
|
+
return callback(operation.mainError());
|
|
1472
|
+
}
|
|
1473
|
+
const lock2 = locks[file2] = {
|
|
1474
|
+
lockfilePath: getLockFile(file2, options),
|
|
1475
|
+
mtime,
|
|
1476
|
+
mtimePrecision: mtimePrecision2,
|
|
1477
|
+
options,
|
|
1478
|
+
lastUpdate: Date.now()
|
|
1479
|
+
};
|
|
1480
|
+
updateLock(file2, options);
|
|
1481
|
+
callback(null, (releasedCallback) => {
|
|
1482
|
+
if (lock2.released) {
|
|
1483
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1484
|
+
}
|
|
1485
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
1486
|
+
});
|
|
1487
|
+
});
|
|
1488
|
+
});
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
function unlock(file, options, callback) {
|
|
1492
|
+
options = {
|
|
1493
|
+
fs,
|
|
1494
|
+
realpath: true,
|
|
1495
|
+
...options
|
|
1496
|
+
};
|
|
1497
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1498
|
+
if (err) {
|
|
1499
|
+
return callback(err);
|
|
1500
|
+
}
|
|
1501
|
+
const lock2 = locks[file2];
|
|
1502
|
+
if (!lock2) {
|
|
1503
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1504
|
+
}
|
|
1505
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
1506
|
+
lock2.released = true;
|
|
1507
|
+
delete locks[file2];
|
|
1508
|
+
removeLock(file2, options, callback);
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
function check(file, options, callback) {
|
|
1512
|
+
options = {
|
|
1513
|
+
stale: 1e4,
|
|
1514
|
+
realpath: true,
|
|
1515
|
+
fs,
|
|
1516
|
+
...options
|
|
1517
|
+
};
|
|
1518
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1519
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1520
|
+
if (err) {
|
|
1521
|
+
return callback(err);
|
|
1522
|
+
}
|
|
1523
|
+
options.fs.stat(getLockFile(file2, options), (err2, stat) => {
|
|
1524
|
+
if (err2) {
|
|
1525
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1526
|
+
}
|
|
1527
|
+
return callback(null, !isLockStale(stat, options));
|
|
1528
|
+
});
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
function getLocks() {
|
|
1532
|
+
return locks;
|
|
1533
|
+
}
|
|
1534
|
+
onExit(() => {
|
|
1535
|
+
for (const file in locks) {
|
|
1536
|
+
const options = locks[file].options;
|
|
1537
|
+
try {
|
|
1538
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
1539
|
+
} catch (e) {
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1543
|
+
module.exports.lock = lock;
|
|
1544
|
+
module.exports.unlock = unlock;
|
|
1545
|
+
module.exports.check = check;
|
|
1546
|
+
module.exports.getLocks = getLocks;
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
|
|
1550
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
1551
|
+
var require_adapter = __commonJS({
|
|
1552
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1553
|
+
"use strict";
|
|
1554
|
+
var fs = require_graceful_fs();
|
|
1555
|
+
function createSyncFs(fs2) {
|
|
1556
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1557
|
+
const newFs = { ...fs2 };
|
|
1558
|
+
methods.forEach((method) => {
|
|
1559
|
+
newFs[method] = (...args) => {
|
|
1560
|
+
const callback = args.pop();
|
|
1561
|
+
let ret;
|
|
1562
|
+
try {
|
|
1563
|
+
ret = fs2[`${method}Sync`](...args);
|
|
1564
|
+
} catch (err) {
|
|
1565
|
+
return callback(err);
|
|
1566
|
+
}
|
|
1567
|
+
callback(null, ret);
|
|
1568
|
+
};
|
|
1569
|
+
});
|
|
1570
|
+
return newFs;
|
|
1571
|
+
}
|
|
1572
|
+
function toPromise(method) {
|
|
1573
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
1574
|
+
args.push((err, result) => {
|
|
1575
|
+
if (err) {
|
|
1576
|
+
reject(err);
|
|
1577
|
+
} else {
|
|
1578
|
+
resolve(result);
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
method(...args);
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
function toSync(method) {
|
|
1585
|
+
return (...args) => {
|
|
1586
|
+
let err;
|
|
1587
|
+
let result;
|
|
1588
|
+
args.push((_err, _result) => {
|
|
1589
|
+
err = _err;
|
|
1590
|
+
result = _result;
|
|
1591
|
+
});
|
|
1592
|
+
method(...args);
|
|
1593
|
+
if (err) {
|
|
1594
|
+
throw err;
|
|
1595
|
+
}
|
|
1596
|
+
return result;
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
function toSyncOptions(options) {
|
|
1600
|
+
options = { ...options };
|
|
1601
|
+
options.fs = createSyncFs(options.fs || fs);
|
|
1602
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1603
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1604
|
+
}
|
|
1605
|
+
return options;
|
|
1606
|
+
}
|
|
1607
|
+
module.exports = {
|
|
1608
|
+
toPromise,
|
|
1609
|
+
toSync,
|
|
1610
|
+
toSyncOptions
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
});
|
|
1614
|
+
|
|
1615
|
+
// node_modules/proper-lockfile/index.js
|
|
1616
|
+
var require_proper_lockfile = __commonJS({
|
|
1617
|
+
"node_modules/proper-lockfile/index.js"(exports, module) {
|
|
1618
|
+
"use strict";
|
|
1619
|
+
var lockfile = require_lockfile();
|
|
1620
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1621
|
+
async function lock(file, options) {
|
|
1622
|
+
const release = await toPromise(lockfile.lock)(file, options);
|
|
1623
|
+
return toPromise(release);
|
|
1624
|
+
}
|
|
1625
|
+
function lockSync2(file, options) {
|
|
1626
|
+
const release = toSync(lockfile.lock)(file, toSyncOptions(options));
|
|
1627
|
+
return toSync(release);
|
|
1628
|
+
}
|
|
1629
|
+
function unlock(file, options) {
|
|
1630
|
+
return toPromise(lockfile.unlock)(file, options);
|
|
1631
|
+
}
|
|
1632
|
+
function unlockSync(file, options) {
|
|
1633
|
+
return toSync(lockfile.unlock)(file, toSyncOptions(options));
|
|
1634
|
+
}
|
|
1635
|
+
function check(file, options) {
|
|
1636
|
+
return toPromise(lockfile.check)(file, options);
|
|
1637
|
+
}
|
|
1638
|
+
function checkSync(file, options) {
|
|
1639
|
+
return toSync(lockfile.check)(file, toSyncOptions(options));
|
|
1640
|
+
}
|
|
1641
|
+
module.exports = lock;
|
|
1642
|
+
module.exports.lock = lock;
|
|
1643
|
+
module.exports.unlock = unlock;
|
|
1644
|
+
module.exports.lockSync = lockSync2;
|
|
1645
|
+
module.exports.unlockSync = unlockSync;
|
|
1646
|
+
module.exports.check = check;
|
|
1647
|
+
module.exports.checkSync = checkSync;
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
|
|
1651
|
+
// lib/shipper/span-shipper.ts
|
|
1652
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
1653
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
1654
|
+
import { dirname, join } from "node:path";
|
|
1655
|
+
|
|
1656
|
+
// lib/otel/otlp-post.ts
|
|
1657
|
+
import { createHash } from "node:crypto";
|
|
1658
|
+
var OTLP_PATH_PREFIX = "/v1/";
|
|
1659
|
+
function otlpPathFor(signal) {
|
|
1660
|
+
return `${OTLP_PATH_PREFIX}${signal}`;
|
|
1661
|
+
}
|
|
1662
|
+
function otlpPostTimeoutMs() {
|
|
1663
|
+
const raw = Number(process.env.OTLP_POST_TIMEOUT_MS);
|
|
1664
|
+
return Number.isFinite(raw) && raw > 0 ? raw : DURATION_MS.FIVE_SECONDS;
|
|
1665
|
+
}
|
|
1666
|
+
function otlpMaxConcurrentPosts() {
|
|
1667
|
+
const raw = Number(process.env.OTLP_MAX_CONCURRENT_POSTS);
|
|
1668
|
+
return Number.isInteger(raw) && raw > 0 ? raw : THRESHOLDS.OTLP_MAX_CONCURRENT_POSTS;
|
|
1669
|
+
}
|
|
1670
|
+
var OTLP_PROTOBUF_CONTENT_TYPE = "application/x-protobuf";
|
|
1671
|
+
function otlpPostHeaders(authHeaders = {}) {
|
|
1672
|
+
return { ...authHeaders, [CONTENT_TYPE_HEADER]: OTLP_PROTOBUF_CONTENT_TYPE };
|
|
1673
|
+
}
|
|
1674
|
+
var IDEMPOTENCY_KEY_HEADER = "X-Idempotency-Key";
|
|
1675
|
+
function idempotencyKeyFor(body) {
|
|
1676
|
+
return createHash("sha256").update(body).digest("hex");
|
|
1677
|
+
}
|
|
1678
|
+
var SOCKET_CLOSED_CODES = /* @__PURE__ */ new Set(["UND_ERR_SOCKET", "EPIPE", "ECONNRESET"]);
|
|
1679
|
+
function isSocketClosed(error) {
|
|
1680
|
+
if (!(error instanceof Error)) return false;
|
|
1681
|
+
for (const link of errorCauseChain(error)) {
|
|
1682
|
+
const code = errorCode(link);
|
|
1683
|
+
if (code !== void 0 && SOCKET_CLOSED_CODES.has(code)) return true;
|
|
1684
|
+
if (link.message.includes("other side closed")) return true;
|
|
1685
|
+
}
|
|
1686
|
+
return false;
|
|
1687
|
+
}
|
|
1688
|
+
async function postOtlpBodies(request) {
|
|
1689
|
+
const { url, headers, bodies } = request;
|
|
1690
|
+
if (bodies.length === 0) return { delivered: false, reason: "empty-batch", deliveredPrefix: 0 };
|
|
1691
|
+
const postHeaders = otlpPostHeaders(headers);
|
|
1692
|
+
let retriedSocketErrors = 0;
|
|
1693
|
+
const postOne = async (body) => {
|
|
1694
|
+
const attempt = async () => {
|
|
1695
|
+
try {
|
|
1696
|
+
const res = await fetchWithTimeout(
|
|
1697
|
+
url,
|
|
1698
|
+
{
|
|
1699
|
+
method: "POST",
|
|
1700
|
+
headers: { ...postHeaders, [IDEMPOTENCY_KEY_HEADER]: idempotencyKeyFor(body) },
|
|
1701
|
+
body
|
|
1702
|
+
},
|
|
1703
|
+
otlpPostTimeoutMs(),
|
|
1704
|
+
// HTTP/1.1: one destroyed HTTP/2 session failed every later post in the run.
|
|
1705
|
+
http1Fetch
|
|
1706
|
+
);
|
|
1707
|
+
await res.body?.cancel();
|
|
1708
|
+
if (!res.ok) {
|
|
1709
|
+
return { delivered: false, reason: "rejected", statusCode: res.status, deliveredPrefix: 0 };
|
|
1710
|
+
}
|
|
1711
|
+
} catch (error) {
|
|
1712
|
+
return { delivered: false, reason: "threw", error, deliveredPrefix: 0 };
|
|
1713
|
+
}
|
|
1714
|
+
return { delivered: true, deliveredPrefix: 1 };
|
|
1715
|
+
};
|
|
1716
|
+
const first = await attempt();
|
|
1717
|
+
if (!first.delivered && first.reason === "threw" && isSocketClosed(first.error)) {
|
|
1718
|
+
const retry = await attempt();
|
|
1719
|
+
if (retry.delivered) {
|
|
1720
|
+
retriedSocketErrors++;
|
|
1721
|
+
return retry;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
return first;
|
|
1725
|
+
};
|
|
1726
|
+
const maxConcurrent = request.maxConcurrent ?? otlpMaxConcurrentPosts();
|
|
1727
|
+
let prefix = 0;
|
|
1728
|
+
for (let i = 0; i < bodies.length; i += maxConcurrent) {
|
|
1729
|
+
const wave = bodies.slice(i, i + maxConcurrent);
|
|
1730
|
+
const outcomes = await Promise.all(wave.map(postOne));
|
|
1731
|
+
const failedAt = outcomes.findIndex((o) => !o.delivered);
|
|
1732
|
+
if (failedAt !== -1) {
|
|
1733
|
+
const failed = outcomes[failedAt];
|
|
1734
|
+
return {
|
|
1735
|
+
...failed,
|
|
1736
|
+
deliveredPrefix: prefix + failedAt,
|
|
1737
|
+
...retriedSocketErrors > 0 ? { retriedSocketErrors } : {}
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
prefix += wave.length;
|
|
1741
|
+
}
|
|
1742
|
+
return {
|
|
1743
|
+
delivered: true,
|
|
1744
|
+
deliveredPrefix: prefix,
|
|
1745
|
+
...retriedSocketErrors > 0 ? { retriedSocketErrors } : {}
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
// lib/otel/otlp-serialize.ts
|
|
1750
|
+
init_esm();
|
|
1751
|
+
|
|
1752
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/common/protobuf/protobuf-writer.js
|
|
1753
|
+
init_esm();
|
|
1754
|
+
|
|
1755
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/common/protobuf/utils.js
|
|
1756
|
+
function estimateVarintSize(v) {
|
|
1757
|
+
if (v < 0)
|
|
1758
|
+
return 10;
|
|
1759
|
+
if (v < 128)
|
|
1760
|
+
return 1;
|
|
1761
|
+
if (v < 16384)
|
|
1762
|
+
return 2;
|
|
1763
|
+
if (v < 2097152)
|
|
1764
|
+
return 3;
|
|
1765
|
+
if (v < 268435456)
|
|
1766
|
+
return 4;
|
|
1767
|
+
if (v < 34359738368)
|
|
1768
|
+
return 5;
|
|
1769
|
+
if (v < 4398046511104)
|
|
1770
|
+
return 6;
|
|
1771
|
+
if (v < 562949953421312)
|
|
1772
|
+
return 7;
|
|
1773
|
+
if (v < 72057594037927940)
|
|
1774
|
+
return 8;
|
|
1775
|
+
return 9;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/common/protobuf/protobuf-writer.js
|
|
1779
|
+
var GROWING_BUFFER_DEBUG_MESSAGE = "ProtobufWriter: estimated size was too small, growing buffer.";
|
|
1780
|
+
var RESERVED_LENGTH_BYTES = 1;
|
|
1781
|
+
var ProtobufWriter = class {
|
|
1782
|
+
_buffer;
|
|
1783
|
+
// Avoid using TextEncoder type. While the global is there on all supported runtimes, types may differ.
|
|
1784
|
+
_textEncoder;
|
|
1785
|
+
_dataView;
|
|
1786
|
+
pos = 0;
|
|
1787
|
+
constructor(estimatedSize = 65536) {
|
|
1788
|
+
this._buffer = new Uint8Array(estimatedSize);
|
|
1789
|
+
this._textEncoder = new TextEncoder();
|
|
1790
|
+
this._dataView = new DataView(this._buffer.buffer, this._buffer.byteOffset);
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Ensure buffer has capacity for at least size more bytes
|
|
1794
|
+
*/
|
|
1795
|
+
_ensureCapacity(size) {
|
|
1796
|
+
const needed = this.pos + size;
|
|
1797
|
+
if (needed <= this._buffer.length) {
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
diag.debug(GROWING_BUFFER_DEBUG_MESSAGE);
|
|
1801
|
+
let newSize = this._buffer.length * 2;
|
|
1802
|
+
while (newSize < needed) {
|
|
1803
|
+
newSize *= 2;
|
|
1804
|
+
}
|
|
1805
|
+
const newBuffer = new Uint8Array(newSize);
|
|
1806
|
+
newBuffer.set(this._buffer);
|
|
1807
|
+
this._buffer = newBuffer;
|
|
1808
|
+
this._dataView = new DataView(this._buffer.buffer, this._buffer.byteOffset);
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Get the written bytes as a Uint8Array
|
|
1812
|
+
*/
|
|
1813
|
+
finish() {
|
|
1814
|
+
return this._buffer.subarray(0, this.pos);
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Insert placeholder for length. Update later with {@link finishLengthDelimited}
|
|
1818
|
+
* Returns the position where to write the length.
|
|
1819
|
+
*/
|
|
1820
|
+
startLengthDelimited() {
|
|
1821
|
+
const lengthPos = this.pos;
|
|
1822
|
+
this._ensureCapacity(RESERVED_LENGTH_BYTES);
|
|
1823
|
+
this.pos += RESERVED_LENGTH_BYTES;
|
|
1824
|
+
return lengthPos;
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Write length varint at placeholder position and shift content forward if needed.
|
|
1828
|
+
* Most messages are small (< 128 bytes), so we reserve 1 byte and only shift
|
|
1829
|
+
* when the length needs more bytes.
|
|
1830
|
+
*/
|
|
1831
|
+
finishLengthDelimited(pos, length) {
|
|
1832
|
+
const v = length >>> 0;
|
|
1833
|
+
const varintSize = estimateVarintSize(v);
|
|
1834
|
+
if (varintSize > RESERVED_LENGTH_BYTES) {
|
|
1835
|
+
const additionalBytes = varintSize - RESERVED_LENGTH_BYTES;
|
|
1836
|
+
this._ensureCapacity(additionalBytes);
|
|
1837
|
+
this._buffer.copyWithin(pos + varintSize, pos + RESERVED_LENGTH_BYTES, this.pos);
|
|
1838
|
+
this.pos += additionalBytes;
|
|
1839
|
+
}
|
|
1840
|
+
let writePos = pos;
|
|
1841
|
+
if (v < 128) {
|
|
1842
|
+
this._buffer[writePos] = v;
|
|
1843
|
+
} else if (v < 16384) {
|
|
1844
|
+
this._buffer[writePos++] = v & 127 | 128;
|
|
1845
|
+
this._buffer[writePos] = v >>> 7;
|
|
1846
|
+
} else if (v < 2097152) {
|
|
1847
|
+
this._buffer[writePos++] = v & 127 | 128;
|
|
1848
|
+
this._buffer[writePos++] = v >>> 7 & 127 | 128;
|
|
1849
|
+
this._buffer[writePos] = v >>> 14;
|
|
1850
|
+
} else if (v < 268435456) {
|
|
1851
|
+
this._buffer[writePos++] = v & 127 | 128;
|
|
1852
|
+
this._buffer[writePos++] = v >>> 7 & 127 | 128;
|
|
1853
|
+
this._buffer[writePos++] = v >>> 14 & 127 | 128;
|
|
1854
|
+
this._buffer[writePos] = v >>> 21;
|
|
1855
|
+
} else {
|
|
1856
|
+
this._buffer[writePos++] = v & 127 | 128;
|
|
1857
|
+
this._buffer[writePos++] = v >>> 7 & 127 | 128;
|
|
1858
|
+
this._buffer[writePos++] = v >>> 14 & 127 | 128;
|
|
1859
|
+
this._buffer[writePos++] = v >>> 21 & 127 | 128;
|
|
1860
|
+
this._buffer[writePos] = v >>> 28;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Write a sint32 value using zigzag encoding
|
|
1865
|
+
*/
|
|
1866
|
+
writeSint32(value) {
|
|
1867
|
+
this.writeVarint((value << 1 ^ value >> 31) >>> 0);
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Write a signed 64-bit fixed integer (sfixed64) from a JS number.
|
|
1871
|
+
* Handles negative values via two's complement.
|
|
1872
|
+
*/
|
|
1873
|
+
writeSfixed64(value) {
|
|
1874
|
+
let low;
|
|
1875
|
+
let high;
|
|
1876
|
+
if (value >= 0) {
|
|
1877
|
+
low = value >>> 0;
|
|
1878
|
+
high = value / 4294967296 >>> 0;
|
|
1879
|
+
} else {
|
|
1880
|
+
const abs = Math.abs(value);
|
|
1881
|
+
low = abs >>> 0;
|
|
1882
|
+
high = abs / 4294967296 >>> 0;
|
|
1883
|
+
low = ~low >>> 0;
|
|
1884
|
+
high = ~high >>> 0;
|
|
1885
|
+
low = low + 1 >>> 0;
|
|
1886
|
+
if (low === 0) {
|
|
1887
|
+
high = high + 1 >>> 0;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
this.writeFixed64(low, high);
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Write a varint (variable-length integer)
|
|
1894
|
+
*/
|
|
1895
|
+
writeVarint(value) {
|
|
1896
|
+
this._ensureCapacity(estimateVarintSize(value));
|
|
1897
|
+
if (value >= 0 && value <= 4294967295) {
|
|
1898
|
+
let v = value >>> 0;
|
|
1899
|
+
while (v > 127) {
|
|
1900
|
+
this._buffer[this.pos++] = v & 127 | 128;
|
|
1901
|
+
v >>>= 7;
|
|
1902
|
+
}
|
|
1903
|
+
this._buffer[this.pos++] = v;
|
|
1904
|
+
} else {
|
|
1905
|
+
let low;
|
|
1906
|
+
let high;
|
|
1907
|
+
if (value >= 0) {
|
|
1908
|
+
low = value >>> 0;
|
|
1909
|
+
high = value / 4294967296 >>> 0;
|
|
1910
|
+
} else {
|
|
1911
|
+
const abs = Math.abs(value);
|
|
1912
|
+
low = abs >>> 0;
|
|
1913
|
+
high = abs / 4294967296 >>> 0;
|
|
1914
|
+
low = ~low >>> 0;
|
|
1915
|
+
high = ~high >>> 0;
|
|
1916
|
+
low = low + 1 >>> 0;
|
|
1917
|
+
if (low === 0) {
|
|
1918
|
+
high = high + 1 >>> 0;
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
while (high > 0 || low > 127) {
|
|
1922
|
+
this._buffer[this.pos++] = low & 127 | 128;
|
|
1923
|
+
low = (low >>> 7 | high << 25) >>> 0;
|
|
1924
|
+
high >>>= 7;
|
|
1925
|
+
}
|
|
1926
|
+
this._buffer[this.pos++] = low & 127;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Write a 32-bit fixed integer (little-endian)
|
|
1931
|
+
*/
|
|
1932
|
+
writeFixed32(value) {
|
|
1933
|
+
this._ensureCapacity(4);
|
|
1934
|
+
const v = value >>> 0;
|
|
1935
|
+
this._buffer[this.pos++] = v & 255;
|
|
1936
|
+
this._buffer[this.pos++] = v >>> 8 & 255;
|
|
1937
|
+
this._buffer[this.pos++] = v >>> 16 & 255;
|
|
1938
|
+
this._buffer[this.pos++] = v >>> 24 & 255;
|
|
1939
|
+
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Write a 64-bit fixed integer (little-endian)
|
|
1942
|
+
* @param low - Low 32 bits
|
|
1943
|
+
* @param high - High 32 bits
|
|
1944
|
+
*/
|
|
1945
|
+
writeFixed64(low, high) {
|
|
1946
|
+
this._ensureCapacity(8);
|
|
1947
|
+
const l = low >>> 0;
|
|
1948
|
+
const h = high >>> 0;
|
|
1949
|
+
this._buffer[this.pos++] = l & 255;
|
|
1950
|
+
this._buffer[this.pos++] = l >>> 8 & 255;
|
|
1951
|
+
this._buffer[this.pos++] = l >>> 16 & 255;
|
|
1952
|
+
this._buffer[this.pos++] = l >>> 24 & 255;
|
|
1953
|
+
this._buffer[this.pos++] = h & 255;
|
|
1954
|
+
this._buffer[this.pos++] = h >>> 8 & 255;
|
|
1955
|
+
this._buffer[this.pos++] = h >>> 16 & 255;
|
|
1956
|
+
this._buffer[this.pos++] = h >>> 24 & 255;
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Write length-delimited data (varint length + bytes)
|
|
1960
|
+
*/
|
|
1961
|
+
writeBytes(bytes) {
|
|
1962
|
+
this.writeVarint(bytes.length);
|
|
1963
|
+
this._ensureCapacity(bytes.length);
|
|
1964
|
+
this._buffer.set(bytes, this.pos);
|
|
1965
|
+
this.pos += bytes.length;
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Write a field key (field number + wire type)
|
|
1969
|
+
*/
|
|
1970
|
+
writeTag(fieldNumber, wireType) {
|
|
1971
|
+
this.writeVarint(fieldNumber << 3 | wireType);
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* Write a double (64-bit IEEE 754)
|
|
1975
|
+
*/
|
|
1976
|
+
writeDouble(value) {
|
|
1977
|
+
this._ensureCapacity(8);
|
|
1978
|
+
this._dataView.setFloat64(this.pos, value, true);
|
|
1979
|
+
this.pos += 8;
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Write a string as UTF-8 bytes (length-delimited)
|
|
1983
|
+
*/
|
|
1984
|
+
writeString(str) {
|
|
1985
|
+
let isAscii = true;
|
|
1986
|
+
const len = str.length;
|
|
1987
|
+
for (let i = 0; i < len; i++) {
|
|
1988
|
+
if (str.charCodeAt(i) > 127) {
|
|
1989
|
+
isAscii = false;
|
|
1990
|
+
break;
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
if (isAscii) {
|
|
1994
|
+
this.writeVarint(len);
|
|
1995
|
+
this._ensureCapacity(len);
|
|
1996
|
+
for (let i = 0; i < len; i++) {
|
|
1997
|
+
this._buffer[this.pos++] = str.charCodeAt(i);
|
|
1998
|
+
}
|
|
1999
|
+
} else {
|
|
2000
|
+
const bytes = this._textEncoder.encode(str);
|
|
2001
|
+
this.writeBytes(bytes);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
|
|
2006
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/common/hex-to-binary.js
|
|
2007
|
+
function intValue(charCode) {
|
|
2008
|
+
if (charCode >= 48 && charCode <= 57) {
|
|
2009
|
+
return charCode - 48;
|
|
2010
|
+
}
|
|
2011
|
+
if (charCode >= 97 && charCode <= 102) {
|
|
2012
|
+
return charCode - 87;
|
|
2013
|
+
}
|
|
2014
|
+
return charCode - 55;
|
|
2015
|
+
}
|
|
2016
|
+
function hexToBinary(hexStr) {
|
|
2017
|
+
const buf = new Uint8Array(hexStr.length / 2);
|
|
2018
|
+
let offset = 0;
|
|
2019
|
+
for (let i = 0; i < hexStr.length; i += 2) {
|
|
2020
|
+
const hi = intValue(hexStr.charCodeAt(i));
|
|
2021
|
+
const lo = intValue(hexStr.charCodeAt(i + 1));
|
|
2022
|
+
buf[offset++] = hi << 4 | lo;
|
|
2023
|
+
}
|
|
2024
|
+
return buf;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/common/protobuf/common-serializer.js
|
|
2028
|
+
function writeHrTimeAsFixed64(serializer, hrTime) {
|
|
2029
|
+
const seconds = hrTime[0];
|
|
2030
|
+
const nanos = hrTime[1];
|
|
2031
|
+
const nanosPerSecond = 1e9;
|
|
2032
|
+
const secondsLower16Bits = seconds & 65535;
|
|
2033
|
+
const secondsUpperBits = seconds / 65536 >>> 0;
|
|
2034
|
+
const nanosFromLower16Bits = secondsLower16Bits * nanosPerSecond;
|
|
2035
|
+
const nanosFromUpperBits = secondsUpperBits * nanosPerSecond;
|
|
2036
|
+
const lower16ContributionLow32 = nanosFromLower16Bits >>> 0;
|
|
2037
|
+
const lower16ContributionHigh32 = Math.floor(nanosFromLower16Bits / 4294967296);
|
|
2038
|
+
const upperBitsContributionLow32 = (nanosFromUpperBits & 65535) * 65536 >>> 0;
|
|
2039
|
+
const upperBitsContributionHigh32 = nanosFromUpperBits / 65536 >>> 0;
|
|
2040
|
+
const low32WithCarry = lower16ContributionLow32 + upperBitsContributionLow32 + nanos;
|
|
2041
|
+
const totalLow = low32WithCarry >>> 0;
|
|
2042
|
+
const carry = Math.floor(low32WithCarry / 4294967296);
|
|
2043
|
+
const totalHigh = lower16ContributionHigh32 + upperBitsContributionHigh32 + carry >>> 0;
|
|
2044
|
+
serializer.writeFixed64(totalLow, totalHigh);
|
|
2045
|
+
}
|
|
2046
|
+
function writeAttributes(writer, attributes, fieldNumber) {
|
|
2047
|
+
for (const key in attributes) {
|
|
2048
|
+
if (!Object.prototype.hasOwnProperty.call(attributes, key)) {
|
|
2049
|
+
continue;
|
|
2050
|
+
}
|
|
2051
|
+
const value = attributes[key];
|
|
2052
|
+
writer.writeTag(fieldNumber, 2);
|
|
2053
|
+
const kvStart = writer.startLengthDelimited();
|
|
2054
|
+
const startPos = writer.pos;
|
|
2055
|
+
writeKeyValue(writer, key, value);
|
|
2056
|
+
writer.finishLengthDelimited(kvStart, writer.pos - startPos);
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
function writeKeyValue(writer, key, value) {
|
|
2060
|
+
writer.writeTag(1, 2);
|
|
2061
|
+
writer.writeString(key);
|
|
2062
|
+
writer.writeTag(2, 2);
|
|
2063
|
+
const valueStart = writer.startLengthDelimited();
|
|
2064
|
+
const startPos = writer.pos;
|
|
2065
|
+
writeAnyValue(writer, value);
|
|
2066
|
+
writer.finishLengthDelimited(valueStart, writer.pos - startPos);
|
|
2067
|
+
}
|
|
2068
|
+
var MIN_64_BIT_INT = -(2 ** 63);
|
|
2069
|
+
var MAX_64_BIT_INT = 2 ** 63;
|
|
2070
|
+
function writeAnyValue(writer, value) {
|
|
2071
|
+
const t = typeof value;
|
|
2072
|
+
if (t === "string") {
|
|
2073
|
+
writer.writeTag(1, 2);
|
|
2074
|
+
writer.writeString(value);
|
|
2075
|
+
} else if (t === "boolean") {
|
|
2076
|
+
writer.writeTag(2, 0);
|
|
2077
|
+
writer.writeVarint(value ? 1 : 0);
|
|
2078
|
+
} else if (t === "number") {
|
|
2079
|
+
const numValue = value;
|
|
2080
|
+
if (Number.isInteger(numValue) && numValue >= MIN_64_BIT_INT && numValue < MAX_64_BIT_INT) {
|
|
2081
|
+
writer.writeTag(3, 0);
|
|
2082
|
+
writer.writeVarint(numValue);
|
|
2083
|
+
} else {
|
|
2084
|
+
writer.writeTag(4, 1);
|
|
2085
|
+
writer.writeDouble(numValue);
|
|
2086
|
+
}
|
|
2087
|
+
} else if (value instanceof Uint8Array) {
|
|
2088
|
+
writer.writeTag(7, 2);
|
|
2089
|
+
writer.writeBytes(value);
|
|
2090
|
+
} else if (Array.isArray(value)) {
|
|
2091
|
+
writer.writeTag(5, 2);
|
|
2092
|
+
const arrayStart = writer.startLengthDelimited();
|
|
2093
|
+
const arrayStartPos = writer.pos;
|
|
2094
|
+
for (const item of value) {
|
|
2095
|
+
writer.writeTag(1, 2);
|
|
2096
|
+
const itemStart = writer.startLengthDelimited();
|
|
2097
|
+
const itemStartPos = writer.pos;
|
|
2098
|
+
writeAnyValue(writer, item);
|
|
2099
|
+
writer.finishLengthDelimited(itemStart, writer.pos - itemStartPos);
|
|
2100
|
+
}
|
|
2101
|
+
writer.finishLengthDelimited(arrayStart, writer.pos - arrayStartPos);
|
|
2102
|
+
} else if (t === "object" && value != null) {
|
|
2103
|
+
writer.writeTag(6, 2);
|
|
2104
|
+
const kvlistStart = writer.startLengthDelimited();
|
|
2105
|
+
const kvlistStartPos = writer.pos;
|
|
2106
|
+
const obj = value;
|
|
2107
|
+
for (const k in obj) {
|
|
2108
|
+
if (!Object.prototype.hasOwnProperty.call(obj, k)) {
|
|
2109
|
+
continue;
|
|
2110
|
+
}
|
|
2111
|
+
const v = obj[k];
|
|
2112
|
+
writer.writeTag(1, 2);
|
|
2113
|
+
const kvStart = writer.startLengthDelimited();
|
|
2114
|
+
const kvStartPos = writer.pos;
|
|
2115
|
+
writer.writeTag(1, 2);
|
|
2116
|
+
writer.writeString(k);
|
|
2117
|
+
writer.writeTag(2, 2);
|
|
2118
|
+
const valueStart = writer.startLengthDelimited();
|
|
2119
|
+
const valueStartPos = writer.pos;
|
|
2120
|
+
writeAnyValue(writer, v);
|
|
2121
|
+
writer.finishLengthDelimited(valueStart, writer.pos - valueStartPos);
|
|
2122
|
+
writer.finishLengthDelimited(kvStart, writer.pos - kvStartPos);
|
|
2123
|
+
}
|
|
2124
|
+
writer.finishLengthDelimited(kvlistStart, writer.pos - kvlistStartPos);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
function writeInstrumentationScope(writer, scope, fieldNumber) {
|
|
2128
|
+
writer.writeTag(fieldNumber, 2);
|
|
2129
|
+
const start = writer.startLengthDelimited();
|
|
2130
|
+
const startPos = writer.pos;
|
|
2131
|
+
writer.writeTag(1, 2);
|
|
2132
|
+
writer.writeString(scope.name);
|
|
2133
|
+
if (scope.version) {
|
|
2134
|
+
writer.writeTag(2, 2);
|
|
2135
|
+
writer.writeString(scope.version);
|
|
2136
|
+
}
|
|
2137
|
+
if (scope.attributes) {
|
|
2138
|
+
writeAttributes(writer, scope.attributes, 3);
|
|
2139
|
+
}
|
|
2140
|
+
if (scope.droppedAttributesCount) {
|
|
2141
|
+
writer.writeTag(4, 0);
|
|
2142
|
+
writer.writeVarint(scope.droppedAttributesCount);
|
|
2143
|
+
}
|
|
2144
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2145
|
+
}
|
|
2146
|
+
function writeResource(writer, resource, fieldNumber) {
|
|
2147
|
+
writer.writeTag(fieldNumber, 2);
|
|
2148
|
+
const resourceStart = writer.startLengthDelimited();
|
|
2149
|
+
const resourceStartPos = writer.pos;
|
|
2150
|
+
if (resource.attributes) {
|
|
2151
|
+
writeAttributes(writer, resource.attributes, 1);
|
|
2152
|
+
}
|
|
2153
|
+
writer.writeTag(2, 0);
|
|
2154
|
+
writer.writeVarint(0);
|
|
2155
|
+
writer.finishLengthDelimited(resourceStart, writer.pos - resourceStartPos);
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/common/protobuf/protobuf-size-estimator.js
|
|
2159
|
+
function utf8ByteLength(str) {
|
|
2160
|
+
const len = str.length;
|
|
2161
|
+
let byteLen = 0;
|
|
2162
|
+
for (let i = 0; i < len; i++) {
|
|
2163
|
+
const code = str.charCodeAt(i);
|
|
2164
|
+
if (code < 128) {
|
|
2165
|
+
byteLen += 1;
|
|
2166
|
+
} else if (code < 2048) {
|
|
2167
|
+
byteLen += 2;
|
|
2168
|
+
} else if (code < 55296 || code >= 57344) {
|
|
2169
|
+
byteLen += 3;
|
|
2170
|
+
} else {
|
|
2171
|
+
i++;
|
|
2172
|
+
byteLen += 4;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
return byteLen;
|
|
2176
|
+
}
|
|
2177
|
+
var ProtobufSizeEstimator = class {
|
|
2178
|
+
pos = 0;
|
|
2179
|
+
startLengthDelimited() {
|
|
2180
|
+
return this.pos;
|
|
2181
|
+
}
|
|
2182
|
+
finishLengthDelimited(_, length) {
|
|
2183
|
+
this.pos += estimateVarintSize(length);
|
|
2184
|
+
}
|
|
2185
|
+
writeVarint(value) {
|
|
2186
|
+
this.pos += estimateVarintSize(value);
|
|
2187
|
+
}
|
|
2188
|
+
writeSint32(value) {
|
|
2189
|
+
this.pos += estimateVarintSize((value << 1 ^ value >> 31) >>> 0);
|
|
2190
|
+
}
|
|
2191
|
+
writeSfixed64(_value) {
|
|
2192
|
+
this.pos += 8;
|
|
2193
|
+
}
|
|
2194
|
+
writeFixed32(_value) {
|
|
2195
|
+
this.pos += 4;
|
|
2196
|
+
}
|
|
2197
|
+
writeFixed64(_low, _high) {
|
|
2198
|
+
this.pos += 8;
|
|
2199
|
+
}
|
|
2200
|
+
writeBytes(bytes) {
|
|
2201
|
+
this.pos += estimateVarintSize(bytes.length);
|
|
2202
|
+
this.pos += bytes.length;
|
|
2203
|
+
}
|
|
2204
|
+
writeTag(fieldNumber, wireType) {
|
|
2205
|
+
this.writeVarint(fieldNumber << 3 | wireType);
|
|
2206
|
+
}
|
|
2207
|
+
writeDouble(_value) {
|
|
2208
|
+
this.pos += 8;
|
|
2209
|
+
}
|
|
2210
|
+
writeString(str) {
|
|
2211
|
+
const byteLen = utf8ByteLength(str);
|
|
2212
|
+
this.pos += estimateVarintSize(byteLen);
|
|
2213
|
+
this.pos += byteLen;
|
|
2214
|
+
}
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/logs/protobuf/logs-serializer.js
|
|
2218
|
+
function serializeLogRecord(writer, logRecord) {
|
|
2219
|
+
const logStart = writer.startLengthDelimited();
|
|
2220
|
+
const logStartPos = writer.pos;
|
|
2221
|
+
writer.writeTag(1, 1);
|
|
2222
|
+
writeHrTimeAsFixed64(writer, logRecord.hrTime);
|
|
2223
|
+
if (logRecord.severityNumber !== void 0 && logRecord.severityNumber !== SeverityNumber.UNSPECIFIED) {
|
|
2224
|
+
writer.writeTag(2, 0);
|
|
2225
|
+
writer.writeVarint(logRecord.severityNumber);
|
|
2226
|
+
}
|
|
2227
|
+
if (logRecord.severityText) {
|
|
2228
|
+
writer.writeTag(3, 2);
|
|
2229
|
+
writer.writeString(logRecord.severityText);
|
|
2230
|
+
}
|
|
2231
|
+
if (logRecord.body !== void 0) {
|
|
2232
|
+
writer.writeTag(5, 2);
|
|
2233
|
+
const bodyStart = writer.startLengthDelimited();
|
|
2234
|
+
const bodyStartPos = writer.pos;
|
|
2235
|
+
writeAnyValue(writer, logRecord.body);
|
|
2236
|
+
writer.finishLengthDelimited(bodyStart, writer.pos - bodyStartPos);
|
|
2237
|
+
}
|
|
2238
|
+
if (logRecord.attributes) {
|
|
2239
|
+
writeAttributes(writer, logRecord.attributes, 6);
|
|
2240
|
+
}
|
|
2241
|
+
writer.writeTag(7, 0);
|
|
2242
|
+
writer.writeVarint(logRecord.droppedAttributesCount);
|
|
2243
|
+
if (logRecord.spanContext?.traceFlags) {
|
|
2244
|
+
writer.writeTag(8, 5);
|
|
2245
|
+
writer.writeFixed32(logRecord.spanContext.traceFlags);
|
|
2246
|
+
}
|
|
2247
|
+
if (logRecord.spanContext?.traceId) {
|
|
2248
|
+
writer.writeTag(9, 2);
|
|
2249
|
+
writer.writeBytes(hexToBinary(logRecord.spanContext.traceId));
|
|
2250
|
+
}
|
|
2251
|
+
if (logRecord.spanContext?.spanId) {
|
|
2252
|
+
writer.writeTag(10, 2);
|
|
2253
|
+
writer.writeBytes(hexToBinary(logRecord.spanContext.spanId));
|
|
2254
|
+
}
|
|
2255
|
+
writer.writeTag(11, 1);
|
|
2256
|
+
writeHrTimeAsFixed64(writer, logRecord.hrTimeObserved);
|
|
2257
|
+
if (logRecord.eventName) {
|
|
2258
|
+
writer.writeTag(12, 2);
|
|
2259
|
+
writer.writeString(logRecord.eventName);
|
|
2260
|
+
}
|
|
2261
|
+
writer.finishLengthDelimited(logStart, writer.pos - logStartPos);
|
|
2262
|
+
}
|
|
2263
|
+
function serializeScopeLogs(writer, scope, logRecords) {
|
|
2264
|
+
const scopeLogsStart = writer.startLengthDelimited();
|
|
2265
|
+
const scopeLogsStartPos = writer.pos;
|
|
2266
|
+
writeInstrumentationScope(writer, scope, 1);
|
|
2267
|
+
for (const logRecord of logRecords) {
|
|
2268
|
+
writer.writeTag(2, 2);
|
|
2269
|
+
serializeLogRecord(writer, logRecord);
|
|
2270
|
+
}
|
|
2271
|
+
if (scope.schemaUrl) {
|
|
2272
|
+
writer.writeTag(3, 2);
|
|
2273
|
+
writer.writeString(scope.schemaUrl);
|
|
2274
|
+
}
|
|
2275
|
+
writer.finishLengthDelimited(scopeLogsStart, writer.pos - scopeLogsStartPos);
|
|
2276
|
+
}
|
|
2277
|
+
function serializeResourceLogs(writer, resource, scopeMap) {
|
|
2278
|
+
const resourceLogsStart = writer.startLengthDelimited();
|
|
2279
|
+
const resourceLogsStartPos = writer.pos;
|
|
2280
|
+
writeResource(writer, resource, 1);
|
|
2281
|
+
for (const scopeLogs of scopeMap.values()) {
|
|
2282
|
+
writer.writeTag(2, 2);
|
|
2283
|
+
const scope = scopeLogs[0].instrumentationScope;
|
|
2284
|
+
serializeScopeLogs(writer, scope, scopeLogs);
|
|
2285
|
+
}
|
|
2286
|
+
if (resource.schemaUrl) {
|
|
2287
|
+
writer.writeTag(3, 2);
|
|
2288
|
+
writer.writeString(resource.schemaUrl);
|
|
2289
|
+
}
|
|
2290
|
+
writer.finishLengthDelimited(resourceLogsStart, writer.pos - resourceLogsStartPos);
|
|
2291
|
+
}
|
|
2292
|
+
function createResourceMap(logRecords) {
|
|
2293
|
+
const resourceMap = /* @__PURE__ */ new Map();
|
|
2294
|
+
for (const record of logRecords) {
|
|
2295
|
+
const resource = record.resource;
|
|
2296
|
+
const scope = record.instrumentationScope;
|
|
2297
|
+
let ismMap = resourceMap.get(resource);
|
|
2298
|
+
if (!ismMap) {
|
|
2299
|
+
ismMap = /* @__PURE__ */ new Map();
|
|
2300
|
+
resourceMap.set(resource, ismMap);
|
|
2301
|
+
}
|
|
2302
|
+
let records = ismMap.get(scope);
|
|
2303
|
+
if (!records) {
|
|
2304
|
+
records = [];
|
|
2305
|
+
ismMap.set(scope, records);
|
|
2306
|
+
}
|
|
2307
|
+
records.push(record);
|
|
2308
|
+
}
|
|
2309
|
+
return resourceMap;
|
|
2310
|
+
}
|
|
2311
|
+
function serializeLogsExportRequest(logRecords) {
|
|
2312
|
+
const resourceMap = createResourceMap(logRecords);
|
|
2313
|
+
const estimator = new ProtobufSizeEstimator();
|
|
2314
|
+
for (const [resource, scopeMap] of resourceMap) {
|
|
2315
|
+
estimator.writeTag(1, 2);
|
|
2316
|
+
serializeResourceLogs(estimator, resource, scopeMap);
|
|
2317
|
+
}
|
|
2318
|
+
const writer = new ProtobufWriter(estimator.pos);
|
|
2319
|
+
for (const [resource, scopeMap] of resourceMap) {
|
|
2320
|
+
writer.writeTag(1, 2);
|
|
2321
|
+
serializeResourceLogs(writer, resource, scopeMap);
|
|
2322
|
+
}
|
|
2323
|
+
return writer.finish();
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/common/protobuf/protobuf-reader.js
|
|
2327
|
+
var ProtobufReader = class {
|
|
2328
|
+
pos = 0;
|
|
2329
|
+
_buf;
|
|
2330
|
+
_textDecoder;
|
|
2331
|
+
constructor(buf) {
|
|
2332
|
+
this._buf = buf;
|
|
2333
|
+
this._textDecoder = new TextDecoder();
|
|
2334
|
+
}
|
|
2335
|
+
isAtEnd() {
|
|
2336
|
+
return this.pos >= this._buf.length;
|
|
2337
|
+
}
|
|
2338
|
+
/** Read a varint and decode it as a tag, returning field number and wire type. */
|
|
2339
|
+
readTag() {
|
|
2340
|
+
const raw = this.readVarint();
|
|
2341
|
+
return { fieldNumber: raw >>> 3, wireType: raw & 7 };
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Read a base-128 varint.
|
|
2345
|
+
* Returns a JS `number`; precision above 2^53 is silently lost.
|
|
2346
|
+
* Throws if the buffer is truncated mid-varint.
|
|
2347
|
+
*/
|
|
2348
|
+
readVarint() {
|
|
2349
|
+
let result = 0;
|
|
2350
|
+
let shift = 0;
|
|
2351
|
+
let terminated = false;
|
|
2352
|
+
while (this.pos < this._buf.length) {
|
|
2353
|
+
const b = this._buf[this.pos++];
|
|
2354
|
+
result += (b & 127) * Math.pow(2, shift);
|
|
2355
|
+
shift += 7;
|
|
2356
|
+
if ((b & 128) === 0) {
|
|
2357
|
+
terminated = true;
|
|
2358
|
+
break;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
if (!terminated) {
|
|
2362
|
+
throw new Error("Truncated buffer: unexpected end of data while reading varint");
|
|
2363
|
+
}
|
|
2364
|
+
return result;
|
|
2365
|
+
}
|
|
2366
|
+
/** Read a length-delimited byte sequence (bytes field or embedded message). */
|
|
2367
|
+
readBytes() {
|
|
2368
|
+
const len = this.readVarint();
|
|
2369
|
+
if (this.pos + len > this._buf.length) {
|
|
2370
|
+
throw new Error(`Truncated buffer: expected ${len} bytes at position ${this.pos}, but only ${this._buf.length - this.pos} available`);
|
|
2371
|
+
}
|
|
2372
|
+
const slice = this._buf.subarray(this.pos, this.pos + len);
|
|
2373
|
+
this.pos += len;
|
|
2374
|
+
return slice;
|
|
2375
|
+
}
|
|
2376
|
+
/** Read a length-delimited UTF-8 string. */
|
|
2377
|
+
readString() {
|
|
2378
|
+
return this._textDecoder.decode(this.readBytes());
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Skip an unknown field.
|
|
2382
|
+
* Handles wire types 0 (varint), 1 (64-bit), 2 (length-delimited),
|
|
2383
|
+
* and 5 (32-bit).
|
|
2384
|
+
*
|
|
2385
|
+
* Wire types 3 and 4 (start-group / end-group) are deprecated in proto3
|
|
2386
|
+
* and are not used by any OpenTelemetry proto definition. Encountering
|
|
2387
|
+
* them is treated as an error.
|
|
2388
|
+
*/
|
|
2389
|
+
skip(wireType) {
|
|
2390
|
+
switch (wireType) {
|
|
2391
|
+
case 0:
|
|
2392
|
+
this.readVarint();
|
|
2393
|
+
break;
|
|
2394
|
+
case 1:
|
|
2395
|
+
this.pos += 8;
|
|
2396
|
+
break;
|
|
2397
|
+
case 2:
|
|
2398
|
+
this.readBytes();
|
|
2399
|
+
break;
|
|
2400
|
+
case 5:
|
|
2401
|
+
this.pos += 4;
|
|
2402
|
+
break;
|
|
2403
|
+
default:
|
|
2404
|
+
throw new Error(`Unknown wire type ${wireType}, cannot safely skip`);
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2409
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/logs/protobuf/response-deserializer.js
|
|
2410
|
+
function deserializePartialSuccess(data) {
|
|
2411
|
+
const reader = new ProtobufReader(data);
|
|
2412
|
+
const result = {};
|
|
2413
|
+
while (!reader.isAtEnd()) {
|
|
2414
|
+
const { fieldNumber, wireType } = reader.readTag();
|
|
2415
|
+
switch (fieldNumber) {
|
|
2416
|
+
case 1:
|
|
2417
|
+
if (wireType === 0) {
|
|
2418
|
+
result.rejectedLogRecords = reader.readVarint();
|
|
2419
|
+
} else {
|
|
2420
|
+
reader.skip(wireType);
|
|
2421
|
+
}
|
|
2422
|
+
break;
|
|
2423
|
+
case 2:
|
|
2424
|
+
if (wireType === 2) {
|
|
2425
|
+
result.errorMessage = reader.readString();
|
|
2426
|
+
} else {
|
|
2427
|
+
reader.skip(wireType);
|
|
2428
|
+
}
|
|
2429
|
+
break;
|
|
2430
|
+
default:
|
|
2431
|
+
reader.skip(wireType);
|
|
2432
|
+
break;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
return result;
|
|
2436
|
+
}
|
|
2437
|
+
function deserializeExportLogsServiceResponse(data) {
|
|
2438
|
+
const reader = new ProtobufReader(data);
|
|
2439
|
+
const result = {};
|
|
2440
|
+
while (!reader.isAtEnd()) {
|
|
2441
|
+
const { fieldNumber, wireType } = reader.readTag();
|
|
2442
|
+
switch (fieldNumber) {
|
|
2443
|
+
case 1:
|
|
2444
|
+
if (wireType === 2) {
|
|
2445
|
+
result.partialSuccess = deserializePartialSuccess(reader.readBytes());
|
|
2446
|
+
} else {
|
|
2447
|
+
reader.skip(wireType);
|
|
2448
|
+
}
|
|
2449
|
+
break;
|
|
2450
|
+
default:
|
|
2451
|
+
reader.skip(wireType);
|
|
2452
|
+
break;
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
return result;
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/logs/protobuf/logs.js
|
|
2459
|
+
var ProtobufLogsSerializer = {
|
|
2460
|
+
serializeRequest: (arg) => {
|
|
2461
|
+
return serializeLogsExportRequest(arg);
|
|
2462
|
+
},
|
|
2463
|
+
deserializeResponse: (arg) => {
|
|
2464
|
+
return deserializeExportLogsServiceResponse(arg);
|
|
2465
|
+
}
|
|
2466
|
+
};
|
|
2467
|
+
|
|
2468
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/metrics/protobuf/metrics-serializer.js
|
|
2469
|
+
init_esm();
|
|
2470
|
+
|
|
2471
|
+
// node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-metrics/build/esm/export/AggregationTemporality.js
|
|
2472
|
+
var AggregationTemporality;
|
|
2473
|
+
(function(AggregationTemporality2) {
|
|
2474
|
+
AggregationTemporality2[AggregationTemporality2["DELTA"] = 0] = "DELTA";
|
|
2475
|
+
AggregationTemporality2[AggregationTemporality2["CUMULATIVE"] = 1] = "CUMULATIVE";
|
|
2476
|
+
})(AggregationTemporality || (AggregationTemporality = {}));
|
|
2477
|
+
|
|
2478
|
+
// node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-metrics/build/esm/export/MetricData.js
|
|
2479
|
+
var InstrumentType;
|
|
2480
|
+
(function(InstrumentType2) {
|
|
2481
|
+
InstrumentType2["COUNTER"] = "COUNTER";
|
|
2482
|
+
InstrumentType2["GAUGE"] = "GAUGE";
|
|
2483
|
+
InstrumentType2["HISTOGRAM"] = "HISTOGRAM";
|
|
2484
|
+
InstrumentType2["UP_DOWN_COUNTER"] = "UP_DOWN_COUNTER";
|
|
2485
|
+
InstrumentType2["OBSERVABLE_COUNTER"] = "OBSERVABLE_COUNTER";
|
|
2486
|
+
InstrumentType2["OBSERVABLE_GAUGE"] = "OBSERVABLE_GAUGE";
|
|
2487
|
+
InstrumentType2["OBSERVABLE_UP_DOWN_COUNTER"] = "OBSERVABLE_UP_DOWN_COUNTER";
|
|
2488
|
+
})(InstrumentType || (InstrumentType = {}));
|
|
2489
|
+
var DataPointType;
|
|
2490
|
+
(function(DataPointType2) {
|
|
2491
|
+
DataPointType2[DataPointType2["HISTOGRAM"] = 0] = "HISTOGRAM";
|
|
2492
|
+
DataPointType2[DataPointType2["EXPONENTIAL_HISTOGRAM"] = 1] = "EXPONENTIAL_HISTOGRAM";
|
|
2493
|
+
DataPointType2[DataPointType2["GAUGE"] = 2] = "GAUGE";
|
|
2494
|
+
DataPointType2[DataPointType2["SUM"] = 3] = "SUM";
|
|
2495
|
+
})(DataPointType || (DataPointType = {}));
|
|
2496
|
+
|
|
2497
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/metrics/protobuf/metrics-serializer.js
|
|
2498
|
+
function serializeNumberDataPoint(writer, dataPoint, valueType) {
|
|
2499
|
+
const start = writer.startLengthDelimited();
|
|
2500
|
+
const startPos = writer.pos;
|
|
2501
|
+
writer.writeTag(2, 1);
|
|
2502
|
+
writeHrTimeAsFixed64(writer, dataPoint.startTime);
|
|
2503
|
+
writer.writeTag(3, 1);
|
|
2504
|
+
writeHrTimeAsFixed64(writer, dataPoint.endTime);
|
|
2505
|
+
if (valueType === ValueType.INT) {
|
|
2506
|
+
writer.writeTag(6, 1);
|
|
2507
|
+
writer.writeSfixed64(dataPoint.value);
|
|
2508
|
+
} else {
|
|
2509
|
+
writer.writeTag(4, 1);
|
|
2510
|
+
writer.writeDouble(dataPoint.value);
|
|
2511
|
+
}
|
|
2512
|
+
if (dataPoint.attributes) {
|
|
2513
|
+
writeAttributes(writer, dataPoint.attributes, 7);
|
|
2514
|
+
}
|
|
2515
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2516
|
+
}
|
|
2517
|
+
function serializeHistogramDataPoint(writer, dataPoint) {
|
|
2518
|
+
const start = writer.startLengthDelimited();
|
|
2519
|
+
const startPos = writer.pos;
|
|
2520
|
+
const histogram = dataPoint.value;
|
|
2521
|
+
writer.writeTag(2, 1);
|
|
2522
|
+
writeHrTimeAsFixed64(writer, dataPoint.startTime);
|
|
2523
|
+
writer.writeTag(3, 1);
|
|
2524
|
+
writeHrTimeAsFixed64(writer, dataPoint.endTime);
|
|
2525
|
+
writer.writeTag(4, 1);
|
|
2526
|
+
writer.writeFixed64(histogram.count >>> 0, histogram.count / 4294967296 >>> 0);
|
|
2527
|
+
if (histogram.sum !== void 0) {
|
|
2528
|
+
writer.writeTag(5, 1);
|
|
2529
|
+
writer.writeDouble(histogram.sum);
|
|
2530
|
+
}
|
|
2531
|
+
if (histogram.buckets.counts.length > 0) {
|
|
2532
|
+
writer.writeTag(6, 2);
|
|
2533
|
+
const countsStart = writer.startLengthDelimited();
|
|
2534
|
+
const countsStartPos = writer.pos;
|
|
2535
|
+
for (const count of histogram.buckets.counts) {
|
|
2536
|
+
writer.writeFixed64(count >>> 0, count / 4294967296 >>> 0);
|
|
2537
|
+
}
|
|
2538
|
+
writer.finishLengthDelimited(countsStart, writer.pos - countsStartPos);
|
|
2539
|
+
}
|
|
2540
|
+
if (histogram.buckets.boundaries.length > 0) {
|
|
2541
|
+
writer.writeTag(7, 2);
|
|
2542
|
+
const boundsStart = writer.startLengthDelimited();
|
|
2543
|
+
const boundsStartPos = writer.pos;
|
|
2544
|
+
for (const bound of histogram.buckets.boundaries) {
|
|
2545
|
+
writer.writeDouble(bound);
|
|
2546
|
+
}
|
|
2547
|
+
writer.finishLengthDelimited(boundsStart, writer.pos - boundsStartPos);
|
|
2548
|
+
}
|
|
2549
|
+
if (dataPoint.attributes) {
|
|
2550
|
+
writeAttributes(writer, dataPoint.attributes, 9);
|
|
2551
|
+
}
|
|
2552
|
+
if (histogram.min !== void 0) {
|
|
2553
|
+
writer.writeTag(11, 1);
|
|
2554
|
+
writer.writeDouble(histogram.min);
|
|
2555
|
+
}
|
|
2556
|
+
if (histogram.max !== void 0) {
|
|
2557
|
+
writer.writeTag(12, 1);
|
|
2558
|
+
writer.writeDouble(histogram.max);
|
|
2559
|
+
}
|
|
2560
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2561
|
+
}
|
|
2562
|
+
function serializeExponentialBuckets(writer, offset, bucketCounts) {
|
|
2563
|
+
const start = writer.startLengthDelimited();
|
|
2564
|
+
const startPos = writer.pos;
|
|
2565
|
+
if (offset !== 0) {
|
|
2566
|
+
writer.writeTag(1, 0);
|
|
2567
|
+
writer.writeSint32(offset);
|
|
2568
|
+
}
|
|
2569
|
+
if (bucketCounts.length > 0) {
|
|
2570
|
+
writer.writeTag(2, 2);
|
|
2571
|
+
const bcStart = writer.startLengthDelimited();
|
|
2572
|
+
const bcStartPos = writer.pos;
|
|
2573
|
+
for (const count of bucketCounts) {
|
|
2574
|
+
writer.writeVarint(count);
|
|
2575
|
+
}
|
|
2576
|
+
writer.finishLengthDelimited(bcStart, writer.pos - bcStartPos);
|
|
2577
|
+
}
|
|
2578
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2579
|
+
}
|
|
2580
|
+
function serializeExponentialHistogramDataPoint(writer, dataPoint) {
|
|
2581
|
+
const start = writer.startLengthDelimited();
|
|
2582
|
+
const startPos = writer.pos;
|
|
2583
|
+
const histogram = dataPoint.value;
|
|
2584
|
+
if (dataPoint.attributes) {
|
|
2585
|
+
writeAttributes(writer, dataPoint.attributes, 1);
|
|
2586
|
+
}
|
|
2587
|
+
writer.writeTag(2, 1);
|
|
2588
|
+
writeHrTimeAsFixed64(writer, dataPoint.startTime);
|
|
2589
|
+
writer.writeTag(3, 1);
|
|
2590
|
+
writeHrTimeAsFixed64(writer, dataPoint.endTime);
|
|
2591
|
+
writer.writeTag(4, 1);
|
|
2592
|
+
writer.writeFixed64(histogram.count >>> 0, histogram.count / 4294967296 >>> 0);
|
|
2593
|
+
if (histogram.sum !== void 0) {
|
|
2594
|
+
writer.writeTag(5, 1);
|
|
2595
|
+
writer.writeDouble(histogram.sum);
|
|
2596
|
+
}
|
|
2597
|
+
if (histogram.scale !== 0) {
|
|
2598
|
+
writer.writeTag(6, 0);
|
|
2599
|
+
writer.writeSint32(histogram.scale);
|
|
2600
|
+
}
|
|
2601
|
+
writer.writeTag(7, 1);
|
|
2602
|
+
writer.writeFixed64(histogram.zeroCount >>> 0, histogram.zeroCount / 4294967296 >>> 0);
|
|
2603
|
+
writer.writeTag(8, 2);
|
|
2604
|
+
serializeExponentialBuckets(writer, histogram.positive.offset, histogram.positive.bucketCounts);
|
|
2605
|
+
writer.writeTag(9, 2);
|
|
2606
|
+
serializeExponentialBuckets(writer, histogram.negative.offset, histogram.negative.bucketCounts);
|
|
2607
|
+
if (histogram.min !== void 0) {
|
|
2608
|
+
writer.writeTag(12, 1);
|
|
2609
|
+
writer.writeDouble(histogram.min);
|
|
2610
|
+
}
|
|
2611
|
+
if (histogram.max !== void 0) {
|
|
2612
|
+
writer.writeTag(13, 1);
|
|
2613
|
+
writer.writeDouble(histogram.max);
|
|
2614
|
+
}
|
|
2615
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2616
|
+
}
|
|
2617
|
+
function serializeMetric(writer, metricData) {
|
|
2618
|
+
const metricStart = writer.startLengthDelimited();
|
|
2619
|
+
const metricStartPos = writer.pos;
|
|
2620
|
+
writer.writeTag(1, 2);
|
|
2621
|
+
writer.writeString(metricData.descriptor.name);
|
|
2622
|
+
if (metricData.descriptor.description) {
|
|
2623
|
+
writer.writeTag(2, 2);
|
|
2624
|
+
writer.writeString(metricData.descriptor.description);
|
|
2625
|
+
}
|
|
2626
|
+
if (metricData.descriptor.unit) {
|
|
2627
|
+
writer.writeTag(3, 2);
|
|
2628
|
+
writer.writeString(metricData.descriptor.unit);
|
|
2629
|
+
}
|
|
2630
|
+
switch (metricData.dataPointType) {
|
|
2631
|
+
case DataPointType.GAUGE:
|
|
2632
|
+
writer.writeTag(5, 2);
|
|
2633
|
+
serializeGauge(writer, metricData);
|
|
2634
|
+
break;
|
|
2635
|
+
case DataPointType.SUM:
|
|
2636
|
+
writer.writeTag(7, 2);
|
|
2637
|
+
serializeSum(writer, metricData);
|
|
2638
|
+
break;
|
|
2639
|
+
case DataPointType.HISTOGRAM:
|
|
2640
|
+
writer.writeTag(9, 2);
|
|
2641
|
+
serializeHistogramMetric(writer, metricData);
|
|
2642
|
+
break;
|
|
2643
|
+
case DataPointType.EXPONENTIAL_HISTOGRAM:
|
|
2644
|
+
writer.writeTag(10, 2);
|
|
2645
|
+
serializeExponentialHistogramMetric(writer, metricData);
|
|
2646
|
+
break;
|
|
2647
|
+
default: {
|
|
2648
|
+
const _exhaustive = metricData;
|
|
2649
|
+
void _exhaustive;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
writer.finishLengthDelimited(metricStart, writer.pos - metricStartPos);
|
|
2653
|
+
}
|
|
2654
|
+
function serializeGauge(writer, metricData) {
|
|
2655
|
+
const start = writer.startLengthDelimited();
|
|
2656
|
+
const startPos = writer.pos;
|
|
2657
|
+
for (const dataPoint of metricData.dataPoints) {
|
|
2658
|
+
writer.writeTag(1, 2);
|
|
2659
|
+
serializeNumberDataPoint(writer, dataPoint, metricData.descriptor.valueType);
|
|
2660
|
+
}
|
|
2661
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2662
|
+
}
|
|
2663
|
+
function serializeSum(writer, metricData) {
|
|
2664
|
+
const start = writer.startLengthDelimited();
|
|
2665
|
+
const startPos = writer.pos;
|
|
2666
|
+
for (const dataPoint of metricData.dataPoints) {
|
|
2667
|
+
writer.writeTag(1, 2);
|
|
2668
|
+
serializeNumberDataPoint(writer, dataPoint, metricData.descriptor.valueType);
|
|
2669
|
+
}
|
|
2670
|
+
const temporality = toProtoAggregationTemporality(metricData.aggregationTemporality);
|
|
2671
|
+
if (temporality !== 0) {
|
|
2672
|
+
writer.writeTag(2, 0);
|
|
2673
|
+
writer.writeVarint(temporality);
|
|
2674
|
+
}
|
|
2675
|
+
if (metricData.isMonotonic) {
|
|
2676
|
+
writer.writeTag(3, 0);
|
|
2677
|
+
writer.writeVarint(1);
|
|
2678
|
+
}
|
|
2679
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2680
|
+
}
|
|
2681
|
+
function serializeHistogramMetric(writer, metricData) {
|
|
2682
|
+
const start = writer.startLengthDelimited();
|
|
2683
|
+
const startPos = writer.pos;
|
|
2684
|
+
for (const dataPoint of metricData.dataPoints) {
|
|
2685
|
+
writer.writeTag(1, 2);
|
|
2686
|
+
serializeHistogramDataPoint(writer, dataPoint);
|
|
2687
|
+
}
|
|
2688
|
+
const temporality = toProtoAggregationTemporality(metricData.aggregationTemporality);
|
|
2689
|
+
if (temporality !== 0) {
|
|
2690
|
+
writer.writeTag(2, 0);
|
|
2691
|
+
writer.writeVarint(temporality);
|
|
2692
|
+
}
|
|
2693
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2694
|
+
}
|
|
2695
|
+
function serializeExponentialHistogramMetric(writer, metricData) {
|
|
2696
|
+
const start = writer.startLengthDelimited();
|
|
2697
|
+
const startPos = writer.pos;
|
|
2698
|
+
for (const dataPoint of metricData.dataPoints) {
|
|
2699
|
+
writer.writeTag(1, 2);
|
|
2700
|
+
serializeExponentialHistogramDataPoint(writer, dataPoint);
|
|
2701
|
+
}
|
|
2702
|
+
const temporality = toProtoAggregationTemporality(metricData.aggregationTemporality);
|
|
2703
|
+
if (temporality !== 0) {
|
|
2704
|
+
writer.writeTag(2, 0);
|
|
2705
|
+
writer.writeVarint(temporality);
|
|
2706
|
+
}
|
|
2707
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2708
|
+
}
|
|
2709
|
+
function serializeScopeMetrics(writer, scopeMetrics) {
|
|
2710
|
+
const scopeStart = writer.startLengthDelimited();
|
|
2711
|
+
const scopeStartPos = writer.pos;
|
|
2712
|
+
writeInstrumentationScope(writer, scopeMetrics.scope, 1);
|
|
2713
|
+
for (const metric of scopeMetrics.metrics) {
|
|
2714
|
+
writer.writeTag(2, 2);
|
|
2715
|
+
serializeMetric(writer, metric);
|
|
2716
|
+
}
|
|
2717
|
+
if (scopeMetrics.scope.schemaUrl) {
|
|
2718
|
+
writer.writeTag(3, 2);
|
|
2719
|
+
writer.writeString(scopeMetrics.scope.schemaUrl);
|
|
2720
|
+
}
|
|
2721
|
+
writer.finishLengthDelimited(scopeStart, writer.pos - scopeStartPos);
|
|
2722
|
+
}
|
|
2723
|
+
function serializeResourceMetrics(writer, resourceMetrics) {
|
|
2724
|
+
const start = writer.startLengthDelimited();
|
|
2725
|
+
const startPos = writer.pos;
|
|
2726
|
+
writeResource(writer, resourceMetrics.resource, 1);
|
|
2727
|
+
for (const scopeMetrics of resourceMetrics.scopeMetrics) {
|
|
2728
|
+
writer.writeTag(2, 2);
|
|
2729
|
+
serializeScopeMetrics(writer, scopeMetrics);
|
|
2730
|
+
}
|
|
2731
|
+
if (resourceMetrics.resource.schemaUrl) {
|
|
2732
|
+
writer.writeTag(3, 2);
|
|
2733
|
+
writer.writeString(resourceMetrics.resource.schemaUrl);
|
|
2734
|
+
}
|
|
2735
|
+
writer.finishLengthDelimited(start, writer.pos - startPos);
|
|
2736
|
+
}
|
|
2737
|
+
function toProtoAggregationTemporality(temporality) {
|
|
2738
|
+
switch (temporality) {
|
|
2739
|
+
case AggregationTemporality.DELTA:
|
|
2740
|
+
return 1;
|
|
2741
|
+
case AggregationTemporality.CUMULATIVE:
|
|
2742
|
+
return 2;
|
|
2743
|
+
default:
|
|
2744
|
+
return 0;
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
function serializeMetricsExportRequest(resourceMetrics) {
|
|
2748
|
+
const estimator = new ProtobufSizeEstimator();
|
|
2749
|
+
estimator.writeTag(1, 2);
|
|
2750
|
+
serializeResourceMetrics(estimator, resourceMetrics);
|
|
2751
|
+
const writer = new ProtobufWriter(estimator.pos);
|
|
2752
|
+
writer.writeTag(1, 2);
|
|
2753
|
+
serializeResourceMetrics(writer, resourceMetrics);
|
|
2754
|
+
return writer.finish();
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/metrics/protobuf/response-deserializer.js
|
|
2758
|
+
function deserializePartialSuccess2(data) {
|
|
2759
|
+
const reader = new ProtobufReader(data);
|
|
2760
|
+
const result = {};
|
|
2761
|
+
while (!reader.isAtEnd()) {
|
|
2762
|
+
const { fieldNumber, wireType } = reader.readTag();
|
|
2763
|
+
switch (fieldNumber) {
|
|
2764
|
+
case 1:
|
|
2765
|
+
if (wireType === 0) {
|
|
2766
|
+
result.rejectedDataPoints = reader.readVarint();
|
|
2767
|
+
} else {
|
|
2768
|
+
reader.skip(wireType);
|
|
2769
|
+
}
|
|
2770
|
+
break;
|
|
2771
|
+
case 2:
|
|
2772
|
+
if (wireType === 2) {
|
|
2773
|
+
result.errorMessage = reader.readString();
|
|
2774
|
+
} else {
|
|
2775
|
+
reader.skip(wireType);
|
|
2776
|
+
}
|
|
2777
|
+
break;
|
|
2778
|
+
default:
|
|
2779
|
+
reader.skip(wireType);
|
|
2780
|
+
break;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
return result;
|
|
2784
|
+
}
|
|
2785
|
+
function deserializeExportMetricsServiceResponse(data) {
|
|
2786
|
+
const reader = new ProtobufReader(data);
|
|
2787
|
+
const result = {};
|
|
2788
|
+
while (!reader.isAtEnd()) {
|
|
2789
|
+
const { fieldNumber, wireType } = reader.readTag();
|
|
2790
|
+
switch (fieldNumber) {
|
|
2791
|
+
case 1:
|
|
2792
|
+
if (wireType === 2) {
|
|
2793
|
+
result.partialSuccess = deserializePartialSuccess2(reader.readBytes());
|
|
2794
|
+
} else {
|
|
2795
|
+
reader.skip(wireType);
|
|
2796
|
+
}
|
|
2797
|
+
break;
|
|
2798
|
+
default:
|
|
2799
|
+
reader.skip(wireType);
|
|
2800
|
+
break;
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
return result;
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/metrics/protobuf/metrics.js
|
|
2807
|
+
var ProtobufMetricsSerializer = {
|
|
2808
|
+
serializeRequest: (arg) => {
|
|
2809
|
+
return serializeMetricsExportRequest(arg);
|
|
2810
|
+
},
|
|
2811
|
+
deserializeResponse: (arg) => {
|
|
2812
|
+
return deserializeExportMetricsServiceResponse(arg);
|
|
2813
|
+
}
|
|
2814
|
+
};
|
|
2815
|
+
|
|
2816
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/trace/protobuf/trace-serializer.js
|
|
2817
|
+
var SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 256;
|
|
2818
|
+
var SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 512;
|
|
2819
|
+
function buildSpanFlags(traceFlags, isRemote) {
|
|
2820
|
+
let flags = traceFlags & 255 | SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK;
|
|
2821
|
+
if (isRemote) {
|
|
2822
|
+
flags |= SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK;
|
|
2823
|
+
}
|
|
2824
|
+
return flags;
|
|
2825
|
+
}
|
|
2826
|
+
function serializeStatus(writer, status) {
|
|
2827
|
+
const statusStart = writer.startLengthDelimited();
|
|
2828
|
+
const statusStartPos = writer.pos;
|
|
2829
|
+
if (status.message) {
|
|
2830
|
+
writer.writeTag(2, 2);
|
|
2831
|
+
writer.writeString(status.message);
|
|
2832
|
+
}
|
|
2833
|
+
writer.writeTag(3, 0);
|
|
2834
|
+
writer.writeVarint(status.code);
|
|
2835
|
+
writer.finishLengthDelimited(statusStart, writer.pos - statusStartPos);
|
|
2836
|
+
}
|
|
2837
|
+
function serializeEvent(writer, event) {
|
|
2838
|
+
const eventStart = writer.startLengthDelimited();
|
|
2839
|
+
const eventStartPos = writer.pos;
|
|
2840
|
+
writer.writeTag(1, 1);
|
|
2841
|
+
writeHrTimeAsFixed64(writer, event.time);
|
|
2842
|
+
writer.writeTag(2, 2);
|
|
2843
|
+
writer.writeString(event.name);
|
|
2844
|
+
if (event.attributes) {
|
|
2845
|
+
writeAttributes(writer, event.attributes, 3);
|
|
2846
|
+
}
|
|
2847
|
+
writer.writeTag(4, 0);
|
|
2848
|
+
writer.writeVarint(event.droppedAttributesCount || 0);
|
|
2849
|
+
writer.finishLengthDelimited(eventStart, writer.pos - eventStartPos);
|
|
2850
|
+
}
|
|
2851
|
+
function serializeLink(writer, link) {
|
|
2852
|
+
const linkStart = writer.startLengthDelimited();
|
|
2853
|
+
const linkStartPos = writer.pos;
|
|
2854
|
+
const context = link.context;
|
|
2855
|
+
writer.writeTag(1, 2);
|
|
2856
|
+
writer.writeBytes(hexToBinary(context.traceId));
|
|
2857
|
+
writer.writeTag(2, 2);
|
|
2858
|
+
writer.writeBytes(hexToBinary(context.spanId));
|
|
2859
|
+
const linkTraceState = context.traceState?.serialize();
|
|
2860
|
+
if (linkTraceState) {
|
|
2861
|
+
writer.writeTag(3, 2);
|
|
2862
|
+
writer.writeString(linkTraceState);
|
|
2863
|
+
}
|
|
2864
|
+
if (link.attributes) {
|
|
2865
|
+
writeAttributes(writer, link.attributes, 4);
|
|
2866
|
+
}
|
|
2867
|
+
writer.writeTag(5, 0);
|
|
2868
|
+
writer.writeVarint(link.droppedAttributesCount || 0);
|
|
2869
|
+
const linkFlags = buildSpanFlags(context.traceFlags, context.isRemote);
|
|
2870
|
+
if (linkFlags) {
|
|
2871
|
+
writer.writeTag(6, 5);
|
|
2872
|
+
writer.writeFixed32(linkFlags);
|
|
2873
|
+
}
|
|
2874
|
+
writer.finishLengthDelimited(linkStart, writer.pos - linkStartPos);
|
|
2875
|
+
}
|
|
2876
|
+
function serializeSpan(writer, span) {
|
|
2877
|
+
const spanStart = writer.startLengthDelimited();
|
|
2878
|
+
const spanStartPos = writer.pos;
|
|
2879
|
+
const ctx = span.spanContext();
|
|
2880
|
+
writer.writeTag(1, 2);
|
|
2881
|
+
writer.writeBytes(hexToBinary(ctx.traceId));
|
|
2882
|
+
writer.writeTag(2, 2);
|
|
2883
|
+
writer.writeBytes(hexToBinary(ctx.spanId));
|
|
2884
|
+
const traceState = ctx.traceState?.serialize();
|
|
2885
|
+
if (traceState) {
|
|
2886
|
+
writer.writeTag(3, 2);
|
|
2887
|
+
writer.writeString(traceState);
|
|
2888
|
+
}
|
|
2889
|
+
if (span.parentSpanContext?.spanId) {
|
|
2890
|
+
writer.writeTag(4, 2);
|
|
2891
|
+
writer.writeBytes(hexToBinary(span.parentSpanContext.spanId));
|
|
2892
|
+
}
|
|
2893
|
+
writer.writeTag(5, 2);
|
|
2894
|
+
writer.writeString(span.name);
|
|
2895
|
+
const kind = span.kind == null ? 0 : span.kind + 1;
|
|
2896
|
+
if (kind !== 0) {
|
|
2897
|
+
writer.writeTag(6, 0);
|
|
2898
|
+
writer.writeVarint(kind);
|
|
2899
|
+
}
|
|
2900
|
+
writer.writeTag(7, 1);
|
|
2901
|
+
writeHrTimeAsFixed64(writer, span.startTime);
|
|
2902
|
+
writer.writeTag(8, 1);
|
|
2903
|
+
writeHrTimeAsFixed64(writer, span.endTime);
|
|
2904
|
+
if (span.attributes) {
|
|
2905
|
+
writeAttributes(writer, span.attributes, 9);
|
|
2906
|
+
}
|
|
2907
|
+
writer.writeTag(10, 0);
|
|
2908
|
+
writer.writeVarint(span.droppedAttributesCount);
|
|
2909
|
+
for (const event of span.events) {
|
|
2910
|
+
writer.writeTag(11, 2);
|
|
2911
|
+
serializeEvent(writer, event);
|
|
2912
|
+
}
|
|
2913
|
+
writer.writeTag(12, 0);
|
|
2914
|
+
writer.writeVarint(span.droppedEventsCount);
|
|
2915
|
+
for (const link of span.links) {
|
|
2916
|
+
writer.writeTag(13, 2);
|
|
2917
|
+
serializeLink(writer, link);
|
|
2918
|
+
}
|
|
2919
|
+
writer.writeTag(14, 0);
|
|
2920
|
+
writer.writeVarint(span.droppedLinksCount);
|
|
2921
|
+
writer.writeTag(15, 2);
|
|
2922
|
+
serializeStatus(writer, span.status);
|
|
2923
|
+
const flags = buildSpanFlags(ctx.traceFlags, span.parentSpanContext?.isRemote);
|
|
2924
|
+
if (flags) {
|
|
2925
|
+
writer.writeTag(16, 5);
|
|
2926
|
+
writer.writeFixed32(flags);
|
|
2927
|
+
}
|
|
2928
|
+
writer.finishLengthDelimited(spanStart, writer.pos - spanStartPos);
|
|
2929
|
+
}
|
|
2930
|
+
function serializeScopeSpans(writer, scope, spans) {
|
|
2931
|
+
const scopeSpansStart = writer.startLengthDelimited();
|
|
2932
|
+
const scopeSpansStartPos = writer.pos;
|
|
2933
|
+
writeInstrumentationScope(writer, scope, 1);
|
|
2934
|
+
for (const span of spans) {
|
|
2935
|
+
writer.writeTag(2, 2);
|
|
2936
|
+
serializeSpan(writer, span);
|
|
2937
|
+
}
|
|
2938
|
+
if (scope.schemaUrl) {
|
|
2939
|
+
writer.writeTag(3, 2);
|
|
2940
|
+
writer.writeString(scope.schemaUrl);
|
|
2941
|
+
}
|
|
2942
|
+
writer.finishLengthDelimited(scopeSpansStart, writer.pos - scopeSpansStartPos);
|
|
2943
|
+
}
|
|
2944
|
+
function serializeResourceSpans(writer, resource, scopeMap) {
|
|
2945
|
+
const resourceSpansStart = writer.startLengthDelimited();
|
|
2946
|
+
const resourceSpansStartPos = writer.pos;
|
|
2947
|
+
writeResource(writer, resource, 1);
|
|
2948
|
+
for (const scopeSpans of scopeMap.values()) {
|
|
2949
|
+
writer.writeTag(2, 2);
|
|
2950
|
+
const scope = scopeSpans[0].instrumentationScope;
|
|
2951
|
+
serializeScopeSpans(writer, scope, scopeSpans);
|
|
2952
|
+
}
|
|
2953
|
+
if (resource.schemaUrl) {
|
|
2954
|
+
writer.writeTag(3, 2);
|
|
2955
|
+
writer.writeString(resource.schemaUrl);
|
|
2956
|
+
}
|
|
2957
|
+
writer.finishLengthDelimited(resourceSpansStart, writer.pos - resourceSpansStartPos);
|
|
2958
|
+
}
|
|
2959
|
+
function createResourceMap2(spans) {
|
|
2960
|
+
const resourceMap = /* @__PURE__ */ new Map();
|
|
2961
|
+
for (const span of spans) {
|
|
2962
|
+
const resource = span.resource;
|
|
2963
|
+
const scope = span.instrumentationScope;
|
|
2964
|
+
let scopeMap = resourceMap.get(resource);
|
|
2965
|
+
if (!scopeMap) {
|
|
2966
|
+
scopeMap = /* @__PURE__ */ new Map();
|
|
2967
|
+
resourceMap.set(resource, scopeMap);
|
|
2968
|
+
}
|
|
2969
|
+
let records = scopeMap.get(scope);
|
|
2970
|
+
if (!records) {
|
|
2971
|
+
records = [];
|
|
2972
|
+
scopeMap.set(scope, records);
|
|
2973
|
+
}
|
|
2974
|
+
records.push(span);
|
|
2975
|
+
}
|
|
2976
|
+
return resourceMap;
|
|
2977
|
+
}
|
|
2978
|
+
function serializeTraceExportRequest(spans) {
|
|
2979
|
+
const resourceMap = createResourceMap2(spans);
|
|
2980
|
+
const estimator = new ProtobufSizeEstimator();
|
|
2981
|
+
for (const [resource, scopeMap] of resourceMap) {
|
|
2982
|
+
estimator.writeTag(1, 2);
|
|
2983
|
+
serializeResourceSpans(estimator, resource, scopeMap);
|
|
2984
|
+
}
|
|
2985
|
+
const writer = new ProtobufWriter(estimator.pos);
|
|
2986
|
+
for (const [resource, scopeMap] of resourceMap) {
|
|
2987
|
+
writer.writeTag(1, 2);
|
|
2988
|
+
serializeResourceSpans(writer, resource, scopeMap);
|
|
2989
|
+
}
|
|
2990
|
+
return writer.finish();
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2993
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/trace/protobuf/response-deserializer.js
|
|
2994
|
+
function deserializePartialSuccess3(data) {
|
|
2995
|
+
const reader = new ProtobufReader(data);
|
|
2996
|
+
const result = {};
|
|
2997
|
+
while (!reader.isAtEnd()) {
|
|
2998
|
+
const { fieldNumber, wireType } = reader.readTag();
|
|
2999
|
+
switch (fieldNumber) {
|
|
3000
|
+
case 1:
|
|
3001
|
+
if (wireType === 0) {
|
|
3002
|
+
result.rejectedSpans = reader.readVarint();
|
|
3003
|
+
} else {
|
|
3004
|
+
reader.skip(wireType);
|
|
3005
|
+
}
|
|
3006
|
+
break;
|
|
3007
|
+
case 2:
|
|
3008
|
+
if (wireType === 2) {
|
|
3009
|
+
result.errorMessage = reader.readString();
|
|
3010
|
+
} else {
|
|
3011
|
+
reader.skip(wireType);
|
|
3012
|
+
}
|
|
3013
|
+
break;
|
|
3014
|
+
default:
|
|
3015
|
+
reader.skip(wireType);
|
|
3016
|
+
break;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
return result;
|
|
3020
|
+
}
|
|
3021
|
+
function deserializeExportTraceServiceResponse(data) {
|
|
3022
|
+
const reader = new ProtobufReader(data);
|
|
3023
|
+
const result = {};
|
|
3024
|
+
while (!reader.isAtEnd()) {
|
|
3025
|
+
const { fieldNumber, wireType } = reader.readTag();
|
|
3026
|
+
switch (fieldNumber) {
|
|
3027
|
+
case 1:
|
|
3028
|
+
if (wireType === 2) {
|
|
3029
|
+
result.partialSuccess = deserializePartialSuccess3(reader.readBytes());
|
|
3030
|
+
} else {
|
|
3031
|
+
reader.skip(wireType);
|
|
3032
|
+
}
|
|
3033
|
+
break;
|
|
3034
|
+
default:
|
|
3035
|
+
reader.skip(wireType);
|
|
3036
|
+
break;
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
return result;
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
// node_modules/@opentelemetry/otlp-transformer/build/esm/trace/protobuf/trace.js
|
|
3043
|
+
var ProtobufTraceSerializer = {
|
|
3044
|
+
serializeRequest: (arg) => {
|
|
3045
|
+
return serializeTraceExportRequest(arg);
|
|
3046
|
+
},
|
|
3047
|
+
deserializeResponse: (arg) => {
|
|
3048
|
+
return deserializeExportTraceServiceResponse(arg);
|
|
3049
|
+
}
|
|
3050
|
+
};
|
|
3051
|
+
|
|
3052
|
+
// lib/otel/otlp-serialize.ts
|
|
3053
|
+
init_esm2();
|
|
3054
|
+
var DEFAULT_SCOPE = { name: "claude-hooks", version: SERVICE_VERSION };
|
|
3055
|
+
function sampledCtx(traceId, spanId) {
|
|
3056
|
+
return { traceId, spanId, traceFlags: TraceFlags.SAMPLED, isRemote: false };
|
|
3057
|
+
}
|
|
3058
|
+
function resourceAttrs(resource) {
|
|
3059
|
+
return {
|
|
3060
|
+
[ATTR_SERVICE_NAME]: resource?.serviceName ?? getServiceName(),
|
|
3061
|
+
[ATTR_SERVICE_VERSION]: resource?.serviceVersion ?? SERVICE_VERSION
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
3064
|
+
function exportedSpanToReadable(s) {
|
|
3065
|
+
const spanCtx = sampledCtx(s.traceId, s.spanId);
|
|
3066
|
+
const instrumentationScope = {
|
|
3067
|
+
name: s.instrumentationScope?.name ?? DEFAULT_SCOPE.name,
|
|
3068
|
+
version: s.instrumentationScope?.version ?? DEFAULT_SCOPE.version
|
|
3069
|
+
};
|
|
3070
|
+
return {
|
|
3071
|
+
name: s.name,
|
|
3072
|
+
kind: s.kind ?? SpanKind.INTERNAL,
|
|
3073
|
+
spanContext: () => spanCtx,
|
|
3074
|
+
parentSpanId: s.parentSpanId,
|
|
3075
|
+
parentSpanContext: s.parentSpanId ? sampledCtx(s.traceId, s.parentSpanId) : void 0,
|
|
3076
|
+
startTime: s.startTime,
|
|
3077
|
+
endTime: s.endTime,
|
|
3078
|
+
duration: s.duration,
|
|
3079
|
+
status: s.status ?? { code: SpanStatusCode.UNSET },
|
|
3080
|
+
attributes: s.attributes ?? {},
|
|
3081
|
+
events: s.events ?? [],
|
|
3082
|
+
links: s.links ?? [],
|
|
3083
|
+
resource: { attributes: resourceAttrs(s.resource), merge: () => null },
|
|
3084
|
+
instrumentationLibrary: instrumentationScope,
|
|
3085
|
+
instrumentationScope,
|
|
3086
|
+
droppedAttributesCount: 0,
|
|
3087
|
+
droppedEventsCount: 0,
|
|
3088
|
+
droppedLinksCount: 0
|
|
3089
|
+
};
|
|
3090
|
+
}
|
|
3091
|
+
function exportedLogToReadable(l) {
|
|
3092
|
+
const instrumentationScope = l.instrumentationScope ?? { name: getServiceName(), version: SERVICE_VERSION };
|
|
3093
|
+
return {
|
|
3094
|
+
hrTime: l.timestamp,
|
|
3095
|
+
hrTimeObserved: l.observedTimestamp ?? l.timestamp,
|
|
3096
|
+
severityNumber: l.severityNumber,
|
|
3097
|
+
severityText: l.severityText,
|
|
3098
|
+
body: l.body,
|
|
3099
|
+
eventName: l.eventName,
|
|
3100
|
+
attributes: l.attributes ?? {},
|
|
3101
|
+
droppedAttributesCount: 0,
|
|
3102
|
+
spanContext: l.traceId && l.spanId ? sampledCtx(l.traceId, l.spanId) : void 0,
|
|
3103
|
+
resource: { attributes: resourceAttrs(l.resource) },
|
|
3104
|
+
instrumentationScope
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
function recordsCarried(bodies) {
|
|
3108
|
+
return bodies.reduce((sum, body) => sum + body.recordCount, 0);
|
|
3109
|
+
}
|
|
3110
|
+
function packBodies(bodies, maxBytes) {
|
|
3111
|
+
const packed = [];
|
|
3112
|
+
let group = [];
|
|
3113
|
+
let groupBytes = 0;
|
|
3114
|
+
const flush = () => {
|
|
3115
|
+
if (group.length === 0) return;
|
|
3116
|
+
if (group.length === 1) {
|
|
3117
|
+
packed.push(...group);
|
|
3118
|
+
} else {
|
|
3119
|
+
const joined = new Uint8Array(groupBytes);
|
|
3120
|
+
let offset = 0;
|
|
3121
|
+
for (const { bytes } of group) {
|
|
3122
|
+
joined.set(bytes, offset);
|
|
3123
|
+
offset += bytes.byteLength;
|
|
3124
|
+
}
|
|
3125
|
+
packed.push({ bytes: joined, recordCount: recordsCarried(group) });
|
|
3126
|
+
}
|
|
3127
|
+
group = [];
|
|
3128
|
+
groupBytes = 0;
|
|
3129
|
+
};
|
|
3130
|
+
for (const body of bodies) {
|
|
3131
|
+
if (groupBytes + body.bytes.byteLength > maxBytes) flush();
|
|
3132
|
+
group.push(body);
|
|
3133
|
+
groupBytes += body.bytes.byteLength;
|
|
3134
|
+
}
|
|
3135
|
+
flush();
|
|
3136
|
+
return packed;
|
|
3137
|
+
}
|
|
3138
|
+
var RECORDS_PER_METRICS_BODY = 1;
|
|
3139
|
+
function isStoredRecord(signal, r) {
|
|
3140
|
+
if (!isJsonObject(r)) return false;
|
|
3141
|
+
switch (signal) {
|
|
3142
|
+
case "traces":
|
|
3143
|
+
return typeof r.traceId === "string" && typeof r.spanId === "string";
|
|
3144
|
+
case "logs":
|
|
3145
|
+
return Array.isArray(r.timestamp);
|
|
3146
|
+
case "metrics":
|
|
3147
|
+
return Array.isArray(r.scopeMetrics);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
function serializeBatch(signal, records) {
|
|
3151
|
+
switch (signal) {
|
|
3152
|
+
case "traces": {
|
|
3153
|
+
const body = ProtobufTraceSerializer.serializeRequest(
|
|
3154
|
+
records.map(exportedSpanToReadable)
|
|
3155
|
+
);
|
|
3156
|
+
return body ? [{ bytes: body, recordCount: records.length }] : [];
|
|
3157
|
+
}
|
|
3158
|
+
case "logs": {
|
|
3159
|
+
const body = ProtobufLogsSerializer.serializeRequest(
|
|
3160
|
+
records.map(exportedLogToReadable)
|
|
3161
|
+
);
|
|
3162
|
+
return body ? [{ bytes: body, recordCount: records.length }] : [];
|
|
3163
|
+
}
|
|
3164
|
+
case "metrics": {
|
|
3165
|
+
const bodies = [];
|
|
3166
|
+
for (const { resource, scopeMetrics } of records) {
|
|
3167
|
+
const body = ProtobufMetricsSerializer.serializeRequest(
|
|
3168
|
+
{ resource, scopeMetrics }
|
|
3169
|
+
);
|
|
3170
|
+
if (body) bodies.push({ bytes: body, recordCount: RECORDS_PER_METRICS_BODY });
|
|
3171
|
+
}
|
|
3172
|
+
return packBodies(bodies, SHIPPER_LIMITS.MAX_BYTES_PER_POST);
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
// lib/shipper/shipper-credentials.ts
|
|
3178
|
+
function keyRouteOf(record) {
|
|
3179
|
+
const ref = record.identityKeyRef;
|
|
3180
|
+
return typeof ref === "string" || ref === null ? ref : void 0;
|
|
3181
|
+
}
|
|
3182
|
+
function createCredentialResolver(opts, overrideHeaders) {
|
|
3183
|
+
const envHeaders = (signal) => {
|
|
3184
|
+
const headers = otlpAuthHeaders(signal);
|
|
3185
|
+
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
3186
|
+
};
|
|
3187
|
+
let signedInKeyFetch;
|
|
3188
|
+
const signedInKey = () => {
|
|
3189
|
+
signedInKeyFetch ??= opts.signedInSecretName && opts.keyForRef ? opts.keyForRef(opts.signedInSecretName) : Promise.resolve(void 0);
|
|
3190
|
+
return signedInKeyFetch;
|
|
3191
|
+
};
|
|
3192
|
+
return async (route, signal) => {
|
|
3193
|
+
if (route === void 0) {
|
|
3194
|
+
const key2 = overrideHeaders ? void 0 : await signedInKey();
|
|
3195
|
+
const headers = overrideHeaders ?? (key2 ? bearerHeaders(key2) : envHeaders(signal));
|
|
3196
|
+
return headers ? { headers } : { missing: "no credential for unstamped records" };
|
|
3197
|
+
}
|
|
3198
|
+
if (route === null) {
|
|
3199
|
+
const headers = envHeaders(signal);
|
|
3200
|
+
return headers ? { headers } : { withhold: true };
|
|
3201
|
+
}
|
|
3202
|
+
const key = await opts.keyForRef?.(route);
|
|
3203
|
+
return key ? { headers: bearerHeaders(key) } : { missing: `no key for ${route}` };
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
// lib/shipper/span-shipper.ts
|
|
3208
|
+
var NEWLINE_BYTES = 1;
|
|
3209
|
+
var LOCK_STALE_MS = TIME_MS.MINUTE;
|
|
3210
|
+
function fitsBatch(batch, route, record) {
|
|
3211
|
+
return batch.route === route && batch.records.length < SHIPPER_LIMITS.MAX_RECORDS_PER_BATCH && batch.bytes + record.lineBytes <= SHIPPER_LIMITS.MAX_BYTES_PER_POST;
|
|
3212
|
+
}
|
|
3213
|
+
function routeBatches(records) {
|
|
3214
|
+
const batches = [];
|
|
3215
|
+
for (const r of records) {
|
|
3216
|
+
const route = keyRouteOf(r.record);
|
|
3217
|
+
const last = batches.at(-1);
|
|
3218
|
+
if (last && fitsBatch(last, route, r)) {
|
|
3219
|
+
last.records.push(r);
|
|
3220
|
+
last.bytes += r.lineBytes;
|
|
3221
|
+
} else {
|
|
3222
|
+
batches.push({ route, records: [r], bytes: r.lineBytes });
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
return batches;
|
|
3226
|
+
}
|
|
3227
|
+
function readNewRecords(filePath, start, signal, aged = false) {
|
|
3228
|
+
const { lines, consumedEnd, skippedOversized } = readBoundedLines(filePath, start, {
|
|
3229
|
+
windowBytes: SHIPPER_LIMITS.MAX_BYTES_PER_RUN,
|
|
3230
|
+
maxLineBytes: SHIPPER_LIMITS.MAX_BYTES_PER_LINE,
|
|
3231
|
+
eofTerminates: aged
|
|
3232
|
+
});
|
|
3233
|
+
let discarded = skippedOversized;
|
|
3234
|
+
const records = [];
|
|
3235
|
+
for (const { text, endOffset } of lines) {
|
|
3236
|
+
const lineBytes = Buffer.byteLength(text) + NEWLINE_BYTES;
|
|
3237
|
+
try {
|
|
3238
|
+
const record = JSON.parse(text);
|
|
3239
|
+
if (isStoredRecord(signal, record)) {
|
|
3240
|
+
records.push({ record, endOffset, lineBytes });
|
|
3241
|
+
} else {
|
|
3242
|
+
discarded++;
|
|
3243
|
+
}
|
|
3244
|
+
} catch {
|
|
3245
|
+
discarded++;
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
return { records, consumedEnd, discarded };
|
|
3249
|
+
}
|
|
3250
|
+
var NOTHING_TO_SEND = "empty batch";
|
|
3251
|
+
function postFailureDetail(outcome) {
|
|
3252
|
+
switch (outcome.reason) {
|
|
3253
|
+
case "empty-batch":
|
|
3254
|
+
return NOTHING_TO_SEND;
|
|
3255
|
+
case "rejected":
|
|
3256
|
+
return `HTTP ${outcome.statusCode}`;
|
|
3257
|
+
case "threw":
|
|
3258
|
+
return shipperErrorDetail(outcome.error);
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
function postFailure(signal, outcome) {
|
|
3262
|
+
const detail = postFailureDetail(outcome);
|
|
3263
|
+
return {
|
|
3264
|
+
detail: `${signal} ${detail}`,
|
|
3265
|
+
kind: outcome.reason === "threw" ? shipperErrorKind(outcome.error) : detail
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
function resolveShipTarget(opts, telemetryDir) {
|
|
3269
|
+
const overrideHeaders = opts.apiKey ? bearerHeaders(opts.apiKey) : void 0;
|
|
3270
|
+
const preflight = shipPreflight(
|
|
3271
|
+
{
|
|
3272
|
+
// OTEL_* is stripped from hook processes, so this reads settings.json; the shipper
|
|
3273
|
+
// is the sole producer of traces, so a missing endpoint silently drops them.
|
|
3274
|
+
endpoint: opts.endpoint ?? resolveOtlpEndpoint(),
|
|
3275
|
+
// The spawn guard in `telemetry-shipper.ts` reads the identity map where this reads the caller's key sources.
|
|
3276
|
+
hasAuth: () => Boolean(overrideHeaders ?? opts.keyForRef) || hasOtlpAuth()
|
|
3277
|
+
},
|
|
3278
|
+
telemetryDir
|
|
3279
|
+
);
|
|
3280
|
+
if ("skipped" in preflight) return { shipped: 0, skipped: preflight.skipped };
|
|
3281
|
+
const credentialConflict = describeOtlpCredentialConflict();
|
|
3282
|
+
if (credentialConflict) {
|
|
3283
|
+
console.warn(`[span-shipper] ${credentialConflict}`);
|
|
3284
|
+
}
|
|
3285
|
+
return { endpoint: preflight.endpoint, overrideHeaders };
|
|
3286
|
+
}
|
|
3287
|
+
function acquireShipperLock(telemetryDir, cursorPath2) {
|
|
3288
|
+
try {
|
|
3289
|
+
ensureDirExists(dirname(cursorPath2));
|
|
3290
|
+
if (!existsSync(cursorPath2)) writeFileSync(cursorPath2, "", { flag: "wx" });
|
|
3291
|
+
const release = (0, import_proper_lockfile.lockSync)(cursorPath2, { stale: LOCK_STALE_MS });
|
|
3292
|
+
return () => {
|
|
3293
|
+
try {
|
|
3294
|
+
release();
|
|
3295
|
+
} catch {
|
|
3296
|
+
}
|
|
3297
|
+
};
|
|
3298
|
+
} catch {
|
|
3299
|
+
recordShipperBusy(telemetryDir);
|
|
3300
|
+
return void 0;
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
async function shipRecords(run, file, signal, records) {
|
|
3304
|
+
const url = `${run.endpoint}${otlpPathFor(signal)}`;
|
|
3305
|
+
const consumePrefix = (tally, batch, count) => {
|
|
3306
|
+
const last = batch[count - 1];
|
|
3307
|
+
if (!last) return;
|
|
3308
|
+
addCount(tally, signal, count);
|
|
3309
|
+
run.cursor[file] = last.endOffset;
|
|
3310
|
+
};
|
|
3311
|
+
for (const { route, records: batch } of routeBatches(records)) {
|
|
3312
|
+
const credential = await run.credentialFor(route, signal);
|
|
3313
|
+
if ("withhold" in credential) {
|
|
3314
|
+
consumePrefix(run.withheldBySignal, batch, batch.length);
|
|
3315
|
+
continue;
|
|
3316
|
+
}
|
|
3317
|
+
if ("missing" in credential) return { detail: `${signal} ${credential.missing}` };
|
|
3318
|
+
const bodies = serializeBatch(signal, batch.map((r) => r.record));
|
|
3319
|
+
const outcome = await postOtlpBodies({ url, headers: credential.headers, bodies: bodies.map((b) => b.bytes) });
|
|
3320
|
+
run.retriedSocketErrors += outcome.retriedSocketErrors ?? 0;
|
|
3321
|
+
const landed = outcome.delivered ? batch.length : recordsCarried(bodies.slice(0, outcome.deliveredPrefix));
|
|
3322
|
+
consumePrefix(run.shippedBySignal, batch, landed);
|
|
3323
|
+
if (!outcome.delivered) return postFailure(signal, outcome);
|
|
3324
|
+
}
|
|
3325
|
+
return void 0;
|
|
3326
|
+
}
|
|
3327
|
+
async function shipFile(run, { file, signal, start, aged }) {
|
|
3328
|
+
let read;
|
|
3329
|
+
try {
|
|
3330
|
+
read = readNewRecords(join(run.telemetryDir, file), start, signal, aged);
|
|
3331
|
+
} catch (error) {
|
|
3332
|
+
return { detail: `${signal} cannot read ${file}: ${shipperErrorDetail(error)}`, kind: shipperErrorKind(error) };
|
|
3333
|
+
}
|
|
3334
|
+
const { records, consumedEnd, discarded } = read;
|
|
3335
|
+
if (discarded > 0) addCount(run.discardedBySignal, signal, discarded);
|
|
3336
|
+
const failure = await shipRecords(run, file, signal, records);
|
|
3337
|
+
if (failure) return failure;
|
|
3338
|
+
if (records.length > 0 || discarded === 0 || aged) {
|
|
3339
|
+
run.cursor[file] = consumedEnd;
|
|
3340
|
+
return void 0;
|
|
3341
|
+
}
|
|
3342
|
+
return { detail: `${signal} ${discarded} unsendable record(s) in ${file}` };
|
|
3343
|
+
}
|
|
3344
|
+
function completedRunStatus(run) {
|
|
3345
|
+
const shipped = sumCounts(run.shippedBySignal);
|
|
3346
|
+
const perSignal = {
|
|
3347
|
+
shippedBySignal: run.shippedBySignal,
|
|
3348
|
+
...hasCounts(run.discardedBySignal) ? { discardedBySignal: run.discardedBySignal } : {},
|
|
3349
|
+
...hasCounts(run.withheldBySignal) ? { withheldBySignal: run.withheldBySignal } : {},
|
|
3350
|
+
retriedSocketErrors: run.retriedSocketErrors
|
|
3351
|
+
};
|
|
3352
|
+
return run.failure ? { outcome: "export-failed", shipped, detail: run.failure.detail, failureKind: run.failure.kind, ...perSignal } : { outcome: hasCounts(run.discardedBySignal) ? "ok-with-discards" : "ok", shipped, ...perSignal };
|
|
3353
|
+
}
|
|
3354
|
+
async function shipTelemetry(opts = {}) {
|
|
3355
|
+
const telemetryDir = opts.telemetryDir ?? TELEMETRY_DIR;
|
|
3356
|
+
const target = resolveShipTarget(opts, telemetryDir);
|
|
3357
|
+
if ("skipped" in target) return target;
|
|
3358
|
+
const credentialFor = createCredentialResolver(opts, target.overrideHeaders);
|
|
3359
|
+
const cursorPath2 = cursorPath(telemetryDir);
|
|
3360
|
+
const release = acquireShipperLock(telemetryDir, cursorPath2);
|
|
3361
|
+
if (!release) return { shipped: 0, skipped: "locked" };
|
|
3362
|
+
const run = {
|
|
3363
|
+
telemetryDir,
|
|
3364
|
+
endpoint: target.endpoint,
|
|
3365
|
+
credentialFor,
|
|
3366
|
+
cursor: {},
|
|
3367
|
+
shippedBySignal: {},
|
|
3368
|
+
discardedBySignal: {},
|
|
3369
|
+
withheldBySignal: {},
|
|
3370
|
+
retriedSocketErrors: 0
|
|
3371
|
+
};
|
|
3372
|
+
try {
|
|
3373
|
+
run.cursor = loadCursor(cursorPath2);
|
|
3374
|
+
const files = candidateFiles(telemetryDir, run.cursor);
|
|
3375
|
+
for (const candidate of files) {
|
|
3376
|
+
const fileFailure = await shipFile(run, candidate);
|
|
3377
|
+
run.failure ??= fileFailure;
|
|
3378
|
+
}
|
|
3379
|
+
saveCursor(cursorPath2, run.cursor, files);
|
|
3380
|
+
pruneGitCache(telemetryDir);
|
|
3381
|
+
pruneSessionState();
|
|
3382
|
+
recordShipperStatus(completedRunStatus(run), telemetryDir);
|
|
3383
|
+
} catch (error) {
|
|
3384
|
+
recordShipperStatus(
|
|
3385
|
+
{
|
|
3386
|
+
outcome: "crashed",
|
|
3387
|
+
shipped: sumCounts(run.shippedBySignal),
|
|
3388
|
+
shippedBySignal: run.shippedBySignal,
|
|
3389
|
+
detail: shipperErrorDetail(error)
|
|
3390
|
+
},
|
|
3391
|
+
telemetryDir
|
|
3392
|
+
);
|
|
3393
|
+
} finally {
|
|
3394
|
+
release();
|
|
3395
|
+
}
|
|
3396
|
+
return { shipped: sumCounts(run.shippedBySignal), skipped: null };
|
|
3397
|
+
}
|
|
3398
|
+
async function shipTelemetryWithAccountKeys() {
|
|
3399
|
+
return shipTelemetry({
|
|
3400
|
+
keyForRef: (s) => Promise.resolve(readMappedKey(s)),
|
|
3401
|
+
signedInSecretName: resolveKeySecretName()
|
|
3402
|
+
});
|
|
3403
|
+
}
|
|
3404
|
+
export {
|
|
3405
|
+
shipTelemetry,
|
|
3406
|
+
shipTelemetryWithAccountKeys
|
|
3407
|
+
};
|
|
3408
|
+
//# sourceMappingURL=span-shipper-4HQDHC47.js.map
|