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

feat: add tracing middleware #5397

Merged
merged 7 commits into from
Nov 18, 2022
Merged

Conversation

eddycharly
Copy link
Member

Explanation

This PR adds a tracing middleware to all admission request handlers.
Every request will have a trace starting from the beginning of the request handling chain.

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Merging #5397 (a45f000) into main (dccb1f6) will decrease coverage by 0.06%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #5397      +/-   ##
==========================================
- Coverage   36.37%   36.30%   -0.07%     
==========================================
  Files         169      170       +1     
  Lines       19036    19072      +36     
==========================================
  Hits         6924     6924              
- Misses      11320    11356      +36     
  Partials      792      792              
Impacted Files Coverage Δ
pkg/webhooks/handlers/admission.go 0.00% <0.00%> (ø)
pkg/webhooks/handlers/dump.go 46.96% <0.00%> (-3.85%) ⬇️
pkg/webhooks/handlers/filter.go 0.00% <0.00%> (ø)
pkg/webhooks/handlers/metrics.go 0.00% <0.00%> (ø)
pkg/webhooks/handlers/protect.go 0.00% <0.00%> (ø)
pkg/webhooks/handlers/trace.go 0.00% <0.00%> (ø)
pkg/webhooks/handlers/verify.go 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

eddycharly and others added 3 commits November 17, 2022 18:09
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Copy link
Member

@realshuting realshuting left a comment

Choose a reason for hiding this comment

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

Looks good! Only naming stuff.

}

// Span executes function doFn inside new span with `operationName` name and hooking as child to a span found within given context if any.
func Span1[T any](ctx context.Context, tracerName string, operationName string, doFn func(context.Context, trace.Span) T, opts ...trace.SpanStartOption) T {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename it to SpanAny()?

Copy link
Member Author

Choose a reason for hiding this comment

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

SpanAny does not make sense, 1 here refers to the number of element in the return statement (we could have Span2, Span3, etc... if we want to support funcs that return multiple values).

Copy link
Member

Choose a reason for hiding this comment

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

Got it, makes sense.

pkg/tracing/tracing.go Show resolved Hide resolved
@eddycharly eddycharly enabled auto-merge (squash) November 18, 2022 08:48
@eddycharly eddycharly merged commit 9983e82 into kyverno:main Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants