Skip to content

refactor(client): remove two unused OpenLLMetry span helpers - #111

Merged
apucacao merged 2 commits into
mainfrom
ag/remove-openllmetry-helpers-clean
Oct 13, 2026
Merged

apucacao merged 2 commits into
mainfrom
ag/remove-openllmetry-helpers-clean

Conversation

@apucacao

@apucacao apucacao commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

set_openllmetry_prompt and set_openllmetry_completion have had no callers since the span work moved every handler onto the content layer in content.py. TELEMETRY-CONTRACT.md said to keep them exported for one release and then remove them, and that release has shipped. This deletes them, along with the parity-test code that only existed to skip them, and updates the contract doc to match.

Testing

  • uv run pytest tests/test_cross_handler_parity.py: 87 passed, 11 skipped.
  • ruff check passes on the changed files.
  • Leaving the full suite and mypy to CI.

Matching TypeScript cleanup: launchdarkly/js-ai-sdk#88

Original branch: ag/remove-openllmetry-helpers


Note

Overview
Removes legacy set_openllmetry_prompt and set_openllmetry_completion from the client package after handlers already write prompts, completions, and usage through content.py and set_usage_span_attributes.

The helpers are dropped from utils.py, unexported from launchdarkly_ai_server, and TELEMETRY-CONTRACT.md section 11 now states they must not return. The cross-handler parity test no longer strips “superseded” function bodies before the vocabulary lock scan—that workaround existed only while dead code still lived in utils.py.

Reviewed by Cursor Bugbot for commit 0be21dd. Bugbot is set up for automated code reviews on this repo. Configure here.

…ompletion

Every handler writes conversation content through the content layer in
content.py since the span work, and the token aliases moved to
set_usage_span_attributes. Nothing in the SDK calls these two functions.
They stayed exported for one release so anyone importing them had time
to move; that release has shipped.

The parity test cut their bodies out before scanning for attribute keys,
so the dead writes could not satisfy the lock. With the functions gone,
that step has nothing left to do and goes too.
Section 11 still described both functions as live and called from every
handler, which stopped being true with the span work. It now says they
were removed from both SDKs and names the helpers that replaced them.
@apucacao
apucacao force-pushed the ag/remove-openllmetry-helpers-clean branch from 5f5775d to 0be21dd Compare September 25, 2026 15:16
@apucacao apucacao changed the title refactor(client)!: remove set_openllmetry_prompt and set_openllmetry_completion refactor(client): remove set_openllmetry_prompt and set_openllmetry_completion Sep 25, 2026
@apucacao apucacao changed the title refactor(client): remove set_openllmetry_prompt and set_openllmetry_completion refactor(client): remove two unused OpenLLMetry span helpers Sep 25, 2026
@apucacao

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0be21dd. Configure here.

@apucacao
apucacao marked this pull request as ready for review September 25, 2026 15:21
apucacao added a commit to launchdarkly/js-ai-sdk that referenced this pull request Oct 1, 2026
#89 will fix unit tests here (which I already broken on `main`).

## Summary

`setOpenLLMetryPrompt` and `setOpenLLMetryCompletion` in `utils.ts` have
had no callers since the content layer in `content.ts` started writing
the `gen_ai.prompt.{i}` and `gen_ai.completion.{i}` attributes. They
aren't exported from the package, so this deletes them.

## Testing

- `git grep` finds no remaining references.
- Leaving typecheck, lint, and tests to CI.

Matching Python cleanup: launchdarkly/python-ai-sdk#111

Original branch:
[`ag/remove-openllmetry-helpers`](https://github.com/launchdarkly/js-ai-sdk/tree/ag/remove-openllmetry-helpers)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Removes the internal **`setOpenLLMetryPrompt`** and
**`setOpenLLMetryCompletion`** helpers from
`packages/client/src/utils.ts`. They duplicated what the content layer
in `content.ts` already does when writing indexed `gen_ai.prompt.{i}`
and `gen_ai.completion.{i}` span attributes for Gonfalon’s LLM Summary
tab.
> 
> Neither helper was exported from the package and there are no
remaining call sites, so this is dead-code cleanup only (aligned with
the matching Python SDK change).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
88309e2. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

@jeffdupont jeffdupont left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with the 1.0 freeze in mind. Nothing blocking. This is item D in the 1.0 API-surface plan, and it's the right call: both helpers go and nothing breaks. On 0be21dd, make test passes (1316 passed, 11 skipped), and make typecheck and make lint are clean. It also merges cleanly onto current main (fee904a).

What I checked:

  • Nothing calls them. On current main, outside utils.py and __init__.py, the only mentions are the parity test's skip list and the contract doc, and this PR removes both. There's nothing in examples or docs. The gen_ai.prompt.N.* / gen_ai.completion.N.* keys Monitoring reads are still written by content.py (_set_openllmetry_messages, line 388). The prompt_tokens / completion_tokens aliases still come from set_usage_span_attributes, which test_span_usage.py:301 pins. So the span data contract doesn't change, only the public names do.
  • JS parity is done. launchdarkly/js-ai-sdk#88 merged on 1 Oct, and js-ai-sdk main has no setOpenLLMetryPrompt / setOpenLLMetryCompletion left. JS never exported them from index.ts, so its public surface doesn't move.
  • No spec change needed. ai-sdks-monorepo main doesn't name either function, and the attribute keys are unchanged.

Smaller notes:

  • These were public. Both names are in __all__ in every released launchdarkly-ai-server from 0.2.0 through 0.2.4, so anyone importing them will break on the next release. Removing them before 1.0 is fine. But with refactor(client): and no ! or BREAKING CHANGE: footer, release-please won't mention the removal in the changelog. I'd add one so the release notes say what went. Details inline.
  • The old contract text asked for direct tests of the replacements. Dropping that ask is fine now: tests/test_ld_span_attributes.py and the usage-alias test in test_span_usage.py cover them.

set_model_identity_attributes,
set_openllmetry_completion,
set_openllmetry_prompt,
set_usage_span_attributes,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two names were in __all__ from 0.2.0 through 0.2.4, so this is a breaking removal for anyone who imported them, even though nothing in the repo does. Pre-1.0 that's fine, and it matches the API-surface plan. Could the squash commit be refactor(client)!: or carry a BREAKING CHANGE: footer? Then release-please lists the removal in the changelog instead of hiding it under a refactor. With bump-minor-pre-major set, that makes the next release 0.3.0 rather than 0.2.5. I think that's the honest version number, but your call.

@apucacao
apucacao merged commit 9f0ece7 into main Oct 13, 2026
7 checks passed
@apucacao
apucacao deleted the ag/remove-openllmetry-helpers-clean branch October 13, 2026 17:10
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