Skip to content

feat(tracing): add semantic span attributes to reconciler child spans - #10156

Open
Paramesh324 wants to merge 6 commits into
tektoncd:mainfrom
Paramesh324:issue_9785
Open

Paramesh324 wants to merge 6 commits into
tektoncd:mainfrom
Paramesh324:issue_9785

Conversation

@Paramesh324

@Paramesh324 Paramesh324 commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Add queryable attributes to all child spans in the TaskRun and PipelineRun reconcilers that previously carried zero attributes (22 of 26 spans were unqueryable timers).

What this PR does:

Add taskrun, pipelinerun, namespace, pipelinetask, step.count, failure.reason, done, pod, taskrun.count, child.pipelinerun, customrun, and other attributes to key spans (reconcile, createPod, failTaskRun, createTaskRun, resolvePipelineState, runNextSchedulableTask, stopSidecars, createChildPipelineRuns, createCustomRuns, etc.)
Use the existing attribute naming convention (taskrun/pipelinerun + namespace) consistently across all spans
Preserve root-span identity attributes on initTracing spans to keep root traces queryable
Operators can now filter and search traces in Jaeger/Tempo by task name, namespace, step count, or failure reason.

Fixes #9785

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Jun 1, 2026
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 1, 2026
@tekton-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign khrm after the PR has been reviewed.
You can assign the PR to them by writing /assign @khrm in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Paramesh324

Copy link
Copy Markdown
Contributor Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 1, 2026
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 4, 2026
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 4, 2026
@waveywaves

Copy link
Copy Markdown
Member

/retest

Comment thread pkg/reconciler/pipelinerun/tracing.go
Comment thread pkg/reconciler/taskrun/tracing.go
Comment thread pkg/reconciler/pipelinerun/pipelinerun.go Outdated
Paramesh324 added a commit to Paramesh324/pipeline that referenced this pull request Jun 13, 2026
Address review feedback on PR tektoncd#10156:
- Restore root-span identity attributes (taskrun/pipelinerun +
  namespace) on initTracing spans to keep root traces queryable
- Replace tekton.* prefixed attribute names with existing convention
  (taskrun, pipelinerun, namespace) for consistency
- Drop semconv k8s.namespace.name in favor of attribute.String
  ("namespace", ...) to avoid mixing naming conventions
Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
@Paramesh324
Paramesh324 requested a review from waveywaves June 13, 2026 12:18
@vdemeester
vdemeester requested a review from Copilot June 18, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances OpenTelemetry tracing in the TaskRun and PipelineRun reconcilers by attaching attributes to previously “attribute-less” child spans so they become filterable/queryable in tracing backends.

Changes:

  • Adds span.SetAttributes(...) to multiple child spans in taskrun and pipelinerun reconcilers (e.g., step counts, done status, failure reason).
  • Adds additional PipelineRun child-span attributes for task/taskrun/customrun creation paths.
  • Minor formatting refactors of existing SetAttributes calls.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
pkg/reconciler/taskrun/taskrun.go Adds attributes to several TaskRun reconciler child spans (e.g., step counts, done status, failure reason).
pkg/reconciler/pipelinerun/pipelinerun.go Adds attributes to several PipelineRun reconciler child spans and creation subroutines; some spans still miss namespace.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/reconciler/pipelinerun/pipelinerun.go
Comment thread pkg/reconciler/pipelinerun/pipelinerun.go
Comment thread pkg/reconciler/pipelinerun/pipelinerun.go
Comment thread pkg/reconciler/taskrun/taskrun.go
Comment thread pkg/reconciler/pipelinerun/pipelinerun.go
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 19, 2026
Paramesh324 added a commit to Paramesh324/pipeline that referenced this pull request Jun 22, 2026
Address review feedback on PR tektoncd#10156:
- Restore root-span identity attributes (taskrun/pipelinerun +
  namespace) on initTracing spans to keep root traces queryable
- Replace tekton.* prefixed attribute names with existing convention
  (taskrun, pipelinerun, namespace) for consistency
- Drop semconv k8s.namespace.name in favor of attribute.String
  ("namespace", ...) to avoid mixing naming conventions
Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 22, 2026
@waveywaves

Copy link
Copy Markdown
Member

/retest

Comment thread pkg/reconciler/taskrun/taskrun.go
Comment thread pkg/reconciler/pipelinerun/pipelinerun.go
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2026
Paramesh324 added a commit to Paramesh324/pipeline that referenced this pull request Jul 6, 2026
Address review feedback on PR tektoncd#10156:
- Restore root-span identity attributes (taskrun/pipelinerun +
  namespace) on initTracing spans to keep root traces queryable
- Replace tekton.* prefixed attribute names with existing convention
  (taskrun, pipelinerun, namespace) for consistency
- Drop semconv k8s.namespace.name in favor of attribute.String
  ("namespace", ...) to avoid mixing naming conventions
Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
Paramesh324 added a commit to Paramesh324/pipeline that referenced this pull request Jul 6, 2026
Address waveywaves review feedback on PR tektoncd#10156:
- Add TestChildSpanAttributes in taskrun/tracing_test.go that asserts
  stopSidecars span carries taskrun, namespace, and pod attributes
- Add TestChildSpanAttributes in pipelinerun/tracing_test.go that asserts
  durationAndCountMetrics span carries pipelinerun and done attributes
- Uses tracetest.SpanRecorder to export and inspect child spans

These tests lock in the attribute contract so any silent drift
in span attributes will be caught.

Fixes tektoncd#9785
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 6, 2026
@Paramesh324
Paramesh324 requested a review from waveywaves July 6, 2026 17:50
Comment thread pkg/reconciler/pipelinerun/pipelinerun.go Outdated
@Paramesh324
Paramesh324 requested a review from waveywaves July 13, 2026 05:02
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 10, 2026
Paramesh324 added a commit to Paramesh324/pipeline that referenced this pull request Sep 22, 2026
Address review feedback on PR tektoncd#10156:
- Restore root-span identity attributes (taskrun/pipelinerun +
  namespace) on initTracing spans to keep root traces queryable
- Replace tekton.* prefixed attribute names with existing convention
  (taskrun, pipelinerun, namespace) for consistency
- Drop semconv k8s.namespace.name in favor of attribute.String
  ("namespace", ...) to avoid mixing naming conventions
Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
Paramesh324 added a commit to Paramesh324/pipeline that referenced this pull request Sep 22, 2026
Address waveywaves review feedback on PR tektoncd#10156:
- Add TestChildSpanAttributes in taskrun/tracing_test.go that asserts
  stopSidecars span carries taskrun, namespace, and pod attributes
- Add TestChildSpanAttributes in pipelinerun/tracing_test.go that asserts
  durationAndCountMetrics span carries pipelinerun and done attributes
- Uses tracetest.SpanRecorder to export and inspect child spans

These tests lock in the attribute contract so any silent drift
in span attributes will be caught.

Fixes tektoncd#9785
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 22, 2026
@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.77%. Comparing base (61e0221) to head (9f9988f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10156      +/-   ##
==========================================
+ Coverage   90.73%   90.77%   +0.03%     
==========================================
  Files         297      297              
  Lines       22569    22665      +96     
==========================================
+ Hits        20478    20574      +96     
  Misses       2089     2089              
  Partials        2        2              
Flag Coverage Δ
unit-tests 90.77% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pkg/reconciler/taskrun/taskrun.go
Comment thread pkg/reconciler/taskrun/taskrun.go
ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "resolvePipelineState")
defer span.End()
span.SetAttributes(
attribute.String("pipelinerun", pr.Name),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Likewise, pipelinerun identifies the run rather than the referenced Pipeline. Since this PR closes #9785, which asks for Pipeline name or reference and status or outcome, could these spans expose a distinct Pipeline identity using the existing pipeline key and record outcome where known? pipelineMeta is already available in this path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding and testing the distinct pipeline attribute. The outcome portion remains. resolvePipelineState returns errors without recording them on the span, and reconcile likewise ends without outcome or error status. Could these paths use the existing recordSpanError helper or otherwise record the final outcome before we resolve this thread?

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 30, 2026
Add queryable attributes to all 22+ child spans in TaskRun and
PipelineRun reconcilers that previously carried zero attributes.

- Add tekton.taskrun.name, tekton.pipelinerun.name, tekton.pipeline.task.name,
  tekton.task.step.count, tekton.taskrun.failure.reason, and other semantic
  attributes to key spans (reconcile, createPod, failTaskRun, createTaskRun,
  resolvePipelineState, runNextSchedulableTask, stopSidecars, etc.)
- Replace ad-hoc attribute.String("namespace", ...) with OTel semconv
  k8s.namespace.name to align with the semconv v1.40.0 already vendored
- Remove duplicate SetAttributes from initTracing root spans that repeated
  the same name/namespace attributes already set on ReconcileKind spans

Operators can now filter traces in Jaeger/Tempo by outcome, task name,
step count, or failure reason.

Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
Address review feedback on PR tektoncd#10156:
- Restore root-span identity attributes (taskrun/pipelinerun +
  namespace) on initTracing spans to keep root traces queryable
- Replace tekton.* prefixed attribute names with existing convention
  (taskrun, pipelinerun, namespace) for consistency
- Drop semconv k8s.namespace.name in favor of attribute.String
  ("namespace", ...) to avoid mixing naming conventions
Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
Address Copilot review feedback: add namespace attribute to
createChildPipelineRuns, createTaskRuns, and createCustomRuns spans
for consistent queryability with their child span counterparts.
Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
Address waveywaves review feedback on PR tektoncd#10156:
- Add TestChildSpanAttributes in taskrun/tracing_test.go that asserts
  stopSidecars span carries taskrun, namespace, and pod attributes
- Add TestChildSpanAttributes in pipelinerun/tracing_test.go that asserts
  durationAndCountMetrics span carries pipelinerun and done attributes
- Uses tracetest.SpanRecorder to export and inspect child spans

These tests lock in the attribute contract so any silent drift
in span attributes will be caught.

Fixes tektoncd#9785
Address waveywaves review: PipelineRun/TaskRun names are
namespace-scoped, so every span that carries a name attribute
must also carry namespace for unambiguous querying.
Adds namespace to durationAndCountMetrics,
finishReconcileUpdateEmitEvents, updateLabelsAndAnnotations,
and updateTaskRunWithDefaultWorkspaces spans in both reconcilers.
Fixes tektoncd#9785

Signed-off-by: Parameshwaran Krishnasamy <Parameshwaran.K@ibm.com>
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 30, 2026
…spans

Address waveywaves review feedback:
- Add taskrun+namespace attributes to all 10 validation/substitution child
  spans (validateTaskSpecRequestResources, ValidateResolvedTask,
  ValidateEnumParam, ValidateParamArrayIndex, ValidateBindings,
  validateOverrides, validateTaskRunResults, applyParamsContextsResults-
  AndWorkspaces, ApplyParameters, ApplyWorkspaces) so they are queryable.
- Add 'task' attribute (rtr.TaskName) to reconcile, validateTaskRunResults,
  and applyParamsContextsResultsAndWorkspaces spans for Task identity.
- Add 'pipeline' attribute (pipelineMeta.Name) to reconcile and
  resolvePipelineState spans for Pipeline identity.
- Extend TestChildSpanAttributes with subtests covering task and pipeline
  attributes.

Fixes tektoncd#9785

@waveywaves waveywaves left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR adds operator visible tracing attributes and is labeled kind/feature, but the release note is still NONE. Please add a concise release note describing that PipelineRun and TaskRun spans now expose semantic attributes for filtering and diagnosis.

Please also squash the branch to a single commit after addressing the remaining feedback and before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tracing): add semantic span attributes to reconciler child spans

4 participants