Get started
- What is Keywords AI?
- Getting started
AI observability
- Overview
- Getting started
- Metrics
- Logs
- Traces
- Threads
- User analytics
- Advanced
Prompt engineering
- Overview
- Prompt management
- Prompt Playground
Evaluations
- Overview
- LLM evals
- Human evals
- Testsets & Experiments
AI gateway
Organization management
Resources
Traces
Group traces
Group traces across different sessions by a trace group id.
Use trace_group_identifier
to group related traces and workflows together, even if they run in different sessions or systems.
Hereโs an example of grouped workflows:๐
Quickstart
Add the same trace_group_identifier
to multiple workflows to group them together.
Python
from keywordsai_tracing.decorators import workflow, task
from keywordsai_tracing.main import KeywordsAITelemetry
from keywordsai_tracing.contexts.span import keywordsai_span_attributes
k_tl = KeywordsAITelemetry()
@task(name="joke_creation")
def create_joke():
# This is the joke creation task
@workflow(name="pirate_joke_generator")
def joke_workflow():
# This is the joke creation workflow
@workflow(name="pirate_joke_plus_audience_reactions")
def pirate_joke_plus_audience():
with keywordsai_span_attributes(
keywordsai_params={
"trace_group_identifier": "pirate_joke_id"
}):
joke = joke_workflow() # This show case the basic workflow usage and compatibility with the OpenAI SDK
return "python"
@workflow(name="pirate_joke_plus_audience_reactions")
def another_workflow():
with keywordsai_span_attributes(
keywordsai_params={
"trace_group_identifier": "pirate_joke_id" # same trace group identifier as the previous workflow
}):
# This is the another workflow
return "python"
Python
from keywordsai_tracing.decorators import workflow, task
from keywordsai_tracing.main import KeywordsAITelemetry
from keywordsai_tracing.contexts.span import keywordsai_span_attributes
k_tl = KeywordsAITelemetry()
@task(name="joke_creation")
def create_joke():
# This is the joke creation task
@workflow(name="pirate_joke_generator")
def joke_workflow():
# This is the joke creation workflow
@workflow(name="pirate_joke_plus_audience_reactions")
def pirate_joke_plus_audience():
with keywordsai_span_attributes(
keywordsai_params={
"trace_group_identifier": "pirate_joke_id"
}):
joke = joke_workflow() # This show case the basic workflow usage and compatibility with the OpenAI SDK
return "python"
@workflow(name="pirate_joke_plus_audience_reactions")
def another_workflow():
with keywordsai_span_attributes(
keywordsai_params={
"trace_group_identifier": "pirate_joke_id" # same trace group identifier as the previous workflow
}):
# This is the another workflow
return "python"
TypeScript
import { KeywordsAITelemetry } from "@keywordsai/tracing";
const keywordsAI = new KeywordsAITelemetry({
// any config
});
async function testTask() {// any task or workflow
}
async function testWorkflow() {
return await keywordsAI.withWorkflow({ name: "test" }, async () => {
keywordsAI.withKeywordsAISpanAttributes(
async () => {
testTask();
},
{
trace_group_identifier: "some_trace_group_identifier",
}
);
return "test workflow";
});
}
testWorkflow();
async function another_testWorkflow() {
return await keywordsAI.withWorkflow({ name: "test_another_workflow" }, async () => {
keywordsAI.withKeywordsAISpanAttributes(
async () => {
// any task or workflow
},
{
trace_group_identifier: "some_trace_group_identifier", // same trace group identifier as the previous workflow
}
);
return "test workflow no.2";
});
}
another_testWorkflow();
Was this page helpful?
On this page