Skip to content

Commit

Permalink
Merged from Main branch (#172)
Browse files Browse the repository at this point in the history
* Set span status according to Semantic Conventions of Http (#164)

* Set span status according to http semantics

* Set span status changes part-2

* Set span status according to http semantics spaces

* Review comments addressed for span status

* Moved error status from Apache hooks to Request processing engine

* Fixed UT failure  (#171)

* Set span status according to http semantics

* Set span status changes part-2

* Set span status according to http semantics spaces

* Review comments addressed for span status

* Moved error status from Apache hooks to Request processing engine

* Fixed unit test failure

Co-authored-by: Narasimha <ngonapa@cisco.com>
  • Loading branch information
DebajitDas and gnm444 authored Jun 2, 2022
1 parent e77d6a0 commit 6342d26
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6342d26

Please sign in to comment.