diff --git a/instrumentation/otel-webserver-module/include/core/api/Payload.h b/instrumentation/otel-webserver-module/include/core/api/Payload.h index 028cc18fc..8ca9df6f9 100644 --- a/instrumentation/otel-webserver-module/include/core/api/Payload.h +++ b/instrumentation/otel-webserver-module/include/core/api/Payload.h @@ -65,9 +65,14 @@ struct InteractionPayload std::string phaseName; bool resolveBackends; + std::string target; + std::string scheme; + std::string host; + InteractionPayload() {} - InteractionPayload(std::string module, std::string phase, bool b) : moduleName(module), phaseName(phase), resolveBackends(b) + InteractionPayload(std::string module, std::string phase, bool b, std::string aTarget, std::string aScheme, std::string aHost) + : moduleName(module), phaseName(phase), resolveBackends(b), target(aTarget), scheme(aScheme), host(aHost) {} }; diff --git a/instrumentation/otel-webserver-module/include/core/api/opentelemetry_ngx_api.h b/instrumentation/otel-webserver-module/include/core/api/opentelemetry_ngx_api.h index d279757df..ea22ffb84 100644 --- a/instrumentation/otel-webserver-module/include/core/api/opentelemetry_ngx_api.h +++ b/instrumentation/otel-webserver-module/include/core/api/opentelemetry_ngx_api.h @@ -62,7 +62,7 @@ void initDependency(); void populatePayload(request_payload* req_payload, void* payload, int count); APPD_SDK_STATUS_CODE opentelemetry_core_init(APPD_SDK_ENV_RECORD* env, unsigned numberOfRecords, struct cNode *rootCN); APPD_SDK_STATUS_CODE startRequest(const char* wscontext, request_payload* req_payload, APPD_SDK_HANDLE_REQ* reqHandle, int count); -APPD_SDK_STATUS_CODE startModuleInteraction(const char* req_handle_key, const char* module_name, const char* stage, bool resolveBackends, APPD_SDK_ENV_RECORD* propagationHeaders, int* ix); +APPD_SDK_STATUS_CODE startModuleInteraction(const char* req_handle_key, const char* module_name, const char* stage, bool resolveBackends, APPD_SDK_ENV_RECORD* propagationHeaders, int* ix, const char* target, const char* scheme, const char* host); APPD_SDK_STATUS_CODE stopModuleInteraction(const char* req_handle_key, const char* backendName, const char* backendType, unsigned int err_code, const char* msg); APPD_SDK_STATUS_CODE endRequest(APPD_SDK_HANDLE_REQ req_handle_key, const char* errMsg); diff --git a/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp b/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp index efd004efb..5b99ed095 100644 --- a/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp +++ b/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp @@ -252,7 +252,7 @@ APPD_SDK_STATUS_CODE ApacheHooks::appd_startInteraction( } std::unique_ptr payload(new - appd::core::InteractionPayload(module, stage, resolveBackends)); + appd::core::InteractionPayload(module, stage, resolveBackends, r->server->server_hostname, ap_run_http_scheme(r), r->hostname)); // Create propagationHeaders to be populated in startInteraction. std::unordered_map propagationHeaders; diff --git a/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp b/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp index 24652d3e4..07ca158ff 100644 --- a/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp +++ b/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp @@ -164,6 +164,9 @@ APPD_SDK_STATUS_CODE RequestProcessingEngine::startInteraction( std::string spanName = payload->moduleName + "_" + payload->phaseName; keyValueMap["interactionType"] = "EXIT_CALL"; auto interactionSpan = m_sdkWrapper->CreateSpan(spanName, SpanKind::CLIENT, keyValueMap); + interactionSpan->AddAttribute("http.target", payload->target); + interactionSpan->AddAttribute("http.scheme", payload->scheme); + interactionSpan->AddAttribute("http.host", payload->host); LOG4CXX_TRACE(mLogger, "Client Span started with SpanName: " << spanName << " Span Id: " << interactionSpan.get()); m_sdkWrapper->PopulatePropagationHeaders(propagationHeaders); diff --git a/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp b/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp index e85a32902..822897487 100644 --- a/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp +++ b/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp @@ -78,14 +78,13 @@ APPD_SDK_STATUS_CODE endRequest(APPD_SDK_HANDLE_REQ req_handle_key, const char* return res; } -APPD_SDK_STATUS_CODE startModuleInteraction(const char* req_handle_key, const char* module_name, const char* stage, bool resolveBackends, APPD_SDK_ENV_RECORD* propagationHeaders, int *ix) +APPD_SDK_STATUS_CODE startModuleInteraction(const char* req_handle_key, const char* module_name, const char* stage, bool resolveBackends, APPD_SDK_ENV_RECORD* propagationHeaders, int *ix, const char* target, const char* scheme, const char* host) { APPD_SDK_STATUS_CODE res = APPD_SUCCESS; std::unordered_map pHeaders; std::string module(module_name); std::string m_stage(stage); - - std::unique_ptr payload(new appd::core::InteractionPayload(module, m_stage, resolveBackends)); + std::unique_ptr payload(new appd::core::InteractionPayload(module, m_stage, resolveBackends, target, scheme, host)); res = wsAgent.startInteraction((APPD_SDK_HANDLE_REQ)req_handle_key, payload.get(), pHeaders); if (APPD_ISSUCCESS(res)) diff --git a/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c b/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c index 891411acd..c1d352bea 100644 --- a/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c +++ b/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c @@ -675,7 +675,8 @@ static APPD_SDK_STATUS_CODE otel_startInteraction(ngx_http_request_t* r, const c } ngx_writeTrace(r->connection->log, __func__, "Starting a new module interaction for: %s", module_name); int ix = 0; - res = startModuleInteraction(ctx->otel_req_handle_key, module_name, "", resolveBackends, propagationHeaders, &ix); + // Todo : In the below line $scheme is Ngnix variable, need to findn correct way to retrieve this + res = startModuleInteraction(ctx->otel_req_handle_key, module_name, "", resolveBackends, propagationHeaders, &ix, (const char*)(r->unparsed_uri.data), "$scheme", (const char*)(r->headers_in.host->value.data)); if (APPD_ISSUCCESS(res)) {