Applies to:
- Plan - Any
- Deployment - Any
- Data plane - v2.2.1 or later for Group scope
- Use case - How to group traces for Topics classification by session stretch and use Trace or Group scope.
Summary
To get separate facet results for session stretches, log each stretch as a separate trace or group turn-based traces using a distinct key for each stretch.What is happening
Topics offers Trace and Group scopes. Topics does not support span-level scope. With Trace scope, a session logged as a single trace is one item to classify. With Group scope, related traces are classified as one unit, so grouping by session combines traces rather than separating stretches.Fix or suggestion
Option 1: Use a distinct grouping key for each stretch
- Emit a consistent grouping key on each turn-based trace in a stretch. Use a distinct value for each stretch.
- In Topics, set Scope to Group and configure Group by to use the key you log.
- Choose First trace in group or Every trace in group to control when Topics classifies traces and where it writes the results.
- First trace in group waits for the group to become idle and writes its classification to the first trace.
- Every trace in group classifies each arriving trace using prior traces in the group as context. Those classifications can differ.
Option 2: Produce smaller traces or attach group keys after the fact
- Emit one trace for each stretch you want classified and set Scope to Trace so each stretch is classified independently.
- For retrospective grouping, assign one consistent segmentation key per separate trace, with a distinct value for each stretch. Set Scope to Group and configure Group by to use that key.
- Use a custom facet prompt to focus extraction within the configured scope.
How to confirm it worked
- Check Topics for a separate facet result for each stretch.
- For Group scope, confirm classifications follow the First trace in group or Every trace in group behavior you selected.
Notes
- Topics runs as a batched classification pipeline. Topic generation requires at least 100 facet summaries.