Skip to content

feat: add session test data generator script - #42

Merged
andrewm4894 merged 1 commit into
mainfrom
andy/session-test-data-script
Feb 21, 2026
Merged

andrewm4894 merged 1 commit into
mainfrom
andy/session-test-data-script

Conversation

@andrewm4894

Copy link
Copy Markdown
Member

Summary

  • Adds python/scripts/generate_session_test_data.py — generates dummy LLM Analytics session events directly via the capture API (no LLM calls or OpenAI key needed)
  • Creates three test scenarios: pagination (120 traces), nested-span latency (5 traces), and a short control session (3 traces)
  • Useful for quickly populating sessions for testing the session detail page, load-more pagination, and latency calculations

Test plan

  • Run source python/venv/bin/activate && python python/scripts/generate_session_test_data.py against local dev
  • Verify sessions appear in LLM Analytics sessions list
  • Check pagination session has >100 traces and shows "load more"
  • Check nested-span session latency doesn't double-count

Generates dummy LLM Analytics session events via the capture API — no
LLM calls needed. Creates three test scenarios:
1. Session with 120 traces (pagination / "load more" testing)
2. Session with nested spans (latency double-counting bugs)
3. Short control session (baseline comparison)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9812094e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

sys.exit(1)


def capture_event(event: str, properties: dict, timestamp: str | None = None) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve Python 3.8 compatibility in type hints

The repository README declares Python 3.8+ support, but this signature uses PEP 604 union syntax (str | None), which raises a SyntaxError on Python 3.8/3.9 and prevents the script from running in documented environments. Use Optional[str] (or equivalent compatibility handling) so the generator works across supported Python versions.

Useful? React with 👍 / 👎.

"$ai_total_cost_usd": str(cost),
}
if has_error and i == num_generations - 1:
props["$ai_is_error"] = "true"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Emit $ai_is_error as a boolean, not a string

This writes $ai_is_error as the string "true" instead of a boolean. Because property typing is based on the ingested JSON value, error filters/aggregations that expect a boolean can miss these events, so the generated “error” scenario may look like a non-error trace in analytics views.

Useful? React with 👍 / 👎.

"$ai_span_id": parent_span_id,
"$ai_parent_id": trace_id,
"$ai_span_name": "agent-chain",
"$ai_latency": str(parent_latency),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep $ai_latency numeric for latency calculations

Latency is serialized with str(...), which ingests $ai_latency as a string property rather than a numeric one. This undermines the script’s stated purpose of validating latency behavior, since numeric latency rollups/sorting can become incorrect or require extra casting; emit float values directly.

Useful? React with 👍 / 👎.

@andrewm4894
andrewm4894 merged commit f146b3a into main Feb 21, 2026
8 checks passed
@andrewm4894
andrewm4894 deleted the andy/session-test-data-script branch February 21, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant