-
Notifications
You must be signed in to change notification settings - Fork 0
fix: give native graph spans their LaunchDarkly identity #121
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
base: main
Are you sure you want to change the base?
Changes from all commits
779a115
5f3e00a
6c19b28
e5e38c1
d693d68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -597,9 +597,11 @@ def make_track_data(node: GraphNode, graph_key: str, run_id: str) -> dict[str, A | |
| Builds the standard tracking payload for a graph node event. | ||
| Shared by all native graph adapters (openai-agents, claude-agents, langchain-agents). | ||
| """ | ||
| from .tracking import _try_get_environment_id # late import: tracking imports utils | ||
|
|
||
| meta = node.meta if isinstance(node.meta, dict) else {} | ||
| config = node.config if isinstance(node.config, dict) else {} | ||
| return { | ||
| track_data: dict[str, Any] = { | ||
| "runId": run_id, | ||
| "configKey": node.key, | ||
| "variationKey": meta.get("variationKey", ""), | ||
|
|
@@ -609,6 +611,40 @@ def make_track_data(node: GraphNode, graph_key: str, run_id: str) -> dict[str, A | |
| **model_stamps_from_meta(meta), | ||
| "graphKey": graph_key, | ||
| } | ||
| environment_id = _try_get_environment_id() | ||
| if environment_id: | ||
| track_data["environmentId"] = environment_id | ||
| return track_data | ||
|
|
||
|
|
||
| def make_graph_track_data(graph_key: str, run_id: str) -> dict[str, Any]: | ||
| """ | ||
| Builds the tracking payload for a native graph run as a whole. | ||
|
|
||
| The graph flag is itself the AI Config the trace belongs to, so its key is | ||
| both the config key and the graph key -- the same choice ``graph.py`` makes | ||
| for the SDK's own graph runner. There is no model or variation to report: a | ||
| graph flag carries a topology, and ``GraphDefinition`` does not expose its | ||
| ``_ldMeta``. | ||
|
|
||
| Native graph adapters pass this to ``set_ld_span_attributes`` so the | ||
| ``launchdarkly.graph`` span can be found by an AI Config Monitoring query. | ||
| """ | ||
| from .tracking import _try_get_environment_id # late import: tracking imports utils | ||
|
|
||
| track_data: dict[str, Any] = { | ||
| "runId": run_id, | ||
| "configKey": graph_key, | ||
| "variationKey": "", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "version": 1, | ||
| "modelName": "", | ||
| "providerName": "", | ||
| "graphKey": graph_key, | ||
| } | ||
| environment_id = _try_get_environment_id() | ||
| if environment_id: | ||
| track_data["environmentId"] = environment_id | ||
| return track_data | ||
|
|
||
|
|
||
| def _usable_context_key(value: Any) -> str | None: | ||
|
|
||
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.
Good to see
environmentIdhere. Thelaunchdarkly.graphspan this runner opens (lines ~919 and ~1135) still doesn't callset_ld_span_attributes, though, sograph()spans don't carrylaunchdarkly.config.keyor thefeature_flagevent that native-adapter spans now have. Is that intended?