Repository navigation
refactor(client): remove two unused OpenLLMetry span helpers - #111
Conversation
…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.
5f5775d to
0be21dd
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ 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.
#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
left a comment
There was a problem hiding this comment.
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.pyand__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. Thegen_ai.prompt.N.*/gen_ai.completion.N.*keys Monitoring reads are still written bycontent.py(_set_openllmetry_messages, line 388). Theprompt_tokens/completion_tokensaliases still come fromset_usage_span_attributes, whichtest_span_usage.py:301pins. 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/setOpenLLMetryCompletionleft. JS never exported them fromindex.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 releasedlaunchdarkly-ai-serverfrom 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 withrefactor(client):and no!orBREAKING 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.pyand the usage-alias test intest_span_usage.pycover them.
| set_model_identity_attributes, | ||
| set_openllmetry_completion, | ||
| set_openllmetry_prompt, | ||
| set_usage_span_attributes, |
There was a problem hiding this comment.
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.
Summary
set_openllmetry_promptandset_openllmetry_completionhave had no callers since the span work moved every handler onto the content layer incontent.py.TELEMETRY-CONTRACT.mdsaid 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 checkpasses on the changed files.Matching TypeScript cleanup: launchdarkly/js-ai-sdk#88
Original branch:
ag/remove-openllmetry-helpersNote
Overview
Removes legacy
set_openllmetry_promptandset_openllmetry_completionfrom the client package after handlers already write prompts, completions, and usage throughcontent.pyandset_usage_span_attributes.The helpers are dropped from
utils.py, unexported fromlaunchdarkly_ai_server, andTELEMETRY-CONTRACT.mdsection 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 inutils.py.Reviewed by Cursor Bugbot for commit 0be21dd. Bugbot is set up for automated code reviews on this repo. Configure here.