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 http.status_code as span attributes for both Apache/Nginx #235

Merged
merged 4 commits into from
Nov 17, 2022

Conversation

DebajitDas
Copy link
Member

No description provided.

@DebajitDas DebajitDas requested a review from kpratyus as a code owner November 11, 2022 11:24
@DebajitDas DebajitDas requested a review from a team November 11, 2022 11:24
@@ -47,7 +47,6 @@ class RequestPayload
std::string flavor;
std::string client_ip;
long port = 80;
long status_code = 200;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No magic numbers here? We can find a better way right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a removed code.

@@ -1101,18 +1101,18 @@ static void stopMonitoringRequest(ngx_http_request_t* r,
}

APPD_SDK_STATUS_CODE res;
unsigned int errCode=0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above..Lets use a better practice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unsigned int initialised to zero value. Do you think we really need to define this else where

char* msg = NULL;

if (otel_requestHasErrors(r))
{
errCode=(unsigned int)otel_getErrorCode(r);
res_payload->status_code = (unsigned int)otel_getErrorCode(r);
msg = (char*)malloc(6);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace fixed number 6 by a constant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@@ -131,7 +136,6 @@ TEST(TestRequestProcessingEngine, StartRequest)
payload.set_request_protocol("GET");
payload.set_uri("dummy_span");
payload.set_server_name("localhost");
payload.set_status_code(200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above can't use magic numbers

@@ -229,12 +232,19 @@ TEST(TestRequestProcessingEngine, EndRequest)
EXPECT_CALL(*getMockSpan(interactionSpan1), End()).
Times(1);

unsigned int status_code = 403;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more magic number

Copy link
Member Author

@DebajitDas DebajitDas Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are test code though. We are testing with a value. Do you really think we need to avoid magic number


EXPECT_CALL(*getMockSpan(rootSpan), End()).
Times(1);

auto res = engine.endRequest(rContext, "403");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String literals should go into a resource file ..outside the code

@DebajitDas DebajitDas requested a review from gnm444 November 16, 2022 10:32
@DebajitDas DebajitDas merged commit 7432ef2 into open-telemetry:main Nov 17, 2022
@DebajitDas DebajitDas deleted the statuscode branch November 17, 2022 05:09
@marcalff marcalff added the Webserver This represents the otel-webserver-module in the instrumentation directory label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Webserver This represents the otel-webserver-module in the instrumentation directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants