AgentMark uses OpenTelemetry for collecting telemetry data. OpenTelemetry is an open-source observability framework that provides vendor-agnostic APIs, libraries, and instrumentation for collecting distributed traces and metrics.

Enabling Telemetry

Enable telemetry when calling runInference:

const result = await runInference(Prompt, props, {
  telemetry: {
    isEnabled: true,
    functionId: "calculate-price",
    metadata: {
      userId: "123",
      environment: "production"
    }
  }
});

Telemetry with Puzzlet

The easiest way to get started with observability is to use Puzzlet. Puzzlet automatically collects and visualizes telemetry data from your prompts:

import { Puzzlet } from "@puzzlet/sdk";

const puzzletClient = new Puzzlet({
  apiKey: process.env.PUZZLET_API_KEY!,
  appId: process.env.PUZZLET_APP_ID!
});

const result = await runInference(Prompt, props, { telemetry: { isEnabled: true } });

Collected Spans

AgentMark records the following span types:

Span TypeDescriptionAttributes
ai.inferenceFull length of the inference calloperation.name, ai.operationId, ai.prompt, ai.response.text, ai.response.toolCalls, ai.response.finishReason
ai.toolCallIndividual tool executionsoperation.name, ai.operationId, ai.toolCall.name, ai.toolCall.args, ai.toolCall.result
ai.streamStreaming response dataai.response.msToFirstChunk, ai.response.msToFinish, ai.response.avgCompletionTokensPerSecond

Basic LLM Span Information

Each LLM span contains:

AttributeDescription
ai.model.idModel identifier
ai.model.providerModel provider name
ai.usage.promptTokensNumber of prompt tokens
ai.usage.completionTokensNumber of completion tokens
ai.settings.maxRetriesMaximum retry attempts
ai.telemetry.functionIdFunction identifier
ai.telemetry.metadata.*Custom metadata

Custom OpenTelemetry Setup

For custom OpenTelemetry configuration:

import { NodeSDK } from '@opentelemetry/sdk-node';
import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node';

const sdk = new NodeSDK({
  traceExporter: new ConsoleSpanExporter(),
  serviceName: 'my-agentmark-app',
});

sdk.start();

Best Practices

  1. Enable telemetry in production environments
  2. Use meaningful function IDs
  3. Include relevant metadata for debugging
  4. Monitor token usage and costs

Learn More

Have Questions?

We’re here to help! Choose the best way to reach us: