Conversation
Add gh-aw.trigger.item_type, gh-aw.trigger.item_number, and gh-aw.trigger.label span attributes to both sendJobSetupSpan and sendJobConclusionSpan. These are read from awInfo.context in aw_info.json, which is written by buildAwContext() and contains the item_type, item_number, and trigger_label fields resolved from the GitHub event payload. Fixes #<issue-number> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/add39553-beaa-4834-b682-cb9c26b4f0b9 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds triggering GitHub item context to OTLP spans so traces can be correlated back to the originating issue/PR/discussion/check in observability backends.
Changes:
- Enriches
sendJobSetupSpanandsendJobConclusionSpanwithgh-aw.trigger.item_type,gh-aw.trigger.item_number, and optionalgh-aw.trigger.labelattributes sourced fromaw_info.json. - Updates inline documentation to describe the new attributes.
- Adds unit tests covering attribute emission/omission behavior for both spans.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/send_otlp_span.cjs | Reads trigger context from aw_info.json and conditionally emits it as span attributes for setup and conclusion spans. |
| actions/setup/js/send_otlp_span.test.cjs | Adds tests validating trigger attribute presence/absence (including when aw_info.json is missing). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
actions/setup/js/send_otlp_span.cjs:725
- Same normalization concern as in
sendJobSetupSpan: theseawInfo.contextfields are not trimmed. If a caller provides whitespace-only values inaw_context(which is accepted as primitives by generate_aw_info), they will be emitted as non-empty span attributes. Trimming before checking/adding the attributes would prevent spans from being tagged with effectively-empty trigger metadata.
const itemType = typeof awInfo.context?.item_type === "string" ? awInfo.context.item_type : "";
const itemNumber = typeof awInfo.context?.item_number === "string" ? awInfo.context.item_number : "";
const triggerLabel = typeof awInfo.context?.trigger_label === "string" ? awInfo.context.trigger_label : "";
- Files reviewed: 2/2 changed files
- Comments generated: 1
| const itemType = typeof awInfo.context?.item_type === "string" ? awInfo.context.item_type : ""; | ||
| const itemNumber = typeof awInfo.context?.item_number === "string" ? awInfo.context.item_number : ""; | ||
| const triggerLabel = typeof awInfo.context?.trigger_label === "string" ? awInfo.context.trigger_label : ""; |
There was a problem hiding this comment.
itemType, itemNumber, and triggerLabel are taken verbatim from awInfo.context and later emitted when truthy. If any of these fields are whitespace-only (e.g. " "), they will be emitted as span attributes even though they are effectively empty. Consider normalizing with .trim() (and using the trimmed value for both the if (...) check and the attribute value) so empty/whitespace values are cleanly omitted, matching the stated behavior of omitting empty strings.
This issue also appears on line 723 of the same file.
| const itemType = typeof awInfo.context?.item_type === "string" ? awInfo.context.item_type : ""; | |
| const itemNumber = typeof awInfo.context?.item_number === "string" ? awInfo.context.item_number : ""; | |
| const triggerLabel = typeof awInfo.context?.trigger_label === "string" ? awInfo.context.trigger_label : ""; | |
| const itemType = typeof awInfo.context?.item_type === "string" ? awInfo.context.item_type.trim() : ""; | |
| const itemNumber = typeof awInfo.context?.item_number === "string" ? awInfo.context.item_number.trim() : ""; | |
| const triggerLabel = typeof awInfo.context?.trigger_label === "string" ? awInfo.context.trigger_label.trim() : ""; |
🧪 Test Quality Sentinel ReportTest Quality Score: 80/100✅ Excellent test quality
Test Classification DetailsView All 6 Tests
|
Every
gh-awworkflow is triggered by a concrete GitHub item (issue, PR, discussion, check run), but neithersendJobSetupSpannorsendJobConclusionSpanemitted any of that context — making spans impossible to correlate with the triggering item in Grafana/Honeycomb.Changes
send_otlp_span.cjssendJobSetupSpanandsendJobConclusionSpannow readitem_type,item_number, andtrigger_labelfromawInfo.context(already written to/tmp/gh-aw/aw_info.jsonbybuildAwContext()) and conditionally emit them as span attributes:gh-aw.trigger.item_type—issue,pull_request,discussion,check_run, etc.gh-aw.trigger.item_number— sequential number of the triggering itemgh-aw.trigger.label— label name forlabeled/unlabeledevents; omitted otherwisesend_otlp_span.test.cjstrigger_label, and clean omission whenaw_info.jsonis absentExample span attributes on an issue-triggered run:
{ "key": "gh-aw.trigger.item_type", "value": { "stringValue": "issue" } }, { "key": "gh-aw.trigger.item_number", "value": { "stringValue": "42" } }