feat(webhook): add optional X-Ray instrumentation for GitHub event delivery latency - #5292
Open
wadherv wants to merge 11 commits into
Open
feat(webhook): add optional X-Ray instrumentation for GitHub event delivery latency#5292wadherv wants to merge 11 commits into
wadherv wants to merge 11 commits into
Conversation
…livery latency Add an opt-in `webhook_xray_github_latency_enabled` flag that adds an X-Ray annotation and a backdated synthetic "github" subsegment showing the delay between a GitHub workflow_job event's created_at and the webhook Lambda's invocation. Disabled by default since backdating trace timestamps is an unusual pattern; wired through the direct and eventbridge webhook submodules and the multi-runner module.
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
The
webhookLambda (lambdas/functions/webhook/src/webhook/index.ts) is the entry point for every GitHubworkflow_jobevent, but its X-Ray instrumentation only covers Lambda-internal and downstream-AWS-SDK timing. There is no visibility into the delivery/ingestion latency between when GitHub generated the event (workflow_job.created_at) and when the webhook Lambda actually began processing it — the gap could stem from GitHub's own delivery queue, network transit, API Gateway, or ingestion-side queuing/cold-start, and this instrumentation can't attribute it to either side by itself.We hit this directly: a workflow run was triggered by GitHub at
23:28:59but wasn't processed by our webhook Lambda until23:37:15— an ~8 minute gap — with no GitHub-side outage reported for that window. Diagnosing it required manually correlating the workflow run's GitHub timestamp against CloudWatch logs.This PR adds
instrumentGithubLatency(), called fromreadWorkflowJobEvent()(shared by bothpublishForRunnersandpublishOnEventBridge), which:workflow_job.created_atandDate.now().event_lag_ms) on the current segment via the sharedtracersingleton (@aws-github-runner/aws-powertools-util), so it's queryable/alertable directly.remote-namespace subsegment namedgithub, backdated to the event'screated_at, so the X-Ray service map shows a distinctgithubnode feeding into the webhook Lambda with a span representing the real end-to-end delay.The entire feature is disabled by default and gated behind a new boolean,
webhook_xray_github_latency_enabled(env varWEBHOOK_XRAY_GITHUB_LATENCY_ENABLED), since backdating a subsegment'sstart_timeis an unusual X-Ray pattern not every consumer of the module will want on by default. When the flag isfalse,instrumentGithubLatency()returns immediately — no annotation, no subsegment, zero behavior change for existing consumers.The new variable is threaded through the full config chain: root
variables.tf/main.tf→modules/webhook→ bothmodules/webhook/directandmodules/webhook/eventbridgesubmodules → the Lambda's environment block, and also throughmodules/multi-runnerfor consumers of that module.Test Plan
terraform fmt -check -recursiveclean.terraform validatepassing on the root module andmodules/multi-runner(pre-existing, unrelated deprecation warnings only).Durationcorrectly rolled up to the full backdated span,IsPartial: False, no fault/error flags, and the subsegment was promoted to a standalone linked segment in the trace (what renders as a distinct node in the Service Map).vitest/ESLint suite locally in this environment (nonode_modulesinstalled) — flagging for CI/reviewer to confirm.Related Issues
Addresses a gap identified in incident investigation; no visibility currently exists into GitHub-to-webhook delivery latency. (Link to feature-request issue to be added.)