| Telemetry | R Documentation |
R6 class for logging events in a structured format (JSON).
trace_idCurrent trace ID for the session.
eventsCollected telemetry events for in-memory inspection.
emitLogical; when TRUE, events are printed as JSON lines.
pricing_tablePricing for common models (USD per 1M tokens).
new()Initialize Telemetry
Telemetry$new(trace_id = NULL, emit = TRUE)
trace_idOptional trace ID. If NULL, generates a random one.
emitLogical; when TRUE, events are printed as JSON lines.
log_event()Log an event
Telemetry$log_event(type, ...)
typeEvent type (e.g., "generation_start", "tool_call").
...Additional fields to log.
get_events()Return collected telemetry events.
Telemetry$get_events()
A list of event payloads.
clear_events()Clear collected telemetry events.
Telemetry$clear_events()
Invisibly returns self.
as_hooks()Create hooks for telemetry
Telemetry$as_hooks()
A HookHandler object pre-configured with telemetry logs.
calculate_cost()Calculate estimated cost for a generation result
Telemetry$calculate_cost(result, model_id = NULL)
resultThe GenerateResult object.
model_idOptional model ID string. if NULL, tries to guess from context (not reliable yet, passing in log_event might be better).
Estimated cost in USD, or NULL if unknown.
clone()The objects of this class are cloneable with this method.
Telemetry$clone(deep = FALSE)
deepWhether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.