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

Print request content as trace logs #383

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

vikman90
Copy link
Member

@vikman90 vikman90 commented Dec 3, 2024

Related issue
Closes #368

This PR aims to replace the HTTP(s) request response debug logs with two different logs:

  1. Debug log: indicating the endpoint and the status code.
  2. Trace log: containing the endpoint, the status code and the response body.

The reason to "duplicate" this information is traceability: different components may print interleaved logs.

Demo Logs

Authorization Token Request

[2024-12-03 11:48:32.105] [wazuh-agent] [debug] [DEBUG] [http_client.cpp:397] [PerformHttpRequestInternal] Request /api/v1/authentication: Status 200

[2024-12-03 11:48:32.106] [wazuh-agent] [trace] [TRACE] [http_client.cpp:398] [PerformHttpRequestInternal] Request endpoint: /api/v1/authentication
Response: HTTP/1.1 200 OK
X-Imposter-Request: 974e8dcd-9b5f-413e-baf3-21ba502128b9
Server: imposter
content-length: 315

{"token":"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJXYXp1aCIsImF1ZCI6IldhenVoIENvbW11bmljYXRpb25zIEFQSSIsImlhdCI6MTczMzIyMjkxMiwiZXhwIjoxNzMzMjIzODEyLCJ1dWlkIjoiMDE2ZDE3NzAtOTlmNi00OTM0LWFmMDMtYmJiOWFiZmM2YmZiIn0.MEQCIBW5kM8lcNgOLxkvXnA42jjmw69Qx-R_lbydLiNQ2JTlAiBWA5LyJjSjxkea2p3Dkkj0STDGu2v_EMzfnOvFqPrsug"}

Stateful Push Request

[2024-12-03 11:47:23.940] [wazuh-agent] [debug] [DEBUG] [http_client.cpp:229] [Co_PerformHttpRequest] Request /api/v1/events/stateful: Status 200

[2024-12-03 11:47:23.941] [wazuh-agent] [trace] [TRACE] [http_client.cpp:230] [Co_PerformHttpRequest] Request endpoint: /api/v1/events/stateful
Response: HTTP/1.1 200 OK
X-Imposter-Request: 10e92eba-3cc9-40d8-9a3f-7882e40e7637
Server: imposter
content-length: 0

@vikman90 vikman90 self-assigned this Dec 3, 2024
@vikman90 vikman90 linked an issue Dec 3, 2024 that may be closed by this pull request
@vikman90 vikman90 requested a review from jotacarma90 December 3, 2024 11:14
Copy link
Member

@jotacarma90 jotacarma90 left a comment

Choose a reason for hiding this comment

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

LGTM

@vikman90 vikman90 merged commit 554b973 into master Dec 3, 2024
5 checks passed
@vikman90 vikman90 deleted the feature/368-request-trace-logs branch December 3, 2024 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log Headers and Content of HTTP Requests in Trace Mode
2 participants