Skip to content

Commit 4099eac

Browse files
authored
chore: lazy otel init (#18861)
As title. A push to fix cli startup times. This is one of several import granularization efforts. At the end of it all we can at least print the cli help in 0.5s. I propose the following: * We **remove barrel imports**. So no more `index.ts` that's just a list of `export * from 'foo'`. * In any project, there are files that are deemed part of the public api (they were exported directly or indirectly via the barrel import), and there are files that are not deemed part of the public api. * Any file that is deemed part of the public api is exported directly through the `package.json` `export` api. If it's good enough to be exported through a barrel, it's good enough to have it's own export on the package. * This will make it *explicit and clear* what we're presenting as the packages public api. * It makes it easier to trivially time the importation of each entrypoint for debugging slow stuff. * It makes it easier to see messy apis and take action to clean them up.
2 parents 1347f11 + e0d539b commit 4099eac

File tree

17 files changed

+26
-24
lines changed

17 files changed

+26
-24
lines changed

yarn-project/aztec/src/cli/cmds/start_archiver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function startArchiver(
5151
const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
5252
const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
5353

54-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
54+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
5555
const blobSinkClient = createBlobSinkClient(archiverConfig, { logger: createLogger('archiver:blob-sink:client') });
5656
const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, { telemetry, blobSinkClient }, true);
5757
services.archiver = [archiver, ArchiverApiSchema];

yarn-project/aztec/src/cli/cmds/start_blob_sink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function startBlobSink(options: any, signalHandlers: (() => Promise
3535
throw new Error('L1_CHAIN_ID');
3636
}
3737

38-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
38+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
3939

4040
const { config: chainConfig, addresses } = await getL1Config(
4141
blobSinkConfig.l1Contracts.registryAddress,

yarn-project/aztec/src/cli/cmds/start_bot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function startBot(
4040
const pxeConfig = extractRelevantOptions<PXEConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
4141
const wallet = await TestWallet.create(aztecNode, pxeConfig);
4242

43-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
43+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
4444
await addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, undefined);
4545
}
4646

yarn-project/aztec/src/cli/cmds/start_node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export async function startNode(
117117
}
118118

119119
const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
120-
const telemetry = initTelemetryClient(telemetryConfig);
120+
const telemetry = await initTelemetryClient(telemetryConfig);
121121

122122
// Create and start Aztec Node
123123
const node = await createAztecNode(nodeConfig, { telemetry }, { prefilledPublicData });

yarn-project/aztec/src/cli/cmds/start_p2p_bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function startP2PBootstrap(
2525
userLog(`Starting P2P bootstrap node with config: ${jsonStringify(safeConfig)}`);
2626

2727
const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
28-
const telemetryClient = initTelemetryClient(telemetryConfig);
28+
const telemetryClient = await initTelemetryClient(telemetryConfig);
2929

3030
const store = await createStore('p2p-bootstrap', 1, config, createLogger('p2p:bootstrap:store'));
3131
const node = new BootstrapNode(store, telemetryClient);

yarn-project/aztec/src/cli/cmds/start_prover_agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function startProverAgent(
5353
);
5454
const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
5555

56-
const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
56+
const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
5757
const prover = await buildServerCircuitProver(config, telemetry);
5858
const proofStore = new InlineProofStore();
5959
const agents = times(

yarn-project/aztec/src/cli/cmds/start_prover_broker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function startProverBroker(
4545
config.l1Contracts = addresses;
4646
config.rollupVersion = rollupConfig.rollupVersion;
4747

48-
const client = initTelemetryClient(getTelemetryClientConfig());
48+
const client = await initTelemetryClient(getTelemetryClientConfig());
4949
const broker = await createAndStartProvingBroker(config, client);
5050

5151
if (options.autoUpdate !== 'disabled' && options.autoUpdateUrl) {

yarn-project/aztec/src/cli/cmds/start_prover_node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export async function startProverNode(
6767
);
6868
}
6969

70-
const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
70+
const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
7171

7272
let broker: ProvingJobBroker;
7373
if (proverConfig.proverBrokerUrl) {

yarn-project/aztec/src/cli/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import type { ConfigMappingsType } from '@aztec/foundation/config';
77
import { type LogFn, createLogger } from '@aztec/foundation/log';
88
import type { SharedNodeConfig } from '@aztec/node-lib/config';
99
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
10-
import { UpdateChecker } from '@aztec/stdlib/update-checker';
11-
import { getTelemetryClient } from '@aztec/telemetry-client';
10+
import { getTelemetryClient } from '@aztec/telemetry-client/start';
1211
import type { TestWallet } from '@aztec/test-wallet/server';
1312

1413
import chalk from 'chalk';
@@ -312,6 +311,7 @@ export async function setupUpdateMonitor(
312311
updateNodeConfig?: (config: object) => Promise<void>,
313312
) {
314313
const logger = createLogger('update-check');
314+
const { UpdateChecker } = await import('@aztec/stdlib/update-checker');
315315
const checker = await UpdateChecker.new({
316316
baseURL: updatesLocation,
317317
publicClient,

yarn-project/aztec/src/local-network/local-network.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
181181
await watcher.start();
182182
}
183183

184-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
184+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
185185
// Create a local blob sink client inside the local network, no http connectivity
186186
const blobSinkClient = createBlobSinkClient();
187187
const node = await createAztecNode(

0 commit comments

Comments
 (0)