Quickstart
Send a trace to telemetry.dev with TypeScript or Python in five minutes.
These examples record an offline sample. You do not need a model-provider key.
Make a project and API key
Open telemetry.dev. Make a project, then copy the API key from the project setup page.
A new project includes a default key. The dashboard shows the full key one time, and keys start with td_live_.
Install an SDK
npm i @telemetry-dev/sdkpip install telemetry-devInitialize and record a trace
Put the API key and resource values in your environment:
TELEMETRY_DEV_API_KEY=td_live_...
TELEMETRY_DEV_ENVIRONMENT=development
OTEL_SERVICE_NAME=quickstartSave one example as quickstart.ts or quickstart.py:
import {
flush,
init,
observe,
shutdown,
startSpan,
} from "@telemetry-dev/sdk";
init();
const answer = observe(
function answer(question: string) {
const generation = startSpan("chat gpt-4", {
type: "generation",
model: "gpt-4",
provider: "openai",
input: [{ role: "user", content: question }],
});
generation.end({
output: [{ role: "assistant", content: "Take the scenic route." }],
usage: { inputTokens: 11, outputTokens: 7 },
finishReason: "stop",
});
return "Take the scenic route.";
},
{ type: "agent", agentName: "trip-planner" },
);
console.log(answer("Plan a day trip"));
await flush();
await shutdown();import telemetry_dev
from telemetry_dev import observe, start_span, update_current_span
telemetry_dev.init()
@observe
def plan_route(city: str) -> dict[str, str]:
with start_span(
"chat gpt-4",
type="generation",
model="gpt-4",
provider="openai",
input=[{"role": "user", "content": f"Plan a day trip to {city}"}],
):
update_current_span(
output=[{"role": "assistant", "content": "Take the scenic route."}],
usage={"input_tokens": 11, "output_tokens": 7},
finish_reason="stop",
)
return {"city": city, "route": "scenic"}
print(plan_route("Kyoto"))
telemetry_dev.flush()
telemetry_dev.shutdown()Run the example
node --experimental-strip-types quickstart.tspython quickstart.pyOpen the trace
Open your project in the dashboard. Select Traces, then select the new trace.
The trace contains the observed parent span and its generation span. The dashboard shows duration, tokens, status, and cost when pricing exists.
Environment variables
| Variable | Default | Purpose |
|---|---|---|
TELEMETRY_DEV_API_KEY |
None | Authenticates OTLP requests. Keys start with td_live_. |
TELEMETRY_DEV_BASE_URL |
https://ingest.telemetry.dev |
Sets a different ingest base URL. |
TELEMETRY_DEV_ENVIRONMENT |
production |
Sets deployment.environment.name. |
OTEL_SERVICE_NAME |
unknown_service |
Sets service.name. |