Automatic Instrumentation
Our specialized compiler provides a way to automatically instrument pre-compiled Wasm code. It will be offered as a free service while the Observe SDK is in preview to help teams quickly add observability to their WebAssembly applications.
Using our
automatic instrumentation tools, you can
take a compiled Wasm module (.wasm
binary) and have it fully instrumented for
function and memory allocation tracing. This will provide a detailed trace of
all activity in your code. We recommend this for debugging your own code, as
well as tracing Wasm modules that you didn't compile (and thus don't have the
source code).
Automatic instrumentation focuses on tracing only, but this could be expanded in the future.
NOTE: support for the Component Model is coming soon. Please reach out to us if this is something you need (support@dylibso.com).
Usage
Once you have an API Key, you can use the instrumentation service:
curl --fail -F wasm=@code.wasm -H "Authorization: Bearer $API_KEY" \
https://compiler-preview.dylibso.com/instrument > code.instr.wasm
Options and Adapter Configuration
Automatic instrumentation may provide more information than you want for everyday monitoring. If so, each Adapter can be configured to reduce the amount of spans emitted. For now, the only option is to filter out spans whose duration is below a configured threshold. For example:
- Rust
- JavaScript
- Go
// Filter out spans that are shorter than 10 microseconds. DEFAULT = 20us.
let options = Options {
span_filter: SpanFilter {
min_duration_microseconds: std::time::Duration::from_micros(10),
},
};
let trace_ctx = adapter.start(&mut linker, &data, options)?;
// Filter out spans that are shorter than 10 microseconds. DEFAULT = 20us.
const traceContext = await adapter.start(bytes, {
spanFilter: {
minDurationMicroseconds: 10,
},
});
// Filter out spans that are shorter than 10 microseconds. DEFAULT = 20us.
options := Options{
SpanFilter: &SpanFilter{
MinDuration: time.Microsecond * 10,
},
}
traceCtx, err := adapter.NewTraceCtx(ctx, rt, wasm, &options)
if err != nil {
log.Println(err)
}
Configuring the Automatic Instrumentation
To reduce the amount of tracing through the instrumentation service, you can configure a compilation pass to allow explicit functions to be traced, or ban others from being traced. To do this, use a JSON object in the following form:
{
"allowed": ["foo", "bar", "baz"]
}
OR
{
"banned": ["__cxx_goop", "count_vowels"]
}
NOTE: only use one key:
allowed
ORbanned
, in your configuration.
This JSON configuration can be passed to the instrumentation service request via
a multipart form field config
, for example:
curl --fail -F wasm=@code.wasm -F config=@config.json \
-H "Authorization: Bearer $API_KEY" \
https://compiler-preview.dylibso.com/instrument > code.instr.wasm
Or entirely inline:
curl --fail -F wasm=@code.wasm -F config='{"allowed": ["foo", "bar"]}' \
-H "Authorization: Bearer $API_KEY" \
https://compiler-preview.dylibso.com/instrument > code.instr.wasm
Support & Self-Hosting
If you're looking for additional help or would like hands-on support, we're happy to be of service. We also are able to provide you with your own offline or self-hosted version of our automatic instrumentation tools so you can run everything in your own network.
Please reach out to support@dylibso.com for more information.
Additionally, visit the GitHub Discussion page for general Q&A about the Observe SDK and related products.