Skip to content

Conversation

nirga
Copy link
Member

@nirga nirga commented Aug 26, 2025

Summary

  • Exports getTraceloopTracer function from the main SDK
  • Allows users to access the OpenTelemetry tracer instance for custom span creation
  • Maintains backward compatibility with existing internal getTracer function

Test plan

  • Verify the function is properly exported from the main SDK package
  • Test that users can import and use getTraceloopTracer
  • Ensure existing functionality remains unchanged

🤖 Generated with Claude Code


Important

Exports getTraceloopTracer from SDK for direct OpenTelemetry tracer access, maintaining backward compatibility.

  • Functionality:
    • Exports getTraceloopTracer from node-server-sdk.ts for direct access to OpenTelemetry tracer.
    • getTraceloopTracer is an alias for existing getTracer in tracing.ts.
  • Compatibility:
    • Maintains backward compatibility with existing getTracer function.
  • Testing:
    • Verify export and usability of getTraceloopTracer.
    • Ensure no changes to existing functionality.

This description was created by Ellipsis for fd1c43d. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features
    • Introduced a new public API alias to retrieve the tracer, expanding the SDK’s surface for easier integration and clearer naming.
    • Existing APIs remain unchanged and fully compatible; this is an additive, opt-in capability with no behavioral changes.
    • Developers can use either naming convention without migration.
    • Current documentation and examples continue to work, with the new alias available for new code.

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>
Copy link

coderabbitai bot commented Aug 26, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary of changes
Tracing API export additions
packages/traceloop-sdk/src/lib/tracing/tracing.ts, packages/traceloop-sdk/src/lib/node-server-sdk.ts
Introduced getTraceloopTracer as an alias to getTracer and re-exported it from the SDK entry point; no logic modifications.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I twitch my nose at freshly traced air,
A new name hops in without a care—
getTraceloopTracer, ears up high,
Same swift path, a different sky.
I stamp my paw: exports aligned,
Carrots cached, code neatly refined. 🥕✨

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch export-traceloop-tracer

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 2 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% <= threshold 50% 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% <= threshold 50% None

Workflow ID: wflow_rcKxR04CfTqkpeuB

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@nirga nirga changed the title feat(sdk): export getTraceloopTracer for direct tracer access fix(sdk): export getTraceloopTracer for direct tracer access Aug 26, 2025
Copy link

@coderabbitai coderabbitai bot left a 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 optionally Tracer) from the root export and make getTracer’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 prefer ASSOCIATION_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.

📥 Commits

Reviewing files that changed from the base of the PR and between f25940f and fd1c43d.

📒 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 to getTracer 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.

@nirga nirga merged commit 768ad76 into main Aug 27, 2025
6 checks passed
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.

2 participants