Skip to content

docs: fix README example so it compiles - #27

Open
SAY-5 wants to merge 1 commit into
traceloop:mainfrom
SAY-5:fix-readme-example
Open

docs: fix README example so it compiles#27
SAY-5 wants to merge 1 commit into
traceloop:mainfrom
SAY-5:fix-readme-example

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 18, 2026

Copy link
Copy Markdown

The "What do we instrument?" example in the README does not compile: it references an undefined config package, uses client and request before they exist, ignores the error returned by NewClient, and calls LogPrompt with the wrong attribute type. This rewrites it to match the working sample-app, and also fixes the getting-started snippet which was missing the os import and dropping the NewClient error. Closes #26.

Summary by CodeRabbit

  • Documentation
    • Updated Go code examples in README to reflect current SDK initialization and error handling patterns.
    • Refreshed API usage examples to align with recent changes.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0f7d4a0-cbc9-41fa-8200-c92cd1ecbc93

📥 Commits

Reviewing files that changed from the base of the PR and between ee5a5c8 and 22c93a7.

📒 Files selected for processing (1)
  • README.md

📝 Walkthrough

Walkthrough

Two Go code examples in README.md are updated to fix compilation errors. The "Getting Started" snippet gains fmt import and error handling for sdk.NewClient. The "What do we instrument?" snippet is rewritten with corrected NewClient error checking, an explicit openai.ChatCompletionRequest, and updated LogPrompt/ContextAttributes API usage.

Changes

README Go snippet corrections

Layer / File(s) Summary
Getting Started: SDK initialization with error handling
README.md
Adds fmt to imports, captures err from sdk.NewClient, prints the error and returns early on failure, then defers Shutdown on success.
Instrumentation example: corrected NewClient, LogPrompt, and ContextAttributes
README.md
Rewrites the "What do we instrument?" example: adds NewClient error check, introduces an explicit openai.ChatCompletionRequest, switches LogPrompt from (llmSpan, err) to direct assignment, replaces sdk.TraceloopAttributes/EntityName with sdk.ContextAttributes/WorkflowName, and uses ctx in the OpenAI completion call.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppity-hop through the docs I go,
Where broken snippets once caused woe.
fmt and err now stand in line,
ContextAttributes — oh so fine!
The README compiles, the rabbits cheer,
No more undefined errors here! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing README examples to compile correctly.
Linked Issues check ✅ Passed The PR directly addresses issue #26 by rewriting code examples to eliminate compilation errors and ensure they work without modification.
Out of Scope Changes check ✅ Passed All changes are focused on fixing compilation errors in README code examples, directly addressing the reported issue with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Example in readme does not compile

1 participant