Basic Features
Metadata
4 min
traces and observations (see abv data model https //docs abv dev/observability data model ) can be enriched with metadata to better understand your users, application, and experiments metadata can be added to traces in the form of arbitrary json metadata updates are merged based on the top level key we strongly discourage writing the same key multiple times within your instrumentation implementation with python sdk when using the @observe() decorator from abvdev import observe, get client abv = get client() @observe() def process data() \# access the client and update the current trace metadata \# add metadata to the trace level abv update current trace( metadata={"source" "api", "version" "1 2 3"} ) \# add metadata to the current span level abv update current span( metadata={"processing stage" "initial"} ) \# process data return result when creating spans directly from abvdev import get client abv = get client() \# add metadata at trace level with abv start as current span( name="process request" ) as root span \# add metadata to the trace root span update trace(metadata={"request id" "req 12345"}) \# add metadata to the current span root span update(metadata={"stage" "parsing"}) \# create a child span with metadata with root span start as current generation( name="generate response", model="gpt 4o", metadata={"temperature" 0 7, "max tokens" 1000} ) as gen \# update metadata later if needed gen update(metadata={"completion type" "creative"}) you can add new keys to the metadata object by continuously updating the entity we strongly discourage writing the same top level key multiple times as this will produce an undefined behaviour with abv start as current span(name="operation") as span \# first write span update(metadata={"status" "started"}) \# additional key will be merged with previous metadata span update(metadata={"error" "failed to process"}) \# final metadata will be {"status" "started", "error" "failed to process"} implementation with js/ts sdk when using the context manager import { startactiveobservation, startobservation, updateactivetrace, } from "@abvdev/tracing"; await startactiveobservation("context manager", async (span) => { // observation metadata span update({ input { query "what is the capital of france?" }, }); updateactivetrace({ metadata { key "value" }, }); }); when using the observe wrapper import { observe, updateactivetrace } from "@abvdev/tracing"; // an existing function async function fetchdata(source string) { // observation metadata updateactivetrace({ metadata { key "value" }, }); // trace metadata updateactivetrace({ metadata { key "value" }, }); // logic to fetch data return { data `some data from ${source}` }; } // wrap the function to trace it const tracedfetchdata = observe(fetchdata, { name "observe wrapper", }); const result = await tracedfetchdata("api"); when creating spans manually import { startobservation } from "@abvdev/tracing"; const span = startobservation("manual observation", { input { query "what is the capital of france?" }, metadata { key "value" }, }); span updatetrace({ metadata { key "value" }, }); span update({ output "paris" }) end(); see typescript sdk overview docid\ j4sdnlmdmnfmk99ootgn7 for more details