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

Implement "b3 single" header format for zipkin #4712

Merged
merged 9 commits into from
Oct 24, 2018

Conversation

zyfjeff
Copy link
Member

@zyfjeff zyfjeff commented Oct 13, 2018

Signed-off-by: zyfjeff tianqian.zyf@alibaba-inc.com

Description: Implement "b3 single" header format for zipkin
Risk Level: medium
Testing: unittest
Docs Changes: N/A
Release Notes: N/A
[Optional Fixes #Issue] #4289
[Optional Deprecated:]

@mattklein123
Copy link
Member

@adriancole @objectiser PTAL if you have some time.

@zyfjeff can you add a release note for this and any relevant docs?

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 14, 2018 via email

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 14, 2018 via email

@zyfjeff zyfjeff force-pushed the b3_single_header branch 4 times, most recently from 06e1052 to f7ce6b9 Compare October 16, 2018 15:58
@zyfjeff
Copy link
Member Author

zyfjeff commented Oct 17, 2018

@adriancole I have two questions want to consult with you

Why FORMAT_MAX_LENGTH equal 32 + 1 + 16 + 2 + 16, not equal 32 + 1 + 16 + 2 + 1 + 16

https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/propagation/B3SingleFormat.java#L45

If I received from downstream b3 header format, that spread to the upstream whether change to b3 single header format ?

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 17, 2018 via email

codefromthecrypt pushed a commit to openzipkin/brave that referenced this pull request Oct 17, 2018
codefromthecrypt pushed a commit to openzipkin/brave that referenced this pull request Oct 17, 2018
codefromthecrypt pushed a commit to openzipkin/brave that referenced this pull request Oct 17, 2018
@zyfjeff zyfjeff force-pushed the b3_single_header branch 8 times, most recently from 61c7c7b to 31ad8b1 Compare October 19, 2018 03:53
@zyfjeff
Copy link
Member Author

zyfjeff commented Oct 19, 2018

@adriancole If I received from downstream b3 header format, that spread to the upstream whether change to b3 single header format ? this problem is not answer me yet

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 19, 2018 via email

@zyfjeff
Copy link
Member Author

zyfjeff commented Oct 19, 2018

This PR default only send X-B3-*, the next PR add option to control the behaviors.

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 19, 2018 via email

@zyfjeff zyfjeff force-pushed the b3_single_header branch 2 times, most recently from 8d4ac3b to adf6322 Compare October 19, 2018 09:29
@zyfjeff zyfjeff changed the title WIP: Implement "b3 single" header format for zipkin Implement "b3 single" header format for zipkin Oct 19, 2018
@zyfjeff
Copy link
Member Author

zyfjeff commented Oct 19, 2018

@adriancole @objectiser I have already finished, can undertake codereview

@zyfjeff
Copy link
Member Author

zyfjeff commented Oct 19, 2018

@mattklein123 In which file do you add release note?

Signed-off-by: zyfjeff <tianqian.zyf@alibaba-inc.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks, some high level comments. Deferring to @adriancole and @objectiser for the detailed Zipkin review.

@@ -4,6 +4,7 @@ Version history
1.9.0 (pending)
===============
* access log: added a :ref:`JSON logging mode <config_access_log_format_dictionaries>` to output access logs in JSON format.
* tracing: added support for Zipkin tracer of b3 single header format.
Copy link
Member

Choose a reason for hiding this comment

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

alpha order please

namespace {
constexpr int FormatMaxLength = 32 + 1 + 16 + 3 + 16; // traceid128-spanid-1-parentid
bool validSamplingFlags(char c) {
if (c == '1' || c == '0' || c == 'd')
Copy link
Member

Choose a reason for hiding this comment

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

braces

const Http::LowerCaseString X_B3_SAMPLED{"X-B3-Sampled"};
const Http::LowerCaseString X_B3_FLAGS{"X-B3-Flags"};

// Zipkin b3 siggle header
Copy link
Member

Choose a reason for hiding this comment

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

typo "siggle"

Signed-off-by: tianqian.zyf <tianqian.zyf@alibaba-inc.com>
Signed-off-by: zyfjeff <tianqian.zyf@alibaba-inc.com>
@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 24, 2018 via email

@zyfjeff
Copy link
Member Author

zyfjeff commented Oct 24, 2018

@adriancole I found a bug

https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/propagation/B3SingleFormat.java#L194

The following case will cause the if condition to be false, pos is not incremented and stays in the sampled position, causing the following to if (endIndex != pos + 17) return false

testcase:

  {
    Http::TestHeaderMapImpl request_headers{
        {"b3", fmt::format("{}-{}-d!{}", trace_id, span_id, parent_id)}};
    SpanContextExtractor extractor(request_headers);
    EXPECT_THROW_WITH_MESSAGE(extractor.extractSpanContext(true), ExtractorException,
                              "Invalid input: truncated");
  }

And https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/propagation/B3SingleFormat.java#L207 is a dead code, Because 194 lines has been verified

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 24, 2018 via email

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 24, 2018 via email

Signed-off-by: tianqian.zyf <tianqian.zyf@alibaba-inc.com>
Signed-off-by: zyfjeff <tianqian.zyf@alibaba-inc.com>
Signed-off-by: tianqian.zyf <tianqian.zyf@alibaba-inc.com>
objectiser
objectiser previously approved these changes Oct 24, 2018
@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 24, 2018 via email

@codefromthecrypt
Copy link
Contributor

@zyfjeff ps I've spoken to a number of sites who are not thrilled that envoy still emits data in zipkin v1 format. I think you can win even more friends if you have cycles to do v2 data format (json or proto3) as well. This would work in zipkin, but also clones of it like jaeger (who also accept zipkin v2 data) and all the myriad of proxies.

@zyfjeff
Copy link
Member Author

zyfjeff commented Oct 24, 2018

@zyfjeff ps I've spoken to a number of sites who are not thrilled that envoy still emits data in zipkin v1 format. I think you can win even more friends if you have cycles to do v2 data format (json or proto3) as well. This would work in zipkin, but also clones of it like jaeger (who also accept zipkin v2 data) and all the myriad of proxies.

I am not familiar with zipkin v2 data format, related documents?I can see first

@moderation
Copy link
Contributor

Not sure if there are different docs but I did find https://zipkin.io/zipkin-api/#/ which appears to be v2.

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Oct 24, 2018 via email

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM, a few small comments. Thank you!

source/extensions/tracers/zipkin/span_context_extractor.cc Outdated Show resolved Hide resolved
docs/root/intro/version_history.rst Outdated Show resolved Hide resolved
docs/root/intro/arch_overview/tracing.rst Outdated Show resolved Hide resolved
Signed-off-by: tianqian.zyf <tianqian.zyf@alibaba-inc.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 6bbefbd into envoyproxy:master Oct 24, 2018
@zyfjeff zyfjeff deleted the b3_single_header branch December 3, 2018 16:23
thgoexpt added a commit to thgoexpt/Java-distributed-tracing-implementation that referenced this pull request Apr 7, 2022
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.

5 participants