docs: add beginner Aleph Alpha tracing example - #4400
Conversation
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a beginner-friendly Aleph Alpha completion tracing example. The example configures console span export, instruments the client, supports token and model environment variables, documents setup and privacy options, and tests missing-token handling. ChangesAleph Alpha completion tracing example
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant main.main
participant OpenTelemetry
participant AlephAlphaInstrumentor
participant Aleph Alpha Client
participant ConsoleSpanExporter
main.main->>OpenTelemetry: configure console span export
main.main->>AlephAlphaInstrumentor: instrument client
main.main->>Aleph Alpha Client: submit completion request
Aleph Alpha Client-->>ConsoleSpanExporter: export completion span
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
Pull request overview
Adds a beginner-friendly, minimal Aleph Alpha completion tracing example to the AlephAlpha instrumentation package, including runnable instructions and a small no-network test to validate the missing-token error path.
Changes:
- Introduces an
examples/basic_completionscript that configures OpenTelemetry withConsoleSpanExporterand instruments Aleph Alpha client calls. - Documents setup, env vars (
AA_TOKEN,AA_MODEL,TRACELOOP_TRACE_CONTENT), and what spans/attributes to expect. - Adds a no-network pytest validating the “missing token” exit code + stderr messaging.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/main.py | Adds a minimal runnable completion call with explicit tracer provider + console span exporter. |
| packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/README.md | Provides step-by-step instructions and explains expected telemetry output and privacy controls. |
| packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/requirements.txt | Pins the minimal dependencies and installs the local package in editable mode for the example. |
| packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/test_main.py | Adds a no-network test for the missing AA_TOKEN path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| AA_MODEL="your-model" uv run --no-project --with-requirements requirements.txt python main.py | ||
| ``` | ||
|
|
||
| The terminal prints the model response followed by an OpenTelemetry span named `alephalpha.completion`. The span includes the model, request type, and usage attributes. Prompt and completion content follows the instrumentation privacy setting; set `TRACELOOP_TRACE_CONTENT=false` to disable content capture. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/test_main.py (1)
6-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the complete actionable message.
assert "AA_TOKEN" in captured.errcan pass for a non-actionable message. Assert the guidance emitted bypackages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/main.pyLine 27.Suggested test assertion
- assert "AA_TOKEN" in captured.err + assert "Set AA_TOKEN before running this example." in captured.err🤖 Prompt for 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. In `@packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/test_main.py` around lines 6 - 11, Update test_missing_token_returns_actionable_error to assert the complete actionable guidance emitted by main.main when AA_TOKEN is missing, matching the message at the error output in main.py rather than only checking for the token name. Preserve the existing exit-code and stderr capture assertions.
🤖 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/opentelemetry-instrumentation-alephalpha/examples/basic_completion/README.md`:
- Line 32: Update the documented output order in the basic completion README to
state that the OpenTelemetry span is printed first, followed by the model
response. Preserve the existing details about the span name, attributes, and
content-capture setting.
---
Nitpick comments:
In
`@packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/test_main.py`:
- Around line 6-11: Update test_missing_token_returns_actionable_error to assert
the complete actionable guidance emitted by main.main when AA_TOKEN is missing,
matching the message at the error output in main.py rather than only checking
for the token name. Preserve the existing exit-code and stderr capture
assertions.
🪄 Autofix
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 Plus
Run ID: f2ce1a46-13cd-42ca-a695-a20ff50d3f8a
📒 Files selected for processing (4)
packages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/README.mdpackages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/main.pypackages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/requirements.txtpackages/opentelemetry-instrumentation-alephalpha/examples/basic_completion/test_main.py
Closes #4069
What changed
ConsoleSpanExporterso beginners can see the completed span without a collector or hosted account.Validation
ruff check .pytest -q(1 passed)AA_TOKENmessage.The example installs the local instrumentation package in editable mode, so it exercises the checked-out code rather than an unrelated published version.
Summary by CodeRabbit