-
Notifications
You must be signed in to change notification settings - Fork 44
fix(sdk): export getTraceloopTracer for direct tracer access #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Allows users to access the OpenTelemetry tracer instance used by the SDK for custom span creation and tracing operations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughAdds a new exported alias getTraceloopTracer (alias of getTracer) and re-exports it from the node-server SDK entry, expanding the public API. No runtime or control-flow changes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Looks good to me! 👍
Reviewed everything up to fd1c43d in 25 seconds. Click for details.
- Reviewed
25
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/traceloop-sdk/src/lib/node-server-sdk.ts:37
- Draft comment:
Exporting getTraceloopTracer is clear, but consider adding a brief JSDoc comment to explain its purpose and relation to getTracer for future maintainers. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
2. packages/traceloop-sdk/src/lib/tracing/tracing.ts:15
- Draft comment:
The alias 'getTraceloopTracer' is a straightforward alias for getTracer. Consider adding a comment noting that this alias is maintained for backward compatibility and direct tracer access. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
Workflow ID: wflow_rcKxR04CfTqkpeuB
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/traceloop-sdk/src/lib/tracing/tracing.ts (3)
15-16
: Public API polish: add JSDoc and explicit typing to stabilize the contract.Since this becomes part of the public surface, add a brief doc (including guidance to prefer higher-level helpers for LLM work) and fix the type to be explicit.
Apply this diff to the changed lines:
- export const getTraceloopTracer = getTracer; + /** + * Returns the OpenTelemetry Tracer used by Traceloop. + * + * Note: For manual LLM operations, prefer using trace.withLLMSpan from @traceloop/node-server-sdk. + */ + export const getTraceloopTracer: typeof getTracer = getTracer;
1-3
: Avoid deep import of Context; use the public @opentelemetry/api types.Importing from "@opentelemetry/api/build/src/…" reaches into internals and may break on minor updates. Pull
Context
(and optionallyTracer
) from the root export and makegetTracer
’s return type explicit.Apply this refactor:
- import { trace, createContextKey } from "@opentelemetry/api"; - import { Context } from "@opentelemetry/api/build/src/context/types"; + import { trace, createContextKey, type Context, type Tracer } from "@opentelemetry/api"; @@ -export const getTracer = () => { - return trace.getTracer(TRACER_NAME); -}; +export const getTracer = (): Tracer => { + return trace.getTracer(TRACER_NAME); +};
7-9
: Typo in exported constant: consider adding a correctly spelled alias (non-breaking).
ASSOCATION_PROPERTIES_KEY
is misspelled. Since it’s exported, renaming would be breaking. Add a correctly spelled alias and deprecate the old name in docs.Add this line near the existing export:
export const ASSOCIATION_PROPERTIES_KEY = ASSOCATION_PROPERTIES_KEY;Then mark
ASSOCATION_PROPERTIES_KEY
as deprecated in JSDoc and preferASSOCIATION_PROPERTIES_KEY
in examples.packages/traceloop-sdk/src/lib/node-server-sdk.ts (1)
37-37
: Prefer re-exporting from the tracing barrel to avoid deep path coupling.Most exports here come from
./tracing
. Re-exporting from the barrel keeps paths consistent and future-proof if internal filenames move.Apply this diff here:
-export { getTraceloopTracer } from "./tracing/tracing"; +export { getTraceloopTracer } from "./tracing";And ensure the barrel exports it (in
packages/traceloop-sdk/src/lib/tracing/index.ts
):export { getTraceloopTracer } from "./tracing";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/traceloop-sdk/src/lib/node-server-sdk.ts
(1 hunks)packages/traceloop-sdk/src/lib/tracing/tracing.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Import AI/LLM semantic attribute constants from @traceloop/ai-semantic-conventions rather than hardcoding strings
Files:
packages/traceloop-sdk/src/lib/tracing/tracing.ts
packages/traceloop-sdk/src/lib/node-server-sdk.ts
packages/traceloop-sdk/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/traceloop-sdk/**/*.{ts,tsx}
: Use the provided decorators (@workflow, @task, @agent) for workflow/task/agent spans instead of re-implementing them
For manual LLM operations, use trace.withLLMSpan from @traceloop/node-server-sdk
Files:
packages/traceloop-sdk/src/lib/tracing/tracing.ts
packages/traceloop-sdk/src/lib/node-server-sdk.ts
packages/traceloop-sdk/src/lib/node-server-sdk.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Register new instrumentation packages during SDK initialization
Files:
packages/traceloop-sdk/src/lib/node-server-sdk.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
PR: traceloop/openllmetry-js#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/**/*.{ts,tsx} : For manual LLM operations, use trace.withLLMSpan from traceloop/node-server-sdk
Learnt from: CR
PR: traceloop/openllmetry-js#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/src/lib/node-server-sdk.ts : Register new instrumentation packages during SDK initialization
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
PR: traceloop/openllmetry-js#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/**/*.{ts,tsx} : For manual LLM operations, use trace.withLLMSpan from traceloop/node-server-sdk
Applied to files:
packages/traceloop-sdk/src/lib/tracing/tracing.ts
packages/traceloop-sdk/src/lib/node-server-sdk.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
PR: traceloop/openllmetry-js#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/src/lib/node-server-sdk.ts : Register new instrumentation packages during SDK initialization
Applied to files:
packages/traceloop-sdk/src/lib/node-server-sdk.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
PR: traceloop/openllmetry-js#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/package.json : When adding a new instrumentation package, add it to the main SDK dependencies
Applied to files:
packages/traceloop-sdk/src/lib/node-server-sdk.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
PR: traceloop/openllmetry-js#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx} : Import AI/LLM semantic attribute constants from traceloop/ai-semantic-conventions rather than hardcoding strings
Applied to files:
packages/traceloop-sdk/src/lib/node-server-sdk.ts
🧬 Code graph analysis (1)
packages/traceloop-sdk/src/lib/tracing/tracing.ts (1)
packages/traceloop-sdk/src/lib/node-server-sdk.ts (1)
getTraceloopTracer
(37-37)
🔇 Additional comments (3)
packages/traceloop-sdk/src/lib/tracing/tracing.ts (1)
15-16
: LGTM on the new public alias.Exporting
getTraceloopTracer
as an alias togetTracer
cleanly exposes the tracer without behavior change.packages/traceloop-sdk/src/lib/node-server-sdk.ts (2)
37-37
: Re-export looks good and matches the PR intent.This exposes the tracer alias via the main SDK entry without altering behavior.
37-37
: Add a quick smoke test and doc note to reduce adoption friction.
- Test: ensure the symbol is exported and returns the same tracer as
getTracer
.- Docs: one line in README/API docs to warn that LLM spans should use
trace.withLLMSpan
.You can add a minimal test like:
// packages/traceloop-sdk/test/getTraceloopTracer.spec.ts import { getTraceloopTracer } from "../src/lib/node-server-sdk"; import { trace } from "@opentelemetry/api"; describe("getTraceloopTracer", () => { it("returns the Traceloop tracer", () => { const t = getTraceloopTracer(); const same = trace.getTracer("@traceloop/node-server-sdk"); // OTel may return the same instance for identical name/version expect(t).toBeDefined(); // If identity is not guaranteed across SDKs, check a property: expect((t as any).instrumentationLibrary?.name ?? (t as any).instrumentationScope?.name) .toBe("@traceloop/node-server-sdk"); }); });Also confirm versioning (minor bump) since this expands the public API, and add a short note in the CHANGELOG.
Summary
getTraceloopTracer
function from the main SDKgetTracer
functionTest plan
getTraceloopTracer
🤖 Generated with Claude Code
Important
Exports
getTraceloopTracer
from SDK for direct OpenTelemetry tracer access, maintaining backward compatibility.getTraceloopTracer
fromnode-server-sdk.ts
for direct access to OpenTelemetry tracer.getTraceloopTracer
is an alias for existinggetTracer
intracing.ts
.getTracer
function.getTraceloopTracer
.This description was created by
for fd1c43d. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit