From 136f56db990d4f8c3894d57fbc74aeb7cb2a6ba8 Mon Sep 17 00:00:00 2001 From: Mathieu Hofman Date: Fri, 24 Feb 2023 15:31:32 +0000 Subject: [PATCH] refactor(telemetry): move shutdown helper to internal --- packages/internal/package.json | 1 + packages/{telemetry/src => internal/src/node}/shutdown.js | 2 +- packages/solo/src/pipe-entrypoint.js | 2 +- packages/solo/src/pipe.js | 2 +- packages/solo/src/start.js | 2 +- packages/telemetry/src/otel-trace.js | 2 +- packages/telemetry/src/slog-sender-pipe-entrypoint.js | 2 +- packages/telemetry/src/slog-sender-pipe.js | 2 +- 8 files changed, 8 insertions(+), 7 deletions(-) rename packages/{telemetry/src => internal/src/node}/shutdown.js (98%) diff --git a/packages/internal/package.json b/packages/internal/package.json index 3c043b11c907..1b03579c6e82 100755 --- a/packages/internal/package.json +++ b/packages/internal/package.json @@ -24,6 +24,7 @@ "@endo/far": "^0.2.14", "@endo/marshal": "^0.8.1", "@endo/promise-kit": "^0.2.52", + "anylogger": "^0.21.0", "jessie.js": "^0.3.2" }, "devDependencies": { diff --git a/packages/telemetry/src/shutdown.js b/packages/internal/src/node/shutdown.js similarity index 98% rename from packages/telemetry/src/shutdown.js rename to packages/internal/src/node/shutdown.js index 8cf5cd6cfd8b..06ae0c5057d6 100644 --- a/packages/telemetry/src/shutdown.js +++ b/packages/internal/src/node/shutdown.js @@ -1,4 +1,4 @@ -/* global process */ +import process from 'node:process'; import anylogger from 'anylogger'; const console = anylogger('shutdown'); diff --git a/packages/solo/src/pipe-entrypoint.js b/packages/solo/src/pipe-entrypoint.js index 16c9d7fc9d68..e03c0b9ac556 100644 --- a/packages/solo/src/pipe-entrypoint.js +++ b/packages/solo/src/pipe-entrypoint.js @@ -8,7 +8,7 @@ import { makePromiseKit } from '@endo/promise-kit'; import '@agoric/cosmic-swingset/src/anylogger-agoric.js'; import { connectToFakeChain } from '@agoric/cosmic-swingset/src/sim-chain.js'; -import { makeShutdown } from '@agoric/telemetry/src/shutdown.js'; +import { makeShutdown } from '@agoric/internal/src/node/shutdown.js'; const { registerShutdown } = makeShutdown(false); registerShutdown(() => process.exit()); diff --git a/packages/solo/src/pipe.js b/packages/solo/src/pipe.js index 371cd622b0b6..4a743e4144e1 100644 --- a/packages/solo/src/pipe.js +++ b/packages/solo/src/pipe.js @@ -5,7 +5,7 @@ import path from 'path'; import { makePromiseKit } from '@endo/promise-kit'; import { parse, stringify } from '@endo/marshal'; -import { makeShutdown } from '@agoric/telemetry/src/shutdown.js'; +import { makeShutdown } from '@agoric/internal/src/node/shutdown.js'; const filename = new URL(import.meta.url).pathname; const dirname = path.dirname(filename); diff --git a/packages/solo/src/start.js b/packages/solo/src/start.js index 9c01198d0d01..81d13102d2cd 100644 --- a/packages/solo/src/start.js +++ b/packages/solo/src/start.js @@ -31,7 +31,7 @@ import { } from '@agoric/swingset-vat'; import { openSwingStore } from '@agoric/swing-store'; import { makeWithQueue } from '@agoric/internal/src/queue.js'; -import { makeShutdown } from '@agoric/telemetry/src/shutdown.js'; +import { makeShutdown } from '@agoric/internal/src/node/shutdown.js'; import { makeDefaultMeterProvider, getTelemetryProviders, diff --git a/packages/telemetry/src/otel-trace.js b/packages/telemetry/src/otel-trace.js index feabede72553..3866333d13ed 100644 --- a/packages/telemetry/src/otel-trace.js +++ b/packages/telemetry/src/otel-trace.js @@ -6,10 +6,10 @@ import { import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; import { Resource } from '@opentelemetry/resources'; +import { makeShutdown } from '@agoric/internal/src/node/shutdown.js'; import { getResourceAttributes } from './index.js'; import { makeSlogToOtelKit } from './slog-to-otel.js'; -import { makeShutdown } from './shutdown.js'; // These numbers are chosen to attempt to export all spans. export const SPAN_MAX_QUEUE_SIZE = 100_000; diff --git a/packages/telemetry/src/slog-sender-pipe-entrypoint.js b/packages/telemetry/src/slog-sender-pipe-entrypoint.js index a5fc05c88c78..a8f9348addf7 100644 --- a/packages/telemetry/src/slog-sender-pipe-entrypoint.js +++ b/packages/telemetry/src/slog-sender-pipe-entrypoint.js @@ -3,7 +3,7 @@ import '@endo/init'; import { makeAggregateError } from '@agoric/internal'; import anylogger from 'anylogger'; -import { makeShutdown } from './shutdown.js'; +import { makeShutdown } from '@agoric/internal/src/node/shutdown.js'; import { makeSlogSender } from './make-slog-sender.js'; diff --git a/packages/telemetry/src/slog-sender-pipe.js b/packages/telemetry/src/slog-sender-pipe.js index be22bb3611e2..15a1d10e6981 100644 --- a/packages/telemetry/src/slog-sender-pipe.js +++ b/packages/telemetry/src/slog-sender-pipe.js @@ -4,7 +4,7 @@ import anylogger from 'anylogger'; import { makeQueue } from '@endo/stream'; -import { makeShutdown } from './shutdown.js'; +import { makeShutdown } from '@agoric/internal/src/node/shutdown.js'; const filename = new URL(import.meta.url).pathname; const dirname = path.dirname(filename);