-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Trace propagation from json rpc client to server (#11325)
Uses otel's `propagate` API to push the current trace from the json rpc client to server using http headers. Client is instrumented by wrapping the `fetch` function so it creates a new span and creates the headers, and the server is instrumented by injecting new middleware that captures the headers and starts a new span for the scope of the request. Fixes #11185 Fixes #11223 Cherry-picks work by @alexghr from #11222 ### Example run Note that `traceId` is the same in both processes. Bot with pxe logs: ``` [20:08:54.763] INFO: pxe:service Sent transaction 0x125eb560f33f44a28b98f0f065197eed8a8557bcb1ab2659eb34e5be0b33a9b4 {"trace_id":"d1143080037e46c037dea7cbdf8e29d6","span_id":"236692ffb270ecb4","trace_flags":"01"} [20:08:54.763] INFO: bot Sent tx with hash 0x125eb560f33f44a28b98f0f065197eed8a8557bcb1ab2659eb34e5be0b33a9b4 {"trace_id":"d1143080037e46c037dea7cbdf8e29d6","span_id":"236692ffb270ecb4","trace_flags":"01"} ``` Node logs: ``` [20:08:54.762] INFO: node Received tx 0x125eb560f33f44a28b98f0f065197eed8a8557bcb1ab2659eb34e5be0b33a9b4 {"txHash":"0x125eb560f33f44a28b98f0f065197eed8a8557bcb1ab2659eb34e5be0b33a9b4","trace_id":"d1143080037e46c037dea7cbdf8e29d6","span_id":"5d1b907122754832","trace_flags":"01"} ``` --------- Co-authored-by: Alex Gherghisan <[email protected]>
- Loading branch information
1 parent
046968f
commit 85ccc15
Showing
24 changed files
with
224 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { type ArchiverApi, ArchiverApiSchema } from '@aztec/circuit-types'; | ||
import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client'; | ||
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server'; | ||
import { createSafeJsonRpcClient } from '@aztec/foundation/json-rpc/client'; | ||
import { createTracedJsonRpcServer, makeTracedFetch } from '@aztec/telemetry-client'; | ||
|
||
export function createArchiverClient(url: string, fetch = makeFetch([1, 2, 3], true)): ArchiverApi { | ||
export function createArchiverClient(url: string, fetch = makeTracedFetch([1, 2, 3], true)): ArchiverApi { | ||
return createSafeJsonRpcClient<ArchiverApi>(url, ArchiverApiSchema, false, 'archiver', fetch); | ||
} | ||
|
||
export function createArchiverRpcServer(handler: ArchiverApi) { | ||
return createSafeJsonRpcServer(handler, ArchiverApiSchema); | ||
return createTracedJsonRpcServer(handler, ArchiverApiSchema); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { type AztecNode, AztecNodeApiSchema } from '@aztec/circuit-types'; | ||
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server'; | ||
import { createTracedJsonRpcServer } from '@aztec/telemetry-client'; | ||
|
||
/** | ||
* Wrap an AztecNode instance with a JSON RPC HTTP server. | ||
* @param node - The AztecNode | ||
* @returns An JSON-RPC HTTP server | ||
*/ | ||
export function createAztecNodeRpcServer(node: AztecNode) { | ||
return createSafeJsonRpcServer(node, AztecNodeApiSchema); | ||
return createTracedJsonRpcServer(node, AztecNodeApiSchema); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.