Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

KafkaChannel Tracing #1155

Merged
merged 11 commits into from
Jul 22, 2020
Merged

Conversation

slinkydeveloper
Copy link
Contributor

Fixes #1139

Proposed Changes

  • 🎁 KafkaChannel now implements tracing

Release Note

KafkaChannel now correctly implements tracing using eventing-wise tracing configuration from config-tracing

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 22, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Apr 22, 2020
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 22, 2020
@slinkydeveloper
Copy link
Contributor Author

/assign @ian-mi

@slinkydeveloper
Copy link
Contributor Author

Example of tracing from IMC:

Screenshot_2020-04-22 Zipkin

KafkaChannel with this patch (same requests flow):

Screenshot_2020-04-22 Zipkin(1)

The obvious problem is that the span of inbound KafkaChannel ends when the message is inserted into the topic, and the dispatcher on the other side tries to rebuild the parent span using the ce attributes.

kafka/channel/pkg/dispatcher/dispatcher.go Outdated Show resolved Hide resolved
kafka/channel/pkg/dispatcher/dispatcher.go Outdated Show resolved Hide resolved
kafka/channel/pkg/dispatcher/dispatcher.go Outdated Show resolved Hide resolved
kafka/channel/pkg/dispatcher/dispatcher.go Outdated Show resolved Hide resolved
kafka/channel/pkg/dispatcher/dispatcher.go Outdated Show resolved Hide resolved
// If the span is not recorded, we just don't send these info
span := trace.FromContext(ctx)
defer span.End()
if span.IsRecordingEvents() {
Copy link
Contributor

Choose a reason for hiding this comment

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

trace context propagation should probably happen regardless of whether events are recorded.

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 think what we do here is fine because it's similar to doing span.IsRecordingEvents(): if you're not recording the span, there is no need to do the hard lifting for writing the span and reading it from the other side.

Copy link
Contributor

Choose a reason for hiding this comment

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

Trace context is meant to be propagated regardless of sampling decision, otherwise there would be no need for a sampled flag. Here's zipkin's documentation on the reason for doing so: https://github.com/openzipkin/b3-propagation#why-send-trace-ids-with-a-reject-sampling-decision.

kafka/channel/pkg/dispatcher/dispatcher.go Outdated Show resolved Hide resolved
Copy link
Member

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 23, 2020
@slinkydeveloper
Copy link
Contributor Author

slinkydeveloper commented Apr 23, 2020

During the CloudEvents WG meeting we just find out that this implementation is wrong, because it should not touch the ce-traceparent extension. We need to write this information in another cloudevent extension

@ian-mi
Copy link
Contributor

ian-mi commented Apr 23, 2020

During the CloudEvents WG meeting we just find out that this implementation is wrong, because it should not touch the ce-traceparent extension. We need to write this information in another cloudevent extension

I'm not sure what you mean by this, ce-traceparent is meant to be used for trace context propagation.

@slinkydeveloper
Copy link
Contributor Author

I'm not sure what you mean by this, ce-traceparent is meant to be used for trace context propagation.

But the event creator should set it, middlewares should not touch it. I'll send you the link to the PR to the spec with the clarification discussed today during the meeting.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 3, 2020
@slinkydeveloper
Copy link
Contributor Author

slinkydeveloper commented May 4, 2020

I propose for now to unblock this PR adding a traceparent/tracestate header backed by us. When the spec clarifies the goals of DCE, we can go ahead and remove our code for traceparent/tracestate.

@ian-mi How do you propose to serialize/deserialize traceparent/tracestate without adding a new library? Should we revert the code we used to have in eventing? knative/eventing#2873

@knative-prow-robot knative-prow-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 4, 2020
@slinkydeveloper
Copy link
Contributor Author

Since now the spec is more specific, how do we want to proceed on this?

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 24, 2020
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 2, 2020
@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 2, 2020
@slinkydeveloper
Copy link
Contributor Author

/retest

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-eventing-contrib-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
kafka/channel/pkg/dispatcher/dispatcher.go 62.6% 59.0% -3.6
kafka/channel/pkg/dispatcher/tracing.go Do not exist 91.7%

@slinkydeveloper slinkydeveloper changed the title [WIP] KafkaChannel Tracing KafkaChannel Tracing Jul 20, 2020
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 20, 2020
Copy link
Member

@matzew matzew 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

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, slinkydeveloper

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:
  • OWNERS [matzew,slinkydeveloper]

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

@knative-prow-robot knative-prow-robot merged commit 8f6e709 into knative:master Jul 22, 2020
@slinkydeveloper slinkydeveloper deleted the issues/1139 branch July 22, 2020 09:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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.

Implement tracing for KafkaChannel
7 participants