Skip to content

Add GitHub agentic workflow (gh-aw) instrumentation#3298

Merged
plengauer merged 3 commits into
mainfrom
copilot/add-github-agentic-workflow-instrumentation
Apr 10, 2026
Merged

Add GitHub agentic workflow (gh-aw) instrumentation#3298
plengauer merged 3 commits into
mainfrom
copilot/add-github-agentic-workflow-instrumentation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

github/gh-aw/actions/setup is a JavaScript action that writes shell scripts to a configurable destination directory. Those scripts are subsequently invoked via absolute paths, bypassing the normal shell instrumentation pipeline.

Changes

  • actions/instrument/job/decorate_action.sh: After any JavaScript action completes successfully, detect if it was github/gh-aw/actions/setup (via GITHUB_ACTION_REPOSITORY + GITHUB_ACTION_PATH suffix check) and inject . otel.sh after the shebang in every .sh file found recursively under INPUT_DESTINATION
if [ "$exit_code" = 0 ] && [ "${GITHUB_ACTION_REPOSITORY:-}" = "github/gh-aw" ] && \
   case "${GITHUB_ACTION_PATH%/}" in */actions/setup) true;; *) false;; esac && \
   [ -n "${INPUT_DESTINATION:-}" ]; then
  find "${INPUT_DESTINATION}" -name "*.sh" 2>/dev/null | while IFS= read -r script_file; do
    sed -i 's~#!/bin/sh~#!/bin/sh\n. otel.sh~g' "$script_file" 2>/dev/null || true
    sed -i 's~#!/bin/bash~#!/bin/bash\n. otel.sh~g' "$script_file" 2>/dev/null || true
  done || true
fi

Pre-instrumenting the files at setup time means they are self-instrumenting regardless of how they are later invoked (absolute path, relative path, sourced). The || true / 2>/dev/null guards ensure the original exit_code is never affected. Follows the same sed pattern used by the copilot and CodeQL instrumentation modules.

Copilot AI linked an issue Apr 3, 2026 that may be closed by this pull request
@plengauer
Copy link
Copy Markdown
Owner

Hello, thanks for contributing for the first time!

Agent-Logs-Url: https://github.com/plengauer/Thoth/sessions/aa0e8b2e-b947-4903-8e31-dbb9770a4313

Co-authored-by: plengauer <100447901+plengauer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add GitHub agentic workflow instrumentation Add GitHub agentic workflow (gh-aw) instrumentation Apr 3, 2026
Copilot AI requested a review from plengauer April 3, 2026 20:35
Copy link
Copy Markdown
Owner

@plengauer plengauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please address the changes

Comment thread actions/instrument/job/decorate_action.sh Outdated
Copilot AI requested a review from plengauer April 3, 2026 22:53
@plengauer plengauer marked this pull request as ready for review April 3, 2026 22:54
@plengauer plengauer requested a review from moflwi as a code owner April 3, 2026 22:54
Copilot AI review requested due to automatic review settings April 3, 2026 22:54
@plengauer plengauer enabled auto-merge (squash) April 3, 2026 22:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds post-action instrumentation for the github/gh-aw/actions/setup JavaScript action by rewriting generated shell scripts so they source otel.sh, ensuring OpenTelemetry instrumentation is applied even when scripts are invoked via absolute paths.

Changes:

  • Detect successful completion of github/gh-aw/actions/setup and locate the action’s configured INPUT_DESTINATION.
  • Recursively find *.sh files under INPUT_DESTINATION and insert . otel.sh after common shebangs using sed -i.

Comment thread actions/instrument/job/decorate_action.sh
Comment thread actions/instrument/job/decorate_action.sh
Comment thread actions/instrument/job/decorate_action.sh
Comment thread actions/instrument/job/decorate_action.sh
@plengauer plengauer merged commit 3ee7869 into main Apr 10, 2026
576 checks passed
@plengauer plengauer deleted the copilot/add-github-agentic-workflow-instrumentation branch April 10, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add github agentic workflow instrumentaiton

4 participants