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

Adding functionality to toggle correlation with incoming traces #346

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions instrumentation/otel-webserver-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Currently, Nginx Webserver module monitores some fixed set of modules, which get
|*NginxModuleRequestHeaders* | | OPTIONAL: Specify the request headers to be captured in the span attributes. The headers are Case-Sensitive and should be comma-separated. e.g.```NginxModuleRequestHeaders Accept-Charset,Accept-Encoding,User-Agent;```|
|*NginxModuleResponseHeaders* | | OPTIONAL: Specify the response headers to be captured in the span attributes. The headers are Case-Sensitive and should be comma-separated. e.g.```NginxModuleResponseHeaders Content-Length,Content-Type;```|
|*NginxModuleOtelExporterOtlpHeaders* | | OPTIONAL: OTEL exporter headers like Meta data related exposrted end point. a list of key value pairs, and these are expected to be represented in a format matching to the W3C Correlation-Context, except that additional semi-colon delimited metadata is not supported, i.e.: key1=value1,key2=value2.|
|*NginxTrustIncomingSpans* | ON | OPTIONAL: Specify if you want to correlate Nginx instrumented traces and spans with incoming requests.|

### Build and Installation
#### Prerequisites
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@ static ngx_command_t ngx_http_opentelemetry_commands[] = {
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_opentelemetry_loc_conf_t, nginxModuleResponseHeaders),
NULL},

{ ngx_string("NginxTrustIncomingSpans"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_opentelemetry_loc_conf_t, nginxTrustIncomingSpans),
NULL},

ngx_null_command /* command termination */
};
Expand Down Expand Up @@ -437,6 +444,7 @@ static void* ngx_http_opentelemetry_create_loc_conf(ngx_conf_t *cf)
conf->nginxModuleTraceAsError = NGX_CONF_UNSET;
conf->nginxModuleOtelMaxQueueSize = NGX_CONF_UNSET;
conf->nginxModuleOtelSslEnabled = NGX_CONF_UNSET;
conf->nginxTrustIncomingSpans = NGX_CONF_UNSET;

return conf;
}
Expand All @@ -453,6 +461,8 @@ static char* ngx_http_opentelemetry_merge_loc_conf(ngx_conf_t *cf, void *parent,
ngx_conf_merge_value(conf->nginxModuleTraceAsError, prev->nginxModuleTraceAsError, 0);
ngx_conf_merge_value(conf->nginxModuleMaskCookie, prev->nginxModuleMaskCookie, 0);
ngx_conf_merge_value(conf->nginxModuleMaskSmUser, prev->nginxModuleMaskSmUser, 0);
ngx_conf_merge_value(conf->nginxTrustIncomingSpans, prev->nginxTrustIncomingSpans, 1);


ngx_conf_merge_str_value(conf->nginxModuleOtelSpanExporter, prev->nginxModuleOtelSpanExporter, "");
ngx_conf_merge_str_value(conf->nginxModuleOtelExporterEndpoint, prev->nginxModuleOtelExporterEndpoint, "");
Expand Down Expand Up @@ -1637,7 +1647,7 @@ static void fillRequestPayload(request_payload* req_payload, ngx_http_request_t*
for (ngx_uint_t j = 0; j < nelts; j++) {

h = &header[j];
for (int i = 0; i < headers_len; i++) {
for (int i = 0; i < headers_len && conf->nginxTrustIncomingSpans ; i++) {

if (strcmp(h->key.data, httpHeaders[i]) == 0) {
req_payload->propagation_headers[propagation_headers_idx].name = httpHeaders[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ typedef struct {
ngx_str_t nginxModuleRequestHeaders;
ngx_str_t nginxModuleResponseHeaders;
ngx_str_t nginxModuleOtelExporterOtlpHeaders;
ngx_flag_t nginxTrustIncomingSpans;

} ngx_http_opentelemetry_loc_conf_t;

/*
Expand Down