opentracing-contrib / nginx-opentracing

NGINX plugin for OpenTracing
Apache License 2.0
495 stars 121 forks source link

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

Open maria-farooq opened 3 years ago

maria-farooq commented 3 years ago

Hi,

Versions

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

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

Reverse Config

    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

Conclusion

sriemer commented 3 years ago

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: