@cetra-ai/cli 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +14 -2
  3. package/dist/cli.js +2816 -0
  4. package/dist/skills/cetra/SKILL.md +95 -0
  5. package/dist/skills/cetra/references/anthropic.md +82 -0
  6. package/dist/skills/cetra/references/attributes.md +178 -0
  7. package/dist/skills/cetra/references/bedrock.md +46 -0
  8. package/dist/skills/cetra/references/crewai.md +38 -0
  9. package/dist/skills/cetra/references/dspy.md +38 -0
  10. package/dist/skills/cetra/references/from-laminar.md +49 -0
  11. package/dist/skills/cetra/references/from-langfuse.md +59 -0
  12. package/dist/skills/cetra/references/google-adk.md +60 -0
  13. package/dist/skills/cetra/references/google-genai.md +50 -0
  14. package/dist/skills/cetra/references/integrations.md +71 -0
  15. package/dist/skills/cetra/references/langchain.md +76 -0
  16. package/dist/skills/cetra/references/litellm.md +45 -0
  17. package/dist/skills/cetra/references/llama-index.md +38 -0
  18. package/dist/skills/cetra/references/metadata-and-tags.md +117 -0
  19. package/dist/skills/cetra/references/openai-agents.md +55 -0
  20. package/dist/skills/cetra/references/openai.md +82 -0
  21. package/dist/skills/cetra/references/openinference.md +51 -0
  22. package/dist/skills/cetra/references/openllmetry.md +42 -0
  23. package/dist/skills/cetra/references/opentelemetry-genai.md +49 -0
  24. package/dist/skills/cetra/references/opentelemetry.md +134 -0
  25. package/dist/skills/cetra/references/otlp.md +73 -0
  26. package/dist/skills/cetra/references/privacy-controls.md +120 -0
  27. package/dist/skills/cetra/references/python-context.md +63 -0
  28. package/dist/skills/cetra/references/python-opentelemetry.md +136 -0
  29. package/dist/skills/cetra/references/python-tracing.md +77 -0
  30. package/dist/skills/cetra/references/python.md +79 -0
  31. package/dist/skills/cetra/references/sessions.md +84 -0
  32. package/dist/skills/cetra/references/sql-schema.md +210 -0
  33. package/dist/skills/cetra/references/troubleshooting.md +90 -0
  34. package/dist/skills/cetra/references/typescript-context.md +22 -0
  35. package/dist/skills/cetra/references/typescript-opentelemetry.md +68 -0
  36. package/dist/skills/cetra/references/typescript-runtimes.md +54 -0
  37. package/dist/skills/cetra/references/typescript-tracing.md +40 -0
  38. package/dist/skills/cetra/references/typescript.md +56 -0
  39. package/dist/skills/cetra/references/users.md +87 -0
  40. package/dist/skills/cetra/references/vercel-ai-sdk.md +82 -0
  41. package/package.json +39 -4
@@ -0,0 +1,50 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/google-genai.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # Google Gen AI
4
+
5
+ Trace Google Gen AI calls with cetra: Gemini generateContent, streaming, multimodal input and reasoning tokens, from Python.
6
+
7
+ cetra traces calls to Gemini through the Google Gen AI SDK, including streamed answers, images in the input and reasoning tokens.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install "cetra-sdk[google-genai]" google-genai
13
+ ```
14
+
15
+ ## Set up
16
+
17
+ ```python
18
+ import cetra
19
+ from google import genai
20
+
21
+ cetra.init(instrument=["google-genai"])
22
+
23
+ client = genai.Client()
24
+ client.models.generate_content(
25
+ model="gemini-2.5-flash",
26
+ contents="What is the weather in Paris?",
27
+ )
28
+
29
+ cetra.flush()
30
+ ```
31
+
32
+ ## What you get
33
+
34
+ - Each `generateContent` call is an `llm` span with the input and output as chat messages.
35
+ - A streamed call is captured as one `llm` span (OpenInference names it `GenerateContentStream`).
36
+ - Reasoning tokens are recorded when Gemini reports them.
37
+ - An image in the input is stored as media and replaced by a reference, as for every other provider. See [Media](https://cetra.sh/docs/tracing/media/).
38
+ - Cache read tokens are recorded when Gemini reports them.
39
+
40
+ ## Limits
41
+
42
+ - The fixtures were captured with `google-genai` 2.34.0 and these instrumentations: OpenInference 1.5.0, the official OpenTelemetry `opentelemetry-instrumentation-google-genai` 1.1b1 and OpenLLMetry 0.62.4.
43
+ - The provider name depends on the instrumentation: `gcp.gen_ai` from OpenInference and `gcp.gemini` from the official OpenTelemetry one. cetra prices both from the same Gemini prices.
44
+ - The `instrument` name is checked by an SDK test that imports the instrumentor when the extra is installed. cetra-sdk's own spans for this name are not captured.
45
+
46
+ ## Next
47
+
48
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
49
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
50
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
@@ -0,0 +1,71 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/index.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # Integrations
4
+
5
+ The frameworks, providers and instrumentation libraries cetra works with, how each is connected and what it is tested against.
6
+
7
+ Use this page to find how to connect your framework, provider or instrumentation library to cetra.
8
+
9
+ | Integration | Python | TypeScript | How | Tested against |
10
+ |---|---|---|---|---|
11
+ | [OpenAI](https://cetra.sh/docs/integrations/openai/) | ✓ | ✓ | `instrument=["openai"]` or `openai(OpenAI)` | captured |
12
+ | [Anthropic](https://cetra.sh/docs/integrations/anthropic/) | ✓ | ✓ | `instrument=["anthropic"]` or `anthropic(Anthropic)` | captured |
13
+ | [Google Gen AI](https://cetra.sh/docs/integrations/google-genai/) | ✓ | — | `instrument=["google-genai"]` | captured |
14
+ | [Amazon Bedrock](https://cetra.sh/docs/integrations/bedrock/) | ✓ | — | `instrument=["bedrock"]` | SDK test |
15
+ | [LiteLLM](https://cetra.sh/docs/integrations/litellm/) | ✓ | — | `instrument=["litellm"]` | SDK test |
16
+ | [LangChain and LangGraph](https://cetra.sh/docs/integrations/langchain/) | ✓ | ✓ | `instrument=["langchain"]` or `langchain(…)` | captured (Python), SDK test (TypeScript) |
17
+ | [LlamaIndex](https://cetra.sh/docs/integrations/llama-index/) | ✓ | — | `instrument=["llama-index"]` | SDK test |
18
+ | [Vercel AI SDK](https://cetra.sh/docs/integrations/vercel-ai-sdk/) | — | ✓ | `aiTelemetry()` | captured |
19
+ | [OpenAI Agents SDK](https://cetra.sh/docs/integrations/openai-agents/) | ✓ | — | `instrument=["openai-agents"]` | captured |
20
+ | [CrewAI](https://cetra.sh/docs/integrations/crewai/) | ✓ | — | `instrument=["crewai"]` | SDK test |
21
+ | [DSPy](https://cetra.sh/docs/integrations/dspy/) | ✓ | — | `instrument=["dspy"]` | SDK test |
22
+ | [Google ADK](https://cetra.sh/docs/integrations/google-adk/) | ✓ | — | ADK's own OpenTelemetry spans | captured |
23
+ | [OpenInference](https://cetra.sh/docs/integrations/openinference/) | ✓ | ✓ | point its exporter at cetra | captured |
24
+ | [OpenLLMetry (Traceloop)](https://cetra.sh/docs/integrations/openllmetry/) | ✓ | ✓ | point its exporter at cetra | captured |
25
+ | [OpenTelemetry GenAI](https://cetra.sh/docs/integrations/opentelemetry-genai/) | ✓ | ✓ | the official `opentelemetry-instrumentation-*` packages | captured |
26
+ | [From Langfuse](https://cetra.sh/docs/integrations/from-langfuse/) | ✓ | — | keep the Langfuse SDK, export its spans to cetra | captured |
27
+ | [From Laminar](https://cetra.sh/docs/integrations/from-laminar/) | ✓ | — | keep the Laminar SDK, export its spans to cetra | captured |
28
+ | [Claude Code](https://cetra.sh/docs/integrations/claude-code/) | — | — | `cetra agents setup claude-code` | captured |
29
+ | [Codex CLI](https://cetra.sh/docs/integrations/codex/) | — | — | `cetra agents setup codex` | captured |
30
+ | [Gemini CLI](https://cetra.sh/docs/integrations/gemini-cli/) | — | — | `cetra agents setup gemini-cli` | captured |
31
+ | [GitHub Copilot](https://cetra.sh/docs/integrations/copilot/) | — | — | `cetra agents setup copilot` | hand-written |
32
+
33
+ "Captured" means the repository holds spans recorded from the real library, and a test checks how cetra reads them. "SDK test" means an SDK test checks the helper, and the repository holds no recorded spans for it. A ✓ for TypeScript means a helper in `@cetra-ai/sdk`, or a TypeScript library whose spans are captured. A — means no helper or captured run exists for that language: you can still use the library's own OpenTelemetry instrumentation with [Send OpenTelemetry](https://cetra.sh/docs/get-started/opentelemetry/).
34
+
35
+ ## Coding agents
36
+
37
+ - [Claude Code](https://cetra.sh/docs/integrations/claude-code/): Prompts, model calls and tools, with the Claude Agent SDK.
38
+ - [Codex CLI](https://cetra.sh/docs/integrations/codex/): Turns and tool calls from codex exec.
39
+ - [Gemini CLI](https://cetra.sh/docs/integrations/gemini-cli/): Model calls and tool batches.
40
+ - [GitHub Copilot](https://cetra.sh/docs/integrations/copilot/): Copilot CLI and VS Code Copilot Chat.
41
+
42
+ ## Providers
43
+
44
+ - [OpenAI](https://cetra.sh/docs/integrations/openai/): Chat, Responses API and embeddings.
45
+ - [Anthropic](https://cetra.sh/docs/integrations/anthropic/): Messages, streaming, thinking and cache tokens.
46
+ - [Google Gen AI](https://cetra.sh/docs/integrations/google-genai/): Gemini through the Google Gen AI SDK.
47
+ - [Amazon Bedrock](https://cetra.sh/docs/integrations/bedrock/): Bedrock calls from Python.
48
+ - [LiteLLM](https://cetra.sh/docs/integrations/litellm/): LiteLLM calls from Python.
49
+
50
+ ## Frameworks
51
+
52
+ - [LangChain and LangGraph](https://cetra.sh/docs/integrations/langchain/): Chains, agents, models and tools.
53
+ - [LlamaIndex](https://cetra.sh/docs/integrations/llama-index/): LlamaIndex from Python.
54
+ - [Vercel AI SDK](https://cetra.sh/docs/integrations/vercel-ai-sdk/): Versions 4 to 7.
55
+ - [OpenAI Agents SDK](https://cetra.sh/docs/integrations/openai-agents/): Agent runs and function tools.
56
+ - [CrewAI](https://cetra.sh/docs/integrations/crewai/): CrewAI from Python.
57
+ - [DSPy](https://cetra.sh/docs/integrations/dspy/): DSPy from Python.
58
+ - [Google ADK](https://cetra.sh/docs/integrations/google-adk/): Agent Development Kit runs.
59
+
60
+ ## Instrumentation libraries
61
+
62
+ - [OpenInference](https://cetra.sh/docs/integrations/openinference/): Arize's instrumentation, with any exporter.
63
+ - [OpenLLMetry](https://cetra.sh/docs/integrations/openllmetry/): Traceloop's instrumentation and SDK.
64
+ - [OpenTelemetry GenAI](https://cetra.sh/docs/integrations/opentelemetry-genai/): The official GenAI instrumentation packages.
65
+
66
+ ## Migrating
67
+
68
+ - [From Langfuse](https://cetra.sh/docs/integrations/from-langfuse/): Keep the Langfuse SDK and send its spans to cetra.
69
+ - [From Laminar](https://cetra.sh/docs/integrations/from-laminar/): Keep the Laminar SDK and send its spans to cetra.
70
+
71
+ Anything else that speaks OpenTelemetry works through [Send OpenTelemetry](https://cetra.sh/docs/get-started/opentelemetry/).
@@ -0,0 +1,76 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/langchain.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # LangChain and LangGraph
4
+
5
+ Trace LangChain and LangGraph with cetra: chains, chat models, tools and agent steps, from Python and TypeScript.
6
+
7
+ cetra traces LangChain and LangGraph runs as a tree: the graph, its nodes, each model call and each tool call.
8
+
9
+ ## Install
10
+
11
+ **Python**
12
+
13
+ ```bash
14
+ pip install "cetra-sdk[langchain]" langchain langchain-openai
15
+ ```
16
+
17
+ **TypeScript**
18
+
19
+ ```bash
20
+ npm install @cetra-ai/sdk @arizeai/openinference-instrumentation-langchain @langchain/core @langchain/openai
21
+ ```
22
+
23
+ ## Set up
24
+
25
+ **Python**
26
+
27
+ ```python
28
+ import cetra
29
+ from langchain_openai import ChatOpenAI
30
+
31
+ cetra.init(instrument=["langchain"])
32
+
33
+ model = ChatOpenAI(model="gpt-4o-mini")
34
+ model.invoke("What is the weather in Paris?")
35
+
36
+ cetra.flush()
37
+ ```
38
+
39
+ **TypeScript**
40
+
41
+ ```ts
42
+ import { init } from "@cetra-ai/sdk";
43
+ import { langchain } from "@cetra-ai/sdk/langchain";
44
+ import * as callbacksManager from "@langchain/core/callbacks/manager";
45
+ ```
46
+
47
+ ```ts
48
+ init({ apiKey: process.env.CETRA_API_KEY, instrument: [langchain(callbacksManager)] });
49
+ ```
50
+
51
+ ```ts
52
+ import { ChatOpenAI } from "@langchain/openai";
53
+
54
+ const model = new ChatOpenAI({ model: "gpt-4o-mini" });
55
+ await model.invoke("What is the weather in Paris?");
56
+ ```
57
+
58
+ ## What you get
59
+
60
+ - A chat model call is an `llm` span with the provider, the messages, the tool definitions and the token counts.
61
+ - A tool run is a `tool` span.
62
+ - A LangGraph agent is a tree: the graph, each node as a `chain` span, the model calls and the tool calls under their nodes.
63
+ - LangChain's run metadata, such as `langgraph_node` and `langgraph_step`, is kept as span metadata.
64
+ - Cost is computed from the token counts of each model call.
65
+
66
+ ## Limits
67
+
68
+ - The fixtures were captured in Python with `langchain` 1.4.8, `langchain-openai` 1.7.3 and `langgraph` 1.2.19, with OpenInference 0.1.81 and OpenLLMetry 0.62.4.
69
+ - With OpenLLMetry, the graph and its nodes come out as `agent` and `chain` spans with the provider `langgraph`.
70
+ - The TypeScript helper is covered by an SDK test that builds the instrumentation from LangChain's callback module. No spans of a LangChain.js run are captured.
71
+
72
+ ## Next
73
+
74
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
75
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
76
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
@@ -0,0 +1,45 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/litellm.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # LiteLLM
4
+
5
+ Trace LiteLLM calls with cetra from Python, with the OpenInference LiteLLM instrumentation.
6
+
7
+ cetra can trace LiteLLM calls from Python through the OpenInference LiteLLM instrumentation.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install "cetra-sdk[litellm]" litellm
13
+ ```
14
+
15
+ ## Set up
16
+
17
+ ```python
18
+ import litellm
19
+
20
+ import cetra
21
+
22
+ cetra.init(instrument=["litellm"])
23
+
24
+ litellm.completion(
25
+ model="gpt-4o-mini",
26
+ messages=[{"role": "user", "content": "What is the weather in Paris?"}],
27
+ )
28
+
29
+ cetra.flush()
30
+ ```
31
+
32
+ ## What you get
33
+
34
+ cetra reads the spans of the OpenInference LiteLLM instrumentation with the OpenInference convention. See [Semantic conventions](https://cetra.sh/docs/concepts/conventions/).
35
+
36
+ ## Limits
37
+
38
+ - No captured spans of this instrumentation are in the repository. The only check is an SDK test that imports the instrumentor when the extra is installed. This page does not say which fields a LiteLLM call fills.
39
+ - If a field is missing, look at the span's **Attributes** tab and compare it with [Span attributes](https://cetra.sh/docs/reference/attributes/).
40
+
41
+ ## Next
42
+
43
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
44
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
45
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
@@ -0,0 +1,38 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/llama-index.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # LlamaIndex
4
+
5
+ Trace LlamaIndex with cetra from Python, with the OpenInference LlamaIndex instrumentation.
6
+
7
+ cetra can trace LlamaIndex queries, retrievals and model calls from Python through the OpenInference LlamaIndex instrumentation.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install "cetra-sdk[llama-index]" llama-index
13
+ ```
14
+
15
+ ## Set up
16
+
17
+ ```python
18
+ import cetra
19
+
20
+ cetra.init(instrument=["llama-index"])
21
+
22
+ # Build and query your index as usual. LlamaIndex calls are traced from here on.
23
+ ```
24
+
25
+ ## What you get
26
+
27
+ cetra reads the spans of the OpenInference LlamaIndex instrumentation with the OpenInference convention. cetra supports the OpenInference `retriever`, `reranker` and `embedding` span kinds. See [Semantic conventions](https://cetra.sh/docs/concepts/conventions/).
28
+
29
+ ## Limits
30
+
31
+ - No captured spans of this instrumentation are in the repository. The only check is an SDK test that imports the instrumentor when the extra is installed. This page does not say which LlamaIndex operations are traced.
32
+ - If a field is missing, look at the span's **Attributes** tab and compare it with [Span attributes](https://cetra.sh/docs/reference/attributes/).
33
+
34
+ ## Next
35
+
36
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
37
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
38
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
@@ -0,0 +1,117 @@
1
+ <!-- Generated from website/src/content/docs/docs/tracing/metadata-and-tags.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # Metadata, tags, environments and releases
4
+
5
+ Label your traces with metadata, tags, an environment and a release, and use those labels to filter.
6
+
7
+ Use these four labels to slice your traces by customer, feature, deployment or version.
8
+
9
+ | Label | What it is for | Shape |
10
+ |---|---|---|
11
+ | Metadata | Facts about a request that you want to read or filter on: a plan, a customer, a feature flag. | Key and value pairs |
12
+ | Tags | Short labels that mark a trace: `beta`, `vip`, `retry`. | A list of strings |
13
+ | Environment | The deployment: `production`, `staging`, `dev`. | One string |
14
+ | Release | The version of your code: a Git SHA or a version number. | One string |
15
+
16
+ ## Set them
17
+
18
+ **Python**
19
+
20
+ Metadata and tags go in a context block. Every span started inside the block carries them. Environment and release are set once, in `init()`.
21
+
22
+ ```python
23
+ import cetra
24
+
25
+ cetra.init(environment="production", release="1.4.2")
26
+
27
+ @cetra.observe(name="turn")
28
+ def turn() -> None: ...
29
+
30
+ with cetra.context(tags=["beta"], metadata={"plan": "pro", "customer": "acme"}):
31
+ turn()
32
+
33
+ cetra.flush()
34
+ ```
35
+
36
+ To add metadata to one span, call `set_metadata` on a manual span.
37
+
38
+ ```python
39
+ import cetra
40
+
41
+ cetra.init()
42
+
43
+ with cetra.span("rerank", kind="reranker") as s:
44
+ s.set_metadata(model="bge")
45
+
46
+ cetra.flush()
47
+ ```
48
+
49
+ **TypeScript**
50
+
51
+ ```ts
52
+ import { observe, withContext } from "@cetra-ai/sdk";
53
+ ```
54
+
55
+ ```ts
56
+ const turn = observe(({ question }: { question: string }) => `answered: ${question}`, {
57
+ name: "turn",
58
+ });
59
+ withContext({ sessionId: "chat-42", userId: "u-17", tags: ["beta"] }, () =>
60
+ turn({ question: "why?" }),
61
+ );
62
+ ```
63
+
64
+ Pass `environment` and `release` to `init()`, or set `CETRA_ENVIRONMENT` and `CETRA_RELEASE`.
65
+
66
+ **OpenTelemetry**
67
+
68
+ Set these attributes on a span: `cetra.metadata.<key>` for each metadata entry, `cetra.tags` for the tags, and `cetra.environment` and `cetra.release`. cetra also reads the resource attributes `deployment.environment.name` and `service.version`.
69
+
70
+ ```python
71
+ import os
72
+
73
+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
74
+ from opentelemetry.sdk.trace import TracerProvider
75
+ from opentelemetry.sdk.trace.export import BatchSpanProcessor
76
+
77
+ provider = TracerProvider()
78
+ provider.add_span_processor(
79
+ BatchSpanProcessor(
80
+ OTLPSpanExporter(headers={"Authorization": f"Bearer {os.environ['CETRA_API_KEY']}"})
81
+ )
82
+ )
83
+ tracer = provider.get_tracer("my-app")
84
+
85
+ with tracer.start_as_current_span("turn") as span:
86
+ span.set_attribute("cetra.metadata.customer", "acme")
87
+ span.set_attribute("cetra.tags", ["beta"])
88
+ span.set_attribute("cetra.environment", "production")
89
+ span.set_attribute("cetra.release", "1.4.2")
90
+
91
+ provider.shutdown()
92
+ ```
93
+
94
+ Metadata keys use letters, digits, `_`, `.` and `-`. The SDK skips a key that does not. Keep personal data out of metadata, or mask it. See [Masking, sampling and truncation](https://cetra.sh/docs/tracing/privacy-controls/).
95
+
96
+ The environments `cetra-eval` and `cetra-playground` are reserved for cetra's own evaluator and playground runs, and `experiment` is the default for experiment runs. cetra renames `cetra-eval` and `cetra-playground` on spans you send to `cetra-eval-external` and `cetra-playground-external`.
97
+
98
+ ## In the UI
99
+
100
+ The trace list has columns for tags and environment. The trace header shows the tags, environment and release. The **Attributes** tab of a span shows its metadata.
101
+
102
+ ## Filter
103
+
104
+ | Filter | Finds |
105
+ |---|---|
106
+ | `metadata['customer'] = 'acme'` | Traces with that metadata value. |
107
+ | `tags @> ['beta']` | Traces with the tag `beta`. |
108
+ | `environment = 'production'` | Traces from one environment. |
109
+ | `release = '1.4.2'` | Traces from one release. |
110
+
111
+ See the [filter language](https://cetra.sh/docs/reference/filter-language/).
112
+
113
+ ## Limits
114
+
115
+ - A trace's metadata comes from its root span. Keys from other spans are added when the root does not have them.
116
+ - A trace's tags are the tags of all its spans together.
117
+ - Metadata values are stored as text. A number is stored as its text form.
@@ -0,0 +1,55 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/openai-agents.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # OpenAI Agents SDK
4
+
5
+ Trace the OpenAI Agents SDK with cetra from Python: agent runs, turns, model calls and function tools.
6
+
7
+ cetra traces OpenAI Agents SDK runs as a tree of agent, turn, model call and tool spans.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install "cetra-sdk[openai-agents]" openai-agents
13
+ ```
14
+
15
+ ## Set up
16
+
17
+ ```python
18
+ import cetra
19
+ from agents import Agent, Runner, function_tool
20
+
21
+ cetra.init(instrument=["openai-agents"])
22
+
23
+ @function_tool
24
+ def get_weather(city: str) -> str:
25
+ return f"It is 18 degrees and sunny in {city}."
26
+
27
+ agent = Agent(
28
+ name="weather",
29
+ instructions="You are a weather assistant.",
30
+ tools=[get_weather],
31
+ )
32
+ Runner.run_sync(agent, "What is the weather in Paris?")
33
+
34
+ cetra.flush()
35
+ ```
36
+
37
+ ## What you get
38
+
39
+ With the OpenInference instrumentation, one run with a function tool produces:
40
+
41
+ - an `agent` span for the workflow and one for the agent;
42
+ - one `chain` span per turn;
43
+ - an `llm` span for each model call, with the provider, token counts and cost;
44
+ - a `tool` span for the function tool.
45
+
46
+ ## Limits
47
+
48
+ - The fixtures were captured with `openai-agents` 0.24.0, OpenInference 2.7.0 and OpenLLMetry 0.62.4.
49
+ - The SDK's own tracing to OpenAI is a separate feature. This page covers the OpenTelemetry instrumentation.
50
+
51
+ ## Next
52
+
53
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
54
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
55
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
@@ -0,0 +1,82 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/openai.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # OpenAI
4
+
5
+ Trace OpenAI calls with cetra: chat completions, the Responses API and embeddings, from Python and TypeScript.
6
+
7
+ cetra traces OpenAI chat completions, Responses API calls and embeddings, with their messages, tool calls, token counts and cost.
8
+
9
+ ## Install
10
+
11
+ **Python**
12
+
13
+ ```bash
14
+ pip install "cetra-sdk[openai]" openai
15
+ ```
16
+
17
+ **TypeScript**
18
+
19
+ ```bash
20
+ npm install @cetra-ai/sdk @arizeai/openinference-instrumentation-openai openai
21
+ ```
22
+
23
+ ## Set up
24
+
25
+ Turn on the instrumentation when you start cetra, then call OpenAI as usual. The spans nest under your own spans and carry the session, user, tags and metadata of the current context.
26
+
27
+ **Python**
28
+
29
+ ```python
30
+ import cetra
31
+ from openai import OpenAI
32
+
33
+ cetra.init(instrument=["openai"])
34
+
35
+ client = OpenAI()
36
+ client.chat.completions.create(
37
+ model="gpt-4o-mini",
38
+ messages=[{"role": "user", "content": "What is the weather in Paris?"}],
39
+ )
40
+
41
+ cetra.flush()
42
+ ```
43
+
44
+ **TypeScript**
45
+
46
+ ```ts
47
+ import { init } from "@cetra-ai/sdk";
48
+ import { openai } from "@cetra-ai/sdk/openai";
49
+ import OpenAI from "openai";
50
+ ```
51
+
52
+ ```ts
53
+ init({ apiKey: process.env.CETRA_API_KEY, instrument: [openai(OpenAI)] });
54
+ ```
55
+
56
+ ```ts
57
+ const client = new OpenAI();
58
+ await client.chat.completions.create({
59
+ model: "gpt-4o-mini",
60
+ messages: [{ role: "user", content: "What is the weather in Paris?" }],
61
+ });
62
+ ```
63
+
64
+ ## What you get
65
+
66
+ - Each chat completion and each Responses API call is an `llm` span with the provider `openai`, the input and output as chat messages, and the tool definitions you passed.
67
+ - A tool call in the answer shows as a tool call in the output messages. The tool result you send back shows in the next call's input.
68
+ - Token counts include the cached input tokens when OpenAI reports them. cetra computes the cost from its price table.
69
+ - Streamed answers record the time to first token with the OpenInference and OpenLLMetry instrumentations. The streamed fixture of the official OpenTelemetry instrumentation has no time to first token.
70
+ - An embeddings call is an `embedding` span with the input token count and a cost.
71
+
72
+ ## Limits
73
+
74
+ - The fixtures were captured with the OpenAI Python SDK 3.45.0 and these instrumentations: OpenInference 0.1.69, OpenLLMetry 0.62.4 and the official `opentelemetry-instrumentation-openai-v2` 2.4b0. Other versions are not covered.
75
+ - Embedding vectors are not stored. Pass `capture_content=False` (Python) or `captureContent: false` to the helper and to `init` (TypeScript) to keep prompts and answers out of cetra.
76
+ - If you use another instrumentation library, see [OpenInference](https://cetra.sh/docs/integrations/openinference/), [OpenLLMetry](https://cetra.sh/docs/integrations/openllmetry/) or [OpenTelemetry GenAI](https://cetra.sh/docs/integrations/opentelemetry-genai/).
77
+
78
+ ## Next
79
+
80
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
81
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
82
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
@@ -0,0 +1,51 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/openinference.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # OpenInference
4
+
5
+ Send OpenInference instrumentation to cetra from any language: the Arize instrumentation libraries, pointed at the cetra endpoint.
6
+
7
+ cetra reads spans from the OpenInference instrumentation libraries, so you can use them with their own OpenTelemetry exporter.
8
+
9
+ ## Point the exporter at cetra
10
+
11
+ The `cetra-sdk` `instrument` option already uses these libraries. To use them with your own OpenTelemetry setup, add an exporter that sends to cetra and pass its provider to the instrumentor. This is the setup the fixtures were captured with, with the endpoint and the key changed.
12
+
13
+ ```python
14
+ from openinference.instrumentation.openai import OpenAIInstrumentor
15
+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
16
+ from opentelemetry.sdk.trace import TracerProvider
17
+ from opentelemetry.sdk.trace.export import BatchSpanProcessor
18
+
19
+ provider = TracerProvider()
20
+ provider.add_span_processor(
21
+ BatchSpanProcessor(
22
+ OTLPSpanExporter(
23
+ endpoint="http://localhost:8080/v1/traces",
24
+ headers={"Authorization": "Bearer <SK_CETRA_KEY>"},
25
+ )
26
+ )
27
+ )
28
+ OpenAIInstrumentor().instrument(tracer_provider=provider)
29
+ ```
30
+
31
+ Replace `<SK_CETRA_KEY>` with your `sk-cetra-` API key. See [Send OpenTelemetry](https://cetra.sh/docs/get-started/opentelemetry/) for the endpoint, the ports and the other languages.
32
+
33
+ ## What carries over
34
+
35
+ cetra reads these OpenInference attributes: the span kind, the model and provider, the flattened input and output messages, the tool definitions, token counts including cache and reasoning tokens, and cost. See [Span attributes](https://cetra.sh/docs/reference/attributes/).
36
+
37
+ - Retriever documents become the span's output.
38
+ - Embedding vectors are dropped. Their texts are kept.
39
+ - A value of `__REDACTED__`, which OpenInference writes for hidden content, is treated as content that was not captured.
40
+ - A span of kind `LLM`, `EMBEDDING`, `TOOL`, `AGENT`, `CHAIN`, `RETRIEVER`, `RERANKER`, `GUARDRAIL` or `EVALUATOR` becomes the cetra span kind of the same name.
41
+
42
+ ## Limits
43
+
44
+ - The captured fixtures are Python. The TypeScript helpers of `@cetra-ai/sdk` use the OpenInference libraries for OpenAI, Anthropic and LangChain, and are covered by SDK tests.
45
+ - The versions covered are in each fixture's `case.json`.
46
+
47
+ ## Next
48
+
49
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
50
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
51
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
@@ -0,0 +1,42 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/openllmetry.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # OpenLLMetry (Traceloop)
4
+
5
+ Send OpenLLMetry and Traceloop instrumentation to cetra from any language, with the Traceloop SDK or the instrumentation packages.
6
+
7
+ cetra reads spans from OpenLLMetry's instrumentation packages and from the Traceloop SDK.
8
+
9
+ ## Point the exporter at cetra
10
+
11
+ With the Traceloop SDK, set the endpoint to cetra. The SDK adds `/v1/traces` to the endpoint. The fixtures were captured with a call like this, with the endpoint changed.
12
+
13
+ ```python
14
+ from traceloop.sdk import Traceloop
15
+
16
+ Traceloop.init(
17
+ app_name="my-app",
18
+ api_endpoint="http://localhost:8080",
19
+ api_key="<SK_CETRA_KEY>",
20
+ )
21
+ ```
22
+
23
+ Replace `<SK_CETRA_KEY>` with your `sk-cetra-` API key. If you use the `opentelemetry-instrumentation-*` packages without the Traceloop SDK, add an exporter to your provider as shown on [OpenInference](https://cetra.sh/docs/integrations/openinference/).
24
+
25
+ ## What carries over
26
+
27
+ - `@workflow`, `@task` and tool spans become `chain` and `tool` spans. The workflow name goes into the span's metadata under `workflow`.
28
+ - Session and user IDs set with `Traceloop.set_association_properties` become the session and user. Other association properties become metadata.
29
+ - Flattened prompts and completions (`gen_ai.prompt.N` and `gen_ai.completion.N`) become input and output messages. The `llm.request.functions` attributes become tool definitions.
30
+ - Token counts, cache tokens and streamed time to first token are read from the LLM spans.
31
+ - If a span carries both OpenTelemetry GenAI messages and OpenLLMetry's flattened keys, cetra uses the GenAI ones.
32
+
33
+ ## Limits
34
+
35
+ - The captured fixtures are Python, with OpenLLMetry 0.62.4. Other languages' packages are not captured here.
36
+ - For Anthropic, OpenLLMetry's prompt token count can exclude the cache. cetra adds the cache back.
37
+
38
+ ## Next
39
+
40
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
41
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
42
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.