Skip to content

Commit

Permalink
Opentracing: Added new tag
Browse files Browse the repository at this point in the history
When using opentracing, the http.host label, is the upstream Host. If a
user wants to track down the opentracing config with the original
host/header is not possible at all.

This commit adds a new tag on opentracing called original_request_uri.

Fix THREESCALE-5669

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
  • Loading branch information
eloycoto committed Aug 31, 2020
1 parent e3bb3e4 commit 2beafe8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Support Proxy Protocol [PR #1211](https://github.com/3scale/APIcast/pull/1211) [THREESCALE-5366](https://issues.redhat.com/browse/THREESCALE-5366)
- Enable support to log credentials on logging policy [PR #1217](https://github.com/3scale/APIcast/pull/1217) [THREESCALE-5273](https://issues.redhat.com/browse/THREESCALE-5273)
- Add a way to support more than 1000 services in a single instance [PR #1222](https://github.com/3scale/APIcast/pull/1222) [THREESCALE-5308](https://issues.redhat.com/browse/THREESCALE-5308)
- Added new original_request_uri tag on Opentracing [PR #1223](https://github.com/3scale/APIcast/pull/1223) [THREESCALE-5669](https://issues.redhat.com/browse/THREESCALE-5669)


### Fixed
Expand Down
1 change: 1 addition & 0 deletions gateway/conf.d/apicast.conf
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ location / {

set $post_action_impact '';
set $original_request_id '';
set $original_request_uri '$scheme://$host$request_uri';

# Variables needed by Websocket policy
set $upstream_connection_header '';
Expand Down
1 change: 1 addition & 0 deletions gateway/http.d/apicast.conf.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ server {
{% if opentracing_tracer != empty %}
opentracing_operation_name "apicast";
opentracing_trace_locations on;
opentracing_tag original_request_uri $original_request_uri;
{% endif %}

{% include "http.d/ssl.conf" %}
Expand Down
1 change: 1 addition & 0 deletions t/apicast-http2.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ run_tests();
__DATA__
=== TEST 1: Simple HTTP2 request termination.
--- ONLY
This test enables HTTP2 termination on endpoint and proxy it to a api_backend
that is not https or HTTP2 enabled.
--- env eval
Expand Down
50 changes: 50 additions & 0 deletions t/opentracing.t
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,53 @@ GET /a_path?
--- udp_query eval
qr/jaeger.version/
--- wait: 10
=== TEST 3: original_request_uri tag
Opentracing custom tag fix for THREESCALE-5669
-- env eval
(
'OPENTRACING_FORWARD_HEADER' => "foobar"
)
--- configuration
{
"services": [
{
"id": 42,
"system_name": "foo",
"proxy": {
"policy_chain": [
{
"name": "apicast.policy.upstream",
"configuration": {
"rules": [
{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT"
}
]
}
}
]
}
}
]
}
--- upstream
location / {
content_by_lua_block {
local headers = ngx.req.get_headers()
assert(headers["foobar"] == "value")
}
}
--- request
GET /a_path?
--- more_headers eval
"foobar: value"
--- error_code: 200
--- no_error_log
[error]
--- udp_listen: 6831
--- udp_reply
--- udp_query eval
qr/original_request_uri/
--- wait: 10

0 comments on commit 2beafe8

Please sign in to comment.