Skip to content

Commit

Permalink
feat: track spans (#7129)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr authored Jun 25, 2024
1 parent 1d29708 commit 924c3f8
Show file tree
Hide file tree
Showing 66 changed files with 981 additions and 207 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
"rushstack",
"schnorr",
"secp",
"SEMRESATTRS",
"sigchld",
"Signerless",
"siloes",
Expand Down
23 changes: 19 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ services:
P2P_ENABLED: true
PEER_ID_PRIVATE_KEY:
AZTEC_PORT: 8999
OTEL_COLLECTOR_BASE_URL: ${OTEL_COLLECTOR_BASE_URL:-http://otel-collector:4318}
TEL_COLLECTOR_BASE_URL: ${TEL_COLLECTOR_BASE_URL:-http://otel-collector:4318}
secrets:
- ethereum-host
- p2p-boot-node
Expand All @@ -76,13 +76,13 @@ services:
# if the stack is started with --profile metrics --profile node, give the collector a chance to start before the node
i=0
max=3
while ! curl --head --silent $$OTEL_COLLECTOR_BASE_URL > /dev/null; do
while ! curl --head --silent $$TEL_COLLECTOR_BASE_URL > /dev/null; do
echo "OpenTelemetry collector not up. Retrying after 1s";
sleep 1;
i=$$((i+1));
if [ $$i -eq $$max ]; then
echo "OpenTelemetry collector at $$OTEL_COLLECTOR_BASE_URL not up after $${max}s. Running without metrics";
unset OTEL_COLLECTOR_BASE_URL;
echo "OpenTelemetry collector at $$TEL_COLLECTOR_BASE_URL not up after $${max}s. Running without metrics";
unset TEL_COLLECTOR_BASE_URL;
break
fi;
done;
Expand Down Expand Up @@ -143,6 +143,13 @@ services:
- source: grafana-sources
target: /etc/grafana/provisioning/datasources/default.yml

jaeger:
image: jaegertracing/all-in-one
ports:
- 16686:16686
profiles:
- metrics

volumes:
aztec:
grafana:
Expand Down Expand Up @@ -187,9 +194,17 @@ configs:
prometheus:
endpoint: 0.0.0.0:8889
metric_expiration: 5m
otlp/jaeger:
endpoint: "jaeger:4317"
tls:
insecure: true
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp/jaeger]
metrics:
receivers: [otlp]
processors: [batch]
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@
"rootDir": "./src",
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
}
}
}
]
},
"extensionsToTreatAsEsm": [
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@
"workerThreads": true,
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
}
}
}
]
},
"extensionsToTreatAsEsm": [
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/aztec-faucet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
"rootDir": "./src",
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
}
}
}
]
},
"extensionsToTreatAsEsm": [
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/aztec-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@
"rootDir": "./src",
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
}
}
}
]
},
"extensionsToTreatAsEsm": [
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export class AztecNodeService implements AztecNode {
archiver,
prover!,
simulationProvider,
telemetry,
);

return new AztecNodeService(
Expand Down Expand Up @@ -763,6 +764,7 @@ export class AztecNodeService implements AztecNode {
merkleTrees.asLatest(),
this.contractDataSource,
new WASMSimulator(),
this.telemetry,
);
const processor = await publicProcessorFactory.create(prevHeader, newGlobalVariables);
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/aztec.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@
"rootDir": "./src",
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
}
}
}
]
},
"extensionsToTreatAsEsm": [
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/aztec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@
"rootDir": "./src",
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
}
}
}
]
},
"extensionsToTreatAsEsm": [
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const startArchiver = async (options: any, signalHandlers: (() => Promise
);
const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);

const telemetry = createAndStartTelemetryClient(getTelemetryClientConfig(), 'aztec-archiver');
const telemetry = createAndStartTelemetryClient(getTelemetryClientConfig());
const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, telemetry, true);
const archiverServer = createArchiverRpcServer(archiver);
services.push({ archiver: archiverServer });
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const startNode = async (
}

// Create and start Aztec Node.
const telemetryClient = createAndStartTelemetryClient(getTelemetryClientConfig(), 'aztec-node');
const telemetryClient = createAndStartTelemetryClient(getTelemetryClientConfig());
const node = await createAztecNode(telemetryClient, nodeConfig);
const nodeServer = createAztecNodeRpcServer(node);

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const startProver: ServiceStarter = async (options, signalHandlers, logge
? parseInt(proverOptions.proverAgentPollInterval, 10)
: proverOptions.proverAgentPollInterval;

const telemetry = createAndStartTelemetryClient(getTelemetryClientConfig(), 'aztec-prover');
const telemetry = createAndStartTelemetryClient(getTelemetryClientConfig());
let circuitProver: ServerCircuitProver;
if (proverOptions.realProofs) {
if (!proverOptions.acvmBinaryPath || !proverOptions.bbBinaryPath) {
Expand Down
10 changes: 9 additions & 1 deletion yarn-project/bb-prover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@
"rootDir": "./src",
"transform": {
"^.+\\.tsx?$": [
"@swc/jest"
"@swc/jest",
{
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
}
}
}
]
},
"extensionsToTreatAsEsm": [
Expand Down
5 changes: 5 additions & 0 deletions yarn-project/bb-prover/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type Histogram,
Metrics,
type TelemetryClient,
type Tracer,
ValueType,
} from '@aztec/telemetry-client';

Expand All @@ -24,8 +25,12 @@ export class ProverInstrumentation {
private circuitSize: Gauge;
private circuitPublicInputCount: Gauge;

public readonly tracer: Tracer;

constructor(telemetry: TelemetryClient, name: string) {
this.tracer = telemetry.getTracer(name);
const meter = telemetry.getMeter(name);

this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION, {
description: 'Records how long it takes to simulate a circuit',
unit: 's',
Expand Down
16 changes: 15 additions & 1 deletion yarn-project/bb-prover/src/prover/bb_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
convertRootRollupOutputsFromWitnessMap,
} from '@aztec/noir-protocol-circuits-types';
import { NativeACVMSimulator } from '@aztec/simulator';
import { type TelemetryClient } from '@aztec/telemetry-client';
import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-client';

import { abiEncode } from '@noir-lang/noirc_abi';
import { type Abi, type WitnessMap } from '@noir-lang/types';
Expand Down Expand Up @@ -111,6 +111,10 @@ export class BBNativeRollupProver implements ServerCircuitProver {
this.instrumentation = new ProverInstrumentation(telemetry, 'BBNativeRollupProver');
}

get tracer() {
return this.instrumentation.tracer;
}

static async new(config: BBProverConfig, telemetry: TelemetryClient) {
await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
await fs.mkdir(config.acvmWorkingDirectory, { recursive: true });
Expand All @@ -127,6 +131,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
* @param inputs - Inputs to the circuit.
* @returns The public inputs of the parity circuit.
*/
@trackSpan('BBNativeRollupProver.getBaseParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'base-parity' })
public async getBaseParityProof(inputs: BaseParityInputs): Promise<RootParityInput<typeof RECURSIVE_PROOF_LENGTH>> {
const { circuitOutput, proof } = await this.createRecursiveProof(
inputs,
Expand All @@ -148,6 +153,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
* @param inputs - Inputs to the circuit.
* @returns The public inputs of the parity circuit.
*/
@trackSpan('BBNativeRollupProver.getRootParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'root-parity' })
public async getRootParityProof(
inputs: RootParityInputs,
): Promise<RootParityInput<typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
Expand All @@ -171,6 +177,9 @@ export class BBNativeRollupProver implements ServerCircuitProver {
* @param inputs - The inputs to the AVM circuit.
* @returns The proof.
*/
@trackSpan('BBNativeRollupProver.getAvmProof', inputs => ({
[Attributes.APP_CIRCUIT_NAME]: inputs.functionName,
}))
public async getAvmProof(inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey> {
const proofAndVk = await this.createAvmProof(inputs);
await this.verifyAvmProof(proofAndVk.proof, proofAndVk.verificationKey);
Expand All @@ -182,6 +191,11 @@ export class BBNativeRollupProver implements ServerCircuitProver {
* @param kernelRequest - The object encapsulating the request for a proof
* @returns The requested circuit's public inputs and proof
*/
@trackSpan('BBNativeRollupProver.getPublicKernelProof', kernelReq => ({
[Attributes.PROTOCOL_CIRCUIT_NAME]: mapProtocolArtifactNameToCircuitName(
PublicKernelArtifactMapping[kernelReq.type]!.artifact,
),
}))
public async getPublicKernelProof(
kernelRequest: PublicKernelNonTailRequest,
): Promise<PublicInputsAndRecursiveProof<PublicKernelCircuitPublicInputs>> {
Expand Down
16 changes: 1 addition & 15 deletions yarn-project/bb-prover/src/stats.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import { type PublicKernelRequest, PublicKernelType } from '@aztec/circuit-types';
import type { CircuitName } from '@aztec/circuit-types/stats';
import { type ClientProtocolArtifact, type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types';

export function mapPublicKernelToCircuitName(kernelType: PublicKernelRequest['type']): CircuitName {
switch (kernelType) {
case PublicKernelType.SETUP:
return 'public-kernel-setup';
case PublicKernelType.APP_LOGIC:
return 'public-kernel-app-logic';
case PublicKernelType.TEARDOWN:
return 'public-kernel-teardown';
case PublicKernelType.TAIL:
return 'public-kernel-tail';
default:
throw new Error(`Unknown kernel type: ${kernelType}`);
}
}
export { mapPublicKernelToCircuitName } from '@aztec/circuit-types';

export function mapProtocolArtifactNameToCircuitName(
artifact: ServerProtocolArtifact | ClientProtocolArtifact,
Expand Down
Loading

0 comments on commit 924c3f8

Please sign in to comment.