diff --git a/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp b/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp index 0807e0659..24652d3e4 100644 --- a/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp +++ b/instrumentation/otel-webserver-module/src/core/api/RequestProcessingEngine.cpp @@ -104,15 +104,13 @@ APPD_SDK_STATUS_CODE RequestProcessingEngine::endRequest( // check for error and set attribute in the scopedSpan. if (error) { - std::string errorStatus; std::stringstream strValue; unsigned int errorValue; strValue << error; strValue >> errorValue; - strValue << kHttpErrorCode + error; // This is status message eg: HTTP ERROR CODE:403 - strValue >> errorStatus; + std::string errorStatus (kHttpErrorCode + error); // This is status message eg: HTTP ERROR CODE:403 if (errorValue >= HTTP_ERROR_1XX && errorValue < HTTP_ERROR_4XX ) { rootSpan->SetStatus(StatusCode::Unset); diff --git a/instrumentation/otel-webserver-module/test/unit/RequestProcessingEngine_test.cpp b/instrumentation/otel-webserver-module/test/unit/RequestProcessingEngine_test.cpp index 3eeda9e8b..c8207fbba 100644 --- a/instrumentation/otel-webserver-module/test/unit/RequestProcessingEngine_test.cpp +++ b/instrumentation/otel-webserver-module/test/unit/RequestProcessingEngine_test.cpp @@ -208,12 +208,12 @@ TEST(TestRequestProcessingEngine, EndRequest) EXPECT_CALL(*getMockSpan(interactionSpan1), End()). Times(1); - EXPECT_CALL(*getMockSpan(rootSpan), SetStatus(appd::core::sdkwrapper::StatusCode::Error, "error_msg")).Times(1); + EXPECT_CALL(*getMockSpan(rootSpan), SetStatus(appd::core::sdkwrapper::StatusCode::Error, "HTTP ERROR CODE:403")).Times(1); EXPECT_CALL(*getMockSpan(rootSpan), End()). Times(1); - auto res = engine.endRequest(rContext, "error_msg"); + auto res = engine.endRequest(rContext, "403"); EXPECT_EQ(res, APPD_SUCCESS); } @@ -225,7 +225,7 @@ TEST(TestRequestProcessingEngine, EndRequestInvalidParams) engine.init(config,spanNamer); auto* sdkWrapper = engine.getMockSdkWrapper(); ASSERT_TRUE(sdkWrapper); - auto res = engine.endRequest(nullptr, "error msg"); + auto res = engine.endRequest(nullptr, "403"); EXPECT_EQ(res, APPD_STATUS(fail)); } diff --git a/instrumentation/otel-webserver-module/test/unit/mocks/mock_sdkwrapper.h b/instrumentation/otel-webserver-module/test/unit/mocks/mock_sdkwrapper.h index 51443d232..7f9ee9dc5 100644 --- a/instrumentation/otel-webserver-module/test/unit/mocks/mock_sdkwrapper.h +++ b/instrumentation/otel-webserver-module/test/unit/mocks/mock_sdkwrapper.h @@ -41,6 +41,10 @@ class MockScopedSpan : public appd::core::sdkwrapper::IScopedSpan (const appd::core::sdkwrapper::StatusCode code, const std::string& desc), (override)); + + MOCK_METHOD(appd::core::sdkwrapper::SpanKind, GetSpanKind, + (), + (override)); }; // TODO : General MOCK_METHOD command is giving some unexpected errors. Revisit later