docs(sample-app): add beginner-friendly LLM tracing example (#4069)#4197
docs(sample-app): add beginner-friendly LLM tracing example (#4069)#4197NishchayMahor wants to merge 2 commits into
Conversation
…p#4069) A heavily-commented walkthrough that introduces Traceloop.init, @workflow, and @task against a single OpenAI call. Existing examples assume you already know the SDK shape — this fills the on-ramp. Also updates the sample-app README (was a placeholder) to point new users at this example first.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds README instructions and a self-contained beginner tracing example that initializes Traceloop with a ConsoleSpanExporter, creates an OpenAI client, defines two traced tasks and a traced workflow that call OpenAI chat completions, and provides a main entrypoint to run the workflow. ChangesBeginner-Friendly LLM Tracing Example
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/sample-app/README.md`:
- Around line 9-12: Update the run command in the README code block so it uses
the project’s preferred package runner: replace the line "poetry run python
sample_app/beginner_tracing_example.py" with "uv run python
sample_app/beginner_tracing_example.py" in the README.md code block (the snippet
that also sets OPENAI_API_KEY) to keep the instructions consistent with the rest
of the repo.
In `@packages/sample-app/sample_app/beginner_tracing_example.py`:
- Around line 12-14: Update the embedded run instructions in the
beginner_tracing_example.py docstring to use the uv package manager instead of
poetry: locate the usage lines that currently read "poetry run python
sample_app/beginner_tracing_example.py" in the file's top-level docstring (or
usage block) and change them to "uv run python
sample_app/beginner_tracing_example.py" so package-management commands follow
the repository guideline; ensure the OPENAI_API_KEY export line remains
unchanged.
- Around line 27-30: The example exits early because Traceloop.init is called
without TRACELOOP_API_KEY or an exporter/processor; update the init call in
beginner_tracing_example.py to supply a stdout debug pipeline by passing
processor=SimpleSpanProcessor(ConsoleSpanExporter()) (import ConsoleSpanExporter
and SimpleSpanProcessor from opentelemetry.sdk.trace.export and
opentelemetry.sdk.trace respectively) so spans print to stdout even when
TRACELOOP_API_KEY is missing, and update the docstring run instruction to use
"uv run ..." instead of "poetry run ...".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ab97d2cd-216e-45cd-8957-7051c5fa0dda
📒 Files selected for processing (2)
packages/sample-app/README.mdpackages/sample-app/sample_app/beginner_tracing_example.py
Without TRACELOOP_API_KEY or an OTLP endpoint the example was silent — pass exporter=ConsoleSpanExporter() so it prints spans out of the box. Also swap the poetry run commands for uv run, matching the repo guideline.
|
Thanks @coderabbitai — addressed all three in 06c2055:
|
|
Tip For best results, initiate chat on the files or code changes.
The changes address the original concerns well. 🐇 If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
Adds a short, heavily-commented walkthrough at `packages/sample-app/sample_app/beginner_tracing_example.py` that introduces `Traceloop.init`, `@workflow`, and `@task` against a single OpenAI call.
Closes #4069.
The existing examples in `sample-app/` are great references once you already know the SDK shape, but they assume you do. This one starts from `Traceloop.init` and works up to a two-task workflow so a first-time user can copy it, run it, and see the trace structure that everything else in the repo produces.
Also replaces the sample-app README placeholder (`Project description here.`) with a short paragraph that points new users at this example first.
```bash
export OPENAI_API_KEY=sk-...
poetry run python sample_app/beginner_tracing_example.py
```
```
$ uvx ruff check packages/sample-app/sample_app/beginner_tracing_example.py
All checks passed!
$ uvx ruff format --check packages/sample-app/sample_app/beginner_tracing_example.py
1 file already formatted
```
Summary by CodeRabbit
Documentation
New Features