feat: add rebased telemetry implementation#579
Open
lizradway wants to merge 5 commits intostrands-agents:mainfrom
Open
feat: add rebased telemetry implementation#579lizradway wants to merge 5 commits intostrands-agents:mainfrom
lizradway wants to merge 5 commits intostrands-agents:mainfrom
Conversation
poshinchen
reviewed
Feb 27, 2026
Comment on lines
+437
to
+447
| private _setAttributes(span: Span, attributes: Record<string, AttributeValue>): void { | ||
| for (const [key, value] of Object.entries(attributes)) { | ||
| if (value !== undefined && value !== null) { | ||
| try { | ||
| span.setAttribute(key, value) | ||
| } catch (err) { | ||
| logger.warn(`error=<${err}>, key=<${key}> | failed to set span attribute`) | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
We can remove this and use setAttributes from the span API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
/liz/otelbranch rebased with structured output changesagent.tsDifferences between /liz/otel branch :
Structural: _executeAgentLoop inlined into _stream
_executeAgentLoopmethod, with_streamhandling the agent span lifecycle around it.context.registerTool()/context.cleanup()must wrap the loop, and the agent span must wrap both._streamkeeps a single try/finally that handles both telemetry span cleanup and structured output cleanup.Similarly:
_executeAgentLoopand passed it toendAgentSpanin_stream'sfinally.let result: AgentResult | undefinedat the top of_streamso thefinallyblock can reference it for the agent span's response/stopReason attributes.Force tool continue
endAgentLoopSpan. Added an explicitendAgentLoopSpan(cycleSpan)before the continue to prevent span leaks._appendMessage is synchronous/ returns event for yielding
async _appendMessagethat invoked hooks directly.MessageAddedEventfor yielding — hooks are invoked centrally instream(). The rebase uses the current synchronous pattern.Related Issues
#69
Documentation PR
strands-agents/docs#557
Type of Change
New feature
Testing
How have you tested the change?
npm run checkChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.