nginx-opentracing icon indicating copy to clipboard operation
nginx-opentracing copied to clipboard

Missing Traces for Method based routing (requests that are not redirectced to another location)

Open maria-farooq opened this issue 4 years ago • 1 comments

Hi,

Versions

  • nginx-plus version: r24
  • We are configuring nginx using nginx-ansible-role: 0.17.4
  • with Datadog Opentracing C++ Plugin version: v1.3.0

Use Case

We have an endpoint where on same URL: request are routed depending on the http METHOD.

For example on this URL: https://usstaging.restcomm.com/restcomm/2012-04-24/Accounts/AC123/Calls

  • GET is routed an accounting service.
  • PUT|POST is routed a sessionHandling service.

How we implement it

    location ~ (?:/restcomm|/api)(?:/2012-04-24)*(/Accounts.*/.+/Calls.*) {
        log_subrequest on;
        error_page 418 = @accountingapi;
        if ($request_method !~ (POST|PUT) ) {
         return 418;
        }
        include "inc/incSessionHandlingApi.conf";
    }
    location @accountingapi {
        include "inc/incAccountingApi.conf";
    }

incSessionHandlingApi.conf

if ($http_authorization ~* (^Bearer)) {
    return 400 "Unsupported Authorization Type";
}
proxy_pass http://connect_lb;
        opentracing_propagate_context;
rewrite (?:/api)+(/2012-04-24.*) /restcomm$1 break;
proxy_set_header Host connect-lb.dev-us-east-1-restcomm-internals.com;
proxy_set_header X-Forwarded-Host $host;

inc/incAccountingApi.conf

proxy_pass https://api_gateway/dev/accounting$uri$is_args$args;
        opentracing_propagate_context;
rewrite (/2012-04-24.*) /accounting$1 break;
proxy_set_header Host abc.execute-api.us-east-1.amazonaws.com;
proxy_set_header X-Forwarded-Host $host;
proxy_ssl_server_name on;

Result of this config

  • using above mentioned config we are able to see the traces for accountingapi (GET requests).
  • however we are not able to see the traces for PUT|POST SessionHandlingApi.

Reverse Config

  • we tried a reverse config where we reverse the if_condition and started to redirected PUT|POST SessionHandlingApi requests instead of accounting api.
    location ~ (?:/restcomm)*(?:/api)*(?:/2012-04-24)*(/Accounts.*/.+/Calls.*) {
        log_subrequest on;
        error_page 418 = @sessionhandlingapi;
        if ($request_method ~ (POST|PUT) ) {
         return 418;
        }
        include "inc/incAccountingApi.conf";
    }

Result of this config

  • result is reversed.
  • using above mentioned config we are able to see the traces for PUT|POST SessionHandlingApi.
  • however we are not able to see the traces for accountingapi (GET requests).

Conclusion

  • we are able to see the traces for requests that are redirected to another location
  • and missing the traces for those which are not redirected to another location

maria-farooq avatar Jul 02 '21 09:07 maria-farooq

Should be raised with Datadog. nginx-opentracing lacks subrequest support. Authentication creates subrequests. The tracer is blind and lacking configuration in that case. Our Instana tracer that I'm developing is always on and tracing by default. So we capture those traces. Trace continuity is broken though. We are working on subrequest support right now. If the dogs want to team up, then that would increase the chance that we won't keep this feature for ourselves. :wink:

sriemer avatar Jul 12 '21 10:07 sriemer