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

contrib/k8s.io/client-go: inject the traceID as kube auditID #351

Merged
merged 6 commits into from
Oct 31, 2018

Conversation

JulienBalestra
Copy link
Contributor

This allows to provide the Kubernetes Audit-ID to the kube-apiserver see.

With this change, we could then use datadog distributing tracing capabilities (audit logs) in the apiserver side.

}
kubeAuditID := strconv.FormatUint(traceID, 10)
req.Header.Set("Audit-Id", kubeAuditID)
span.SetTag("kubernetes.auditID", kubeAuditID)
Copy link
Contributor

@gbbr gbbr Oct 29, 2018

Choose a reason for hiding this comment

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

I think kubernetes.audit_id would be more standard to APM (and the actual header itself). Would this change be troublesome for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not at all 👍

}))
}

func requestToResource(method, path string) string {
func RequestToResource(method, path string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this made public API? If there's a good reason it's fine, but then let's clearly document it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to use this part of the code to generate traces from the apiserver side while parsing the Kubernetes audit logs.
It avoids me to repeat this function and keep a coherence there.
The goal of this is to set a distributed trace.
Does it make sense ?
I'll document this properly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. Let's keep it then. Was just making sure this was intentional.

Copy link
Contributor

@gbbr gbbr 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, happy to merge this once the small changes are applied.

contrib/k8s.io/client-go/kubernetes/kubernetes.go Outdated Show resolved Hide resolved
}))
}

func requestToResource(method, path string) string {
func RequestToResource(method, path string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. Let's keep it then. Was just making sure this was intentional.

JulienBalestra and others added 4 commits October 30, 2018 14:39
Co-Authored-By: JulienBalestra <julien.balestra@gmail.com>
Co-Authored-By: JulienBalestra <julien.balestra@gmail.com>
@gbbr gbbr changed the title kubernetes: inject the traceID as kube auditID contrib/k8s.io/client-go: inject the traceID as kube auditID Oct 31, 2018
traceID := span.Context().TraceID()
if traceID == 0 {
// tracer is not running
return
Copy link
Contributor

Choose a reason for hiding this comment

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

What's wrong with the alignment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I accepted the github suggestion 😆 going to fix it in the old way

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok then I'll take the fall for that 😅

Signed-off-by: JulienBalestra <julien.balestra@datadoghq.com>
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Thanks for this change and for being patient with my review.

@gbbr gbbr merged commit b2aa429 into v1 Oct 31, 2018
@gbbr
Copy link
Contributor

gbbr commented Oct 31, 2018

Will include this in 1.5.0 next week.

@gbbr gbbr deleted the JulienBalestra/kube-audit branch October 31, 2018 13:48
@JulienBalestra JulienBalestra removed the request for review from dd-caleb March 20, 2019 15:02
mingrammer pushed a commit to mingrammer/dd-trace-go that referenced this pull request Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants