Skip to content

Commit 5313411

Browse files
authored
Showing Attribute Values properly for Nginx Module (#248)
* Attributes parsed values * Removing Comments * Fixing comments
1 parent ba0094b commit 5313411

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,11 +1565,19 @@ static void fillRequestPayload(request_payload* req_payload, ngx_http_request_t*
15651565

15661566
#endif
15671567

1568-
req_payload->protocol = (const char*)(r->http_protocol).data;
1569-
req_payload->request_method = (const char*)(r->method_name).data;
1568+
// TODO - use strncpy function to just create memory of size (r->http_protocol.len)
1569+
char *temp_http_protocol = ngx_pcalloc(r->pool, (strlen((r->http_protocol).data))+1);
1570+
strcpy(temp_http_protocol,(const char*)(r->http_protocol).data);
1571+
temp_http_protocol[(r->http_protocol).len]='\0';
1572+
req_payload->protocol = temp_http_protocol;
1573+
1574+
char *temp_request_method = ngx_pcalloc(r->pool, (strlen((r->method_name).data))+1);
1575+
strcpy(temp_request_method,(const char*)(r->method_name).data);
1576+
temp_request_method[(r->method_name).len]='\0';
1577+
req_payload->request_method = temp_request_method;
15701578

15711579
// flavor has to be scraped from protocol in future
1572-
req_payload->flavor = (const char*)(r->http_protocol).data;
1580+
req_payload->flavor = temp_http_protocol;
15731581

15741582
char *temp_hostname = ngx_pcalloc(r->pool, (strlen(hostname.data))+1);
15751583
strcpy(temp_hostname,(const char*)hostname.data);

0 commit comments

Comments
 (0)