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

OpenTracing support #669

Merged
merged 24 commits into from
Apr 30, 2018
Merged

OpenTracing support #669

merged 24 commits into from
Apr 30, 2018

Conversation

jmprusi
Copy link
Contributor

@jmprusi jmprusi commented Apr 18, 2018

Adds basic opentracing jaeger support to apicast

  • Adds Opentracing support to apicast.
  • Example config for Jaeger tracer.
  • Uses opentracing_load_tracer to load tracing libraries dynamically.
  • New ENV vars
    • opentracing_tracer: tracer to include, now only "jaeger" is available
    • opentracing_config: config to be used by the tracer, can be configmap mounted inside the container.
    • opentracing_forward_header: name of the http header used by the tracing libraries (defaults to uber-trace-id)

Requires 3scale/s2i-openresty#56, 3scale/s2i-openresty#57

@@ -5,12 +5,16 @@ env RESOLVER;
env BACKEND_ENDPOINT_OVERRIDE;
env OPENSSL_VERIFY;

{% if jaeger_enabled %}
load_module /opt/app-root/src/nginx-modules/ngx_http_opentracing_module.so;
load_module /opt/app-root/src/nginx-modules/ngx_http_jaeger_module.so;
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not work on macOS or any local machine. We have to make this relative somehow.

@@ -61,37 +67,38 @@ http {
{% include file %}
{% endfor %}


{% if jaeger_enabled %}
{% include "conf.d/jaeger.conf" %}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can have a opentracing subfolder there and do:

{% include "conf.d/opentracing" | append opentracing_tracer | append ".conf" %}

So we have a conf file for each supported tracer.

daemon {{ daemon | default: 'off' }};
master_process {{ master_process | default: 'on' }};
worker_processes {{ worker_processes | default: 'auto' }};
pcre_jit on;
pid {{ pid | default: 'nginx.pid' }};
timer_resolution {{ timer_resolution | default: '100ms' }};
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be disabled only when opentracing is enabled. Or the timer_resolution should be set to 0 (if that works).


echo_read_request_body;
location / {
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably don't need to rewrite this right? The echo module behaves ok.

@@ -1,4 +1,11 @@
{% if jaeger_enabled %}
Copy link
Contributor

Choose a reason for hiding this comment

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

No liquid in this template (it would need to have .liquid extension). This will neeed to be in the main nginx.conf.liquid.

@@ -9,6 +11,12 @@ set_by_lua_block $deployment {
# ssl_session_fetch_by_lua_block { require('apicast.executor').call() }
# ssl_session_store_by_lua_block { require('apicast.executor').call() }

{% if jaeger_enabled %}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is trouble. There is no liquid templating in this file. This global definition can be in the nginx.conf.liquid.

proxy_pass_request_headers off;

{% if jaeger_enabled %}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is impossible to do. This file has to stay plain nginx file without liquid templating because of our test suite.

@@ -0,0 +1,4 @@
jaeger_reporter_local_agent_host_port {{ jaeger_addr | default: '127.0.0.1' }}:{{ jaeger_port | default: 6831 }};
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add .liquid extension to files that are processed by liquid so it is more obvious liquid is available there.

@@ -108,7 +108,10 @@ _M.default_config = {
proxy_ssl_certificate_key = env_value_ref('APICAST_PROXY_HTTPS_CERTIFICATE_KEY'),
proxy_ssl_session_reuse = env_value_ref('APICAST_PROXY_HTTPS_SESSION_REUSE'),
proxy_ssl_password_file = env_value_ref('APICAST_PROXY_HTTPS_PASSWORD_FILE'),

jaeger_enabled = env_value_ref('JAEGER_ENABLED'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather try to make this "opentracing" support rather than just jaeger.

IMO we should be open to support more than jaeger tracker and that the configuration should be designed like that.

So for example jaeger_enabled IMO should be opentracing_enabled and then there should be opentracing_tracer that says jaeger|...|...|....

The common denominator of the configuration should be defined as "opentracing" and then the specifics can be named with the tracer name.

@jmprusi jmprusi force-pushed the opentracing branch 4 times, most recently from c458cf6 to b3f904a Compare April 19, 2018 16:24
@@ -35,6 +35,7 @@ location = /___http_call {
proxy_set_header User-Agent $user_agent;
proxy_set_header X-3scale-OAuth2-Grant-Type $grant_type;
proxy_set_header 3scale-options $options;
proxy_set_header uber-trace-id $http_uber_trace_id;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mikz @davidor we cannot template this apicast file isn't it?

This header in jaeger is user customizable, so, we should allow some way to change this via ENV, any idea? some include?

@jmprusi jmprusi changed the title WIP Opentracing Opentracing support Apr 20, 2018
@jmprusi jmprusi force-pushed the opentracing branch 4 times, most recently from e10da83 to f1090fd Compare April 20, 2018 18:17
daemon {{ daemon | default: 'off' }};
master_process {{ master_process | default: 'on' }};
worker_processes {{ worker_processes | default: 'auto' }};
pcre_jit on;
pid {{ pid | default: 'nginx.pid' }};

{% unless opentracing_tracer != empty %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be if.

CHANGELOG.md Outdated
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

- Rate Limit policy [PR #648](https://github.com/3scale/apicast/pull/648)
- Opentracing support [PR #669](https://github.com/3scale/apicast/pull/669)
Copy link
Contributor

Choose a reason for hiding this comment

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

👀 OpenTracing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"fixed"

@jmprusi jmprusi changed the title Opentracing support OpenTracing support Apr 26, 2018
--- error_code: 200
--- no_error_log
[error]
--- udp_listen: 6831
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's openresty? cool.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@mikz mikz left a comment

Choose a reason for hiding this comment

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

👍 sweet

We got OpenTracing support on Linux and macOS.
Homebrew formulas provided in our tap: 3scale-archive/homebrew-opentracing#1

@mikz mikz merged commit 78aa7ab into master Apr 30, 2018
@mikz mikz deleted the opentracing branch April 30, 2018 17:25
@davidor davidor added this to the 3.3 milestone Jun 1, 2018
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.

3 participants