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

WIP: Simple instrumentation with Jaeger backend #45962

Closed
wants to merge 5 commits into from

Conversation

gmarek
Copy link
Contributor

@gmarek gmarek commented May 17, 2017

Ref. #26507

This adds OpenTracing instrumentation to the apiserver and client-go. It does all instrumentation work and only thing that's left to allow users using client-go instrumentation is allowing passing context.Context to client calls (@caesarxuchao @kubernetes/sig-api-machinery-feature-requests). Once this is done we'll need to write a short doc describing how to use this.

cc @yurishkuro @bhs

Add OpenTracing instrumentation to client-go and apiserver.

@gmarek gmarek added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label May 17, 2017
@gmarek gmarek self-assigned this May 17, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 17, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gmarek
We suggest the following additional approver: bgrant0607

Assign the PR to them by writing /assign @bgrant0607 in a comment when ready.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels May 17, 2017
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 20, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2017
@k8s-github-robot k8s-github-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label May 25, 2017
@gmarek gmarek force-pushed the jaeger branch 2 times, most recently from 9b81105 to c0e347e Compare May 25, 2017 12:56
@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 25, 2017
@gmarek gmarek force-pushed the jaeger branch 3 times, most recently from fca9cee to c1c8315 Compare May 25, 2017 17:07
@gmarek
Copy link
Contributor Author

gmarek commented May 25, 2017

Only minor godep-related fixes are needed, I'll apply them tomorrow.

@k8s-github-robot k8s-github-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels May 25, 2017
@gmarek gmarek force-pushed the jaeger branch 2 times, most recently from b9da01f to 859c350 Compare May 26, 2017 10:31
@gmarek
Copy link
Contributor Author

gmarek commented May 26, 2017

@k8s-bot node e2e test this

if r.ctx == nil {
r.ctx = context.Background()
}
span, ctx := opentracing.StartSpanFromContext(r.ctx, fmt.Sprintf("%v %v", r.verb, r.resource))

Choose a reason for hiding this comment

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

note: this will create a bare bones span with little useful information. You may want to consider using https://github.com/opentracing-contrib/go-stdlib/ (or replicating that logic if you can do it more efficiently internally).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'd be way easier if there was a nethttp.NewFromTracer(tr *opentracing.Tracer, opts...) Tracer function in the library... Currently I don't think it's worth the effort.

Choose a reason for hiding this comment

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

if there was a nethttp.NewFromTracer(tr *opentracing.Tracer, opts...)

that's fair, my point is that a bare-bones span is not very useful when you actually want to troubleshoot some traces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think you can add such a function to the library?

Choose a reason for hiding this comment

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

I had a look, the existing code there is too coupled. I think it's simpler to add the tags explicitly, rather than pull another dependency just for that. You want at least these:

	ext.HTTPMethod.Set(span, req.Method)
	ext.HTTPUrl.Set(span, req.URL.String())
	ext.SpanKindRPCClient.Set(span)
	ext.Component.Set(span, componentName) // optional

If you have the peer/callee address easily accessible, it's also useful to set

        ext.PeerAddress.Set(span, address) // IP string or anything, really

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 26, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2017
@gmarek gmarek force-pushed the jaeger branch 2 times, most recently from db4f638 to ce6f6dc Compare May 30, 2017 11:20
Copy link

@bhs bhs left a comment

Choose a reason for hiding this comment

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

Main comment: this is a giant PR with the vendored code, etc... can you point me to the parts you are most concerned about / want feedback about from an OT standpoint?

I've made one tiny comment in the meantime. :)

Thanks!

}

func startTracing(req *http.Request, operationName string) (otSpan opentracing.Span, simpleTrace *utiltrace.Trace) {
trace := utiltrace.New(operationName)
Copy link

Choose a reason for hiding this comment

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

I'm sure you considered it, but why not add an opentracing.Span field to utiltrace.Trace? Then you wouldn't need to pass them around together.

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 wanted to get rid of the old trace library, and I figured that this was was easier.

@gmarek
Copy link
Contributor Author

gmarek commented May 30, 2017

@bhs - only first three commits matter. Rest is generated code and godeps.

@caesarxuchao
Copy link
Member

@gmarek is this PR targeting 1.7?

@gmarek
Copy link
Contributor Author

gmarek commented May 30, 2017

No, I don't think it is.

span := opentracing.SpanFromContext(r.ctx)
if span != nil {
ext.HTTPMethod.Set(span, req.Method)
ext.HTTPUrl.Set(span, req.URL.String())

Choose a reason for hiding this comment

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

nit: reuse url from above

span.Context(),
opentracing.HTTPHeaders,
opentracing.HTTPHeadersCarrier(req.Header))
}

r.backoffMgr.Sleep(r.backoffMgr.CalculateBackoff(r.URL()))
if retries > 0 {

Choose a reason for hiding this comment

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

what will happen if there are retries? The span seems to be created earlier, in the caller.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 2, 2017
@timothysc timothysc added this to the v1.8 milestone Jun 4, 2017
@timothysc
Copy link
Member

I saw this come in, but I'm prioritizing 1.7 items atm.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 12, 2017
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jun 12, 2017

@gmarek: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-federation-e2e-gce ba13d1385f9b48d9abd9198f0458bceb0a5cb956 link @k8s-bot pull-kubernetes-federation-e2e-gce test this
pull-kubernetes-bazel fa003ad link @k8s-bot pull-kubernetes-bazel test this
pull-kubernetes-verify fa003ad link @k8s-bot pull-kubernetes-verify test this

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-github-robot
Copy link

@gmarek PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 21, 2017
@timothysc
Copy link
Member

I'm for dropping in favor of updated Events proposal.

@gmarek gmarek closed this Jul 19, 2017
@bhs
Copy link

bhs commented Jul 19, 2017

@timothysc @gmarek for those of us who are not k8s insiders, can you provide a pointer to the "Events" proposal? thanks.

@gmarek
Copy link
Contributor Author

gmarek commented Jul 19, 2017

Sure, sorry - https://docs.google.com/a/google.com/document/d/13BeJlrEcJhSKgsHOHWmHdJGqXrjSm_o9XxOtwcN6yNg/edit?usp=sharing

I also wanted to finish this work (there's not a lot to do), so we have tracing inside API server, but I didn't have time:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants