You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/10/20 11:56:30 UTC

[GitHub] [apisix] zuiyangqingzhou opened a new pull request #5295: fix zipkin plugin logic bug

zuiyangqingzhou opened a new pull request #5295:
URL: https://github.com/apache/apisix/pull/5295


   fix: https://github.com/apache/apisix/issues/5294
   
   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   * [ ] Did you explain what problem does this PR solve? Or what new features have been added?
   * [ ] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #5295: fix(zipkin): response_span doesn't have correct start time

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #5295:
URL: https://github.com/apache/apisix/pull/5295


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] zuiyangqingzhou commented on pull request #5295: fix(zipkin): response_span doesn't have correct start time

Posted by GitBox <gi...@apache.org>.
zuiyangqingzhou commented on pull request #5295:
URL: https://github.com/apache/apisix/pull/5295#issuecomment-948317829


   > Could you provide a test case? You can hook the "start_child_span" to check if a valid time is given. You can refer
   > 
   > https://github.com/apache/apisix/blob/4dd1f6799f8207ed2f07da0e2a34c282b26cd877/t/plugin/skywalking.t#L36
   
   OK


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] zuiyangqingzhou commented on pull request #5295: fix(zipkin): response_span doesn't have correct start time

Posted by GitBox <gi...@apache.org>.
zuiyangqingzhou commented on pull request #5295:
URL: https://github.com/apache/apisix/pull/5295#issuecomment-950168765


   > Could you provide a test case? You can hook the "start_child_span" to check if a valid time is given. You can refer
   > 
   > https://github.com/apache/apisix/blob/4dd1f6799f8207ed2f07da0e2a34c282b26cd877/t/plugin/skywalking.t#L36
   
   sorry, after trying many ways, I still don't understand how to hook the start_child_span, can you help me? @spacewander 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] zuiyangqingzhou commented on pull request #5295: fix(zipkin): response_span doesn't have correct start time

Posted by GitBox <gi...@apache.org>.
zuiyangqingzhou commented on pull request #5295:
URL: https://github.com/apache/apisix/pull/5295#issuecomment-950280727


   > You can apply this patch:
   > 
   > ```
   > diff --git t/plugin/zipkin2.t t/plugin/zipkin2.t
   > index 7b0edef5..f7d4b55e 100644
   > --- t/plugin/zipkin2.t
   > +++ t/plugin/zipkin2.t
   > @@ -31,6 +31,24 @@ add_block_preprocessor(sub {
   >      if (!$block->no_error_log && !$block->error_log) {
   >          $block->set_value("no_error_log", "[error]\n[alert]");
   >      }
   > +
   > +    my $extra_init_by_lua = <<_EOC_;
   > +    local new = require("opentracing.tracer").new
   > +    local tracer_mt = getmetatable(new()).__index
   > +    local orig_func = tracer_mt.start_span
   > +    tracer_mt.start_span = function (...)
   > +        local orig = orig_func(...)
   > +        local mt = getmetatable(orig).__index
   > +        local old_start_child_span = mt.start_child_span
   > +        mt.start_child_span = function(self, name, time)
   > +            ngx.log(ngx.WARN, "zipkin start_child_span ", name, " time: ", time)
   > +            return old_start_child_span(self, name, time)
   > +        end
   > +        return orig
   > +    end
   > +_EOC_
   > +
   > +    $block->set_value("extra_init_by_lua", $extra_init_by_lua);
   >  });
   > 
   >  run_tests;
   > @@ -83,6 +101,9 @@ x-b3-sampled: 1
   >  b3:
   >  --- error_log
   >  new span context: trace id: 80f198ee56343ba864fe8b2a57d3eff7, span id: e457b5a2e4d86bd1, parent span id: 05e3ac9a4f6e3b90
   > +--- grep_error_log eval
   > +qr/zipkin start_child_span apisix.response_span time: nil/
   > +--- grep_error_log_out
   > 
   > 
   > 
   > @@ -186,3 +207,6 @@ GET /t
   >  --- request
   >  GET /opentracing
   >  --- wait: 10
   > +--- grep_error_log eval
   > +qr/zipkin start_child_span apisix.response_span time: nil/
   > +--- grep_error_log_out
   > ```
   
   Thank you 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on pull request #5295: fix(zipkin): response_span doesn't have correct start time

Posted by GitBox <gi...@apache.org>.
spacewander commented on pull request #5295:
URL: https://github.com/apache/apisix/pull/5295#issuecomment-950256072


   You can apply this patch:
   ```
   diff --git t/plugin/zipkin2.t t/plugin/zipkin2.t
   index 7b0edef5..f7d4b55e 100644
   --- t/plugin/zipkin2.t
   +++ t/plugin/zipkin2.t
   @@ -31,6 +31,24 @@ add_block_preprocessor(sub {
        if (!$block->no_error_log && !$block->error_log) {
            $block->set_value("no_error_log", "[error]\n[alert]");
        }
   +
   +    my $extra_init_by_lua = <<_EOC_;
   +    local new = require("opentracing.tracer").new
   +    local tracer_mt = getmetatable(new()).__index
   +    local orig_func = tracer_mt.start_span
   +    tracer_mt.start_span = function (...)
   +        local orig = orig_func(...)
   +        local mt = getmetatable(orig).__index
   +        local old_start_child_span = mt.start_child_span
   +        mt.start_child_span = function(self, name, time)
   +            ngx.log(ngx.WARN, "zipkin start_child_span ", name, " time: ", time)
   +            return old_start_child_span(self, name, time)
   +        end
   +        return orig
   +    end
   +_EOC_
   +
   +    $block->set_value("extra_init_by_lua", $extra_init_by_lua);
    });
   
    run_tests;
   @@ -83,6 +101,9 @@ x-b3-sampled: 1
    b3:
    --- error_log
    new span context: trace id: 80f198ee56343ba864fe8b2a57d3eff7, span id: e457b5a2e4d86bd1, parent span id: 05e3ac9a4f6e3b90
   +--- grep_error_log eval
   +qr/zipkin start_child_span apisix.response_span time: nil/
   +--- grep_error_log_out
   
   
   
   @@ -186,3 +207,6 @@ GET /t
    --- request
    GET /opentracing
    --- wait: 10
   +--- grep_error_log eval
   +qr/zipkin start_child_span apisix.response_span time: nil/
   +--- grep_error_log_out
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org