Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate apiserver from utils/trace to component-base/tracing #113172

Merged
merged 1 commit into from Oct 27, 2022

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Oct 19, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

Part of #113170

Depends on #113183. See that PR for the proposed changes to utils/traces interfaces.

After this change, APIServerTracing traces will include spans from calls to tracing.Start(), and span events from calls to span.AddEvent(). Log-based "tracing" will continue to function exactly the same, with the exception a change to the wording of Step() calls that included an error.

If the APIServerTracing feature is disabled, the OpenTelemetry portion of these calls are no-ops.

Special notes for your reviewer:

Naming differences between utils/trace and component-base/tracing:

  • utiltrace.New(), and utiltrace.Nest() are replaced by tracing.Start()
    • the thing returned by this call is now called span instead of trace, which is more accurate
  • trace.Step() is replaced by span.AddEvent()
  • trace.LogIfLong() is replaced by span.End()
  • utiltrace.Field is replaced by attribute.KeyValue

This is intended to simply be a refactor, and shouldn't significantly change behavior when using the logging trace functionality. The only behavioral change is that trace.Step calls which specify an error have been split into a "succeeded" step without an error, and a "failed" step with an error. This is because err.Error() panics if err is nil.

In cases where a utiltrace.Trace was stored on an object, or passed via function, i've replaced those with Context-based passing of the current active span.

The component-base/tracing library gracefully handles invoking functions on spans retrieved from context. It is no longer necessary to check for nil before calling AddEvent or LogIfLong.

Does this PR introduce a user-facing change?

API Server Tracing now includes a variety of new spans and span events.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/blob/1954332075e9df9b51e1b04eecbb22537308f102/keps/sig-instrumentation/647-apiserver-tracing

/sig instrumentation
/kind feature
/priority important-soon

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. labels Oct 19, 2022
@dashpole
Copy link
Contributor Author

dashpole commented Oct 19, 2022

Ah, I didn't realize k8s.io/utils was the source of truth for that library. I'll have to make an update there first.

Edit: utils update kubernetes/utils#264.

@dashpole dashpole closed this Oct 19, 2022
@dashpole dashpole reopened this Oct 19, 2022
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. labels Oct 19, 2022
@dashpole dashpole changed the title Migrate util trace fields to opentelemetry attributes [WIP] Migrate util trace fields to opentelemetry attributes Oct 19, 2022
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 19, 2022
@dashpole dashpole changed the title [WIP] Migrate util trace fields to opentelemetry attributes [WIP] Migrate to updated util/traces interfaces Oct 19, 2022
@dashpole
Copy link
Contributor Author

cc @dgrisonnet @logicalhan

@dims
Copy link
Member

dims commented Oct 19, 2022

@swagatbora90 if you wanna do a code review!

@leilajal
Copy link
Contributor

/cc @logicalhan
/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Oct 20, 2022
@k8s-ci-robot k8s-ci-robot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 20, 2022
@dashpole dashpole changed the title [WIP] Migrate apiserver from utils/trace to component-base/tracing Migrate apiserver from utils/trace to component-base/tracing Oct 20, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 20, 2022
@dashpole
Copy link
Contributor Author

This is now ready for review.

Copy link
Member

@logicalhan logicalhan left a comment

Choose a reason for hiding this comment

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

/lgtm

This looks strictly better than it used to be. Thanks for making these changes!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 25, 2022
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Oct 26, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 27, 2022
@liggitt
Copy link
Member

liggitt commented Oct 27, 2022

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 27, 2022
Copy link
Member

@logicalhan logicalhan left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dashpole, liggitt, logicalhan

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot merged commit ae6dc59 into kubernetes:master Oct 27, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Oct 27, 2022
@leilajal
Copy link
Contributor

/triage accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants