Send Spans Manually
- Allows you to send data that doesn't normally get sent (done manually)
"Span"
is the name of the data structure representing an interesting operation in your app.
Aspecto will automatically collect spans for operations created by popular packages that perform IO (such as http, messaging systems, databases, etc).
Manual spans are used if you need to trace an operation in a code you wrote, or when using a package that does not provide an automatic tracing.
To create a Manual Span for a function run, you need to wrap it in a trace
call like this:
All options are optional. If you don't need to provide options, you can omit the options parameter and just call:
Metadata
You can attach custom metadata to each operation which will be visible and searchable in the Aspecto app. Metadata is a list of key-value pairs, where the key is a string in the format: example.for.key
and a value which can be any primitive or JSON.stringified
object.
You can set metadata when starting a trace:
Or add it while executing the traced function by using the span
object:
Async Functions
If your traced function is async or returns a promise, the operation duration and success status will be calculated based on this promise result:
For callback syntax, you can use the done
function to report end of the operation and success status:
Or to report an error in the operation:
Last updated