[Go] Prevent genkit:isFailureSource attribute from propagating to parent spans

Open Beginner friendly
#5,153 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
go
Domain
observability

Research direction

Start in go/core/tracing/tracing.go and compare the error-handling flow with the ignoreFailedSpan logic in js/core/src/tracing/instrumentation.ts. Trace how errors move through nested spans and verify that only the deepest span receives genkit:isFailureSource, while parent spans recognize the marked error. Done means a single failure is not counted repeatedly along the call stack.

Written by the indexing model from the issue text.

Description

go

The Go implementation of Genkit instrumentation incorrectly marks every span in a failing call stack with the genkit:isFailureSource attribute. This attribute should only be set on the original (deepest) span where the error occurred.

Current Behavior (Go)

In go/core/tracing/tracing.go, the code sets sm.IsFailureSource = true whenever an error is returned, without checking if the error has already been "marked" by a child span. This leads to redundant marking as the error bubbles up.

Reference Behavior (JS)

The JavaScript implementation in js/core/src/tracing/instrumentation.ts correctly uses a flag (ignoreFailedSpan) to ensure isFailureSource is only set once at the origin.

Impact
  • Metrics Inaccuracy: Monitoring systems that aggregate failure counts based on the isFailureSource attribute will overcount a single failure multiple times (once for every span in the path).
  • UI Visualization: The Genkit Developer UI may fail to highlight the specific root cause correctly if multiple spans claim to be the source.
Proposed Solution

Update the error handling in go/core/tracing/tracing.go to only set sm.IsFailureSource = true if !isErrorAlreadyMarked(err). The error should then be wrapped using markErrorAsHandled(err) to ensure parents correctly identify it as already processed.

Dominant language
TypeScript
Stars
6.5k
Forks
845
Avg merge
3d 22h
Merged PRs (30d)
56

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from genkit-ai/genkit

All issues in genkit-ai/genkit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.