Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ To send <a href="/llm_observability/evaluations/external_evaluations#submitting-

For information on using Prompt Tracking with OpenTelemetry spans, see <a href="/llm_observability/monitoring/prompt_tracking#opentelemetry-instrumentation">Prompt Tracking - OpenTelemetry Instrumentation</a>.

For information on using Prompt Tracking with OpenTelemetry spans, see <a href="/llm_observability/monitoring/prompt_tracking#opentelemetry-instrumentation">Prompt Tracking - OpenTelemetry Instrumentation</a>.

## Setup

To send OpenTelemetry traces to LLM Observability, configure your OpenTelemetry exporter with the following settings:
Expand Down
52 changes: 41 additions & 11 deletions content/en/llm_observability/monitoring/prompt_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,58 @@ Set the attribute on any LLM span:
import json

span.set_attribute("_dd.ml_obs.prompt_tracking", json.dumps({
"name": "greeting-prompt",
"version": "v1",
"template": "Hello {{name}}, tell me about {{topic}}",
"variables": {"name": "Alice", "topic": "weather"}
"name": "support-rag-prompt",
"version": "v2",
"chat_template": [
{
"role": "system",
"content": "You are a helpful customer support assistant for {{product_name}}. Use only the provided context to answer questions. If the answer is not in the context, say so."
},
{
"role": "user",
"content": "Context:\n{{retrieved_docs}}\n\nQuestion: {{question}}"
}
],
}))
```
{{% /tab %}}
{{% tab "JavaScript" %}}
```javascript
span.setAttribute("_dd.ml_obs.prompt_tracking", JSON.stringify({
name: "greeting-prompt",
version: "v1",
template: "Hello {{name}}, tell me about {{topic}}",
variables: { name: "Alice", topic: "weather" }
name: "support-rag-prompt",
version: "v2",
chat_template: [
{
role: "system",
content: "You are a helpful customer support assistant for {{product_name}}. Use only the provided context to answer questions. If the answer is not in the context, say so."
},
{
role: "user",
content: "Context:\n{{retrieved_docs}}\n\nQuestion: {{question}}"
}
]
}));
```
{{% /tab %}}
{{% tab "Go" %}}
```go
span.SetAttributes(attribute.String("_dd.ml_obs.prompt_tracking",
`{"name":"greeting-prompt","version":"v1","template":"Hello {{name}}, tell me about {{topic}}","variables":{"name":"Alice","topic":"weather"}}`,
))
import "encoding/json"

promptData, _ := json.Marshal(map[string]any{
"name": "support-rag-prompt",
"version": "v2",
"chat_template": []map[string]string{
{
"role": "system",
"content": "You are a helpful customer support assistant for {{product_name}}. Use only the provided context to answer questions. If the answer is not in the context, say so.",
},
{
"role": "user",
"content": "Context:\n{{retrieved_docs}}\n\nQuestion: {{question}}",
},
},
})
span.SetAttributes(attribute.String("_dd.ml_obs.prompt_tracking", string(promptData)))
```
{{% /tab %}}
{{< /tabs >}}
Expand Down
Loading