feat(observability): identify agent spans#1978
Conversation
🦋 Changeset detectedLatest commit: 8d724ca The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| // Compatibility representation of InstrumentationScope until the Workers | ||
| // tracing API exposes native scope metadata. | ||
| "instrumentation_scope.name": "agents", | ||
| "instrumentation_scope.version": "0.18.0", |
There was a problem hiding this comment.
🟡 Telemetry reports a frozen SDK version that no longer matches the actual release
The reported instrumentation version is written as a fixed string ("0.18.0" at packages/agents/src/observability/agent-span-attributes.ts:12) instead of being read from the package version, so it stops matching the real SDK version as soon as the package is bumped (this PR is already a version bump).
Impact: Anyone reading the traces sees a version label that is wrong, making it impossible to reliably tell which SDK version produced a span.
Version constant drifts from package.json on every release
The current packages/agents/package.json version is 0.18.0, matching the literal. However this PR ships a patch changeset (.changeset/curly-agents-trace.md), so the released version becomes 0.18.1 while instrumentation_scope.version stays 0.18.0. There is no build-time injection (scripts/build.ts performs no version substitution) and the accompanying test (packages/agents/src/tests/observability/agent-span-attributes.test.ts:14) hardcodes the same literal, so it cannot detect drift against package.json. Every future release requires a manual edit here or the emitted scope version silently diverges from the true SDK version.
Prompt for agents
The instrumentation_scope.version in packages/agents/src/observability/agent-span-attributes.ts is hardcoded to "0.18.0" and will drift from the real package version on every release (this PR itself is a patch bump to 0.18.x). There is no build-time version injection in packages/agents/scripts/build.ts. Consider deriving the version from packages/agents/package.json (e.g. an import of the version, or a build-time define/replace injected into the bundle) so the emitted instrumentation_scope.version always matches the shipped SDK version. Update the test in packages/agents/src/tests/observability/agent-span-attributes.test.ts accordingly so it validates against the single source of truth rather than duplicating the literal.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
can we remove this. froxen versions are not gonna be fun
abdb1fd to
28cd075
Compare
agents
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
c46dfc7 to
4edca85
Compare
4edca85 to
8d724ca
Compare
Why
Users need to compare Agent token usage, cost, model preferences, latency, and errors without stitching together different identity fields.
Closes #1975
What
Add a consistent identity block to SDK-created Agent spans:
instrumentation_scope.nameinstrumentation_scope.versioncloudflare.agents.session.idcloudflare.agents.session.namegen_ai.agent.name