You typically don’t instantiate
Trace directly. Use client.trace() instead.Methods
addAttribute()
Add a single attribute to the trace.Parameters
Examples
addAttributes()
Add multiple attributes at once.Parameters
Examples
addTag()
Add a single tag to the trace.Parameters
Examples
addTags()
Add multiple tags at once.Parameters
Examples
addEvent()
Add a timestamped event to the trace.Parameters
AddEventOptions
Examples
Convenience methods:
trace.info(), trace.warn(), and trace.error() are shortcuts for addEvent() with a severity field. See below.info() / warn() / error()
Convenience methods for adding events with severity. These are shortcuts foraddEvent() that include a severity field in the event details.
Examples
getTraceId()
Get the trace ID. In v2, trace IDs are generated client-side at creation time as W3C Tracing Context compatible 32-character hex strings. The ID is available immediately — no need to wait for the server response.Returns
string- The trace ID (always available immediately after trace creation)
Examples
startSpan()
Open a span — a timed, nestable unit of work within the trace. Returns aSpan handle; call span.end() to close it.
Parameters
SpanOptions
Examples
span()
Run a function inside a span that ends automatically — statusOK when it returns, or ERROR (plus the error message) when it throws. Works with sync and async functions and returns the function’s result. The span is passed to the callback for precise event nesting.
Parameters
Examples
web3 (Plugin Namespace)
When theWeb3Plugin is enabled, blockchain methods are available under the web3 namespace. These methods require the plugin to be configured on the client.
These methods are only available when
Web3Plugin is enabled. See Plugins for setup.web3.evm.addTxHint()
Add a blockchain transaction hash hint.web3.evm.addTxInputData()
Add transaction input data (calldata) as a trace event.web3.evm.addTx()
Add a transaction hint from a transaction-like object. Automatically extracts the hash, input data, and chain.web3.evm.sendTransaction()
Send a transaction through the plugin’s provider, automatically capturing tx hints and error data.web3.safe.addMsgHint()
Add a Safe multisig message hint. See Safe Multisig for usage details.web3.safe.addTxHint()
Add a Safe multisig transaction hint. See Safe Multisig for usage details.flush()
Send pending data to the gateway. Available in both the Web SDK and Node.js SDK.FlushTrace requests. The gateway handles idempotent upserts — there is no distinction between create and update on the wire.
Builder methods automatically schedule a flush via microtask, batching all synchronous calls within the same JS tick into a single network request. You can also call flush() manually to send immediately.
flush() is fire-and-forget. It returns immediately but maintains strict ordering of requests internally.Examples
addStackTrace()
Capture and add the current stack trace as an event.Parameters
Examples
addExistingStackTrace()
Add a previously captured stack trace as an event.Parameters
Examples
startKeepAlive()
Manually start the keep-alive timer. This is useful when you setautoKeepAlive: false but later decide the trace needs to stay alive.
Examples
stopKeepAlive()
Manually stop the keep-alive timer without closing the trace. Useful when you want to pause keep-alive pings but continue adding data to the trace.Examples
close()
Close the trace, drain the flush queue, run plugin cleanup, and stop all timers. After calling this method, all subsequent operations will be ignored.Parameters
Examples
Once a trace is closed, all method calls will be ignored with a warning. The keep-alive timer will be stopped, plugins will be cleaned up, and a close request will be sent to the server.
isClosed()
Check if the trace has been closed.Returns
boolean-trueif the trace has been closed,falseotherwise
Examples
Method Chaining
All builder methods returnthis, enabling fluent chaining:
Lifecycle
Both SDKs share the same auto-flush pattern: builder methods schedule a microtask that batches and sends data automatically. All flushes use the idempotentFlushTrace RPC.
Next Steps
Types
TypeScript type definitions
Examples
See complete usage examples