ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.66k stars 750 forks source link

[New Feature]: Log each request and response with relevant details for deriving metrics #43516

Closed chathurace closed 4 hours ago

chathurace commented 4 hours ago

Description

Logging each request and response with a timestamp, status, response time, etc, is useful for observability purposes. This is especially useful for deriving metrics from logs. Such logs need to be generated from all transports, and should have the ability to enable or disable logging via a configuration.

This is applicable to both Ballerina and MI.

e.g. logs for HTTP: [timestamp] <request|response> [2024-07-27T11:31:06] request b76a4c42-8eaa-466b-b471-fbfa4cb759bf GET /sales /accounts [2024-07-27T11:31:06] response 9e01c068-97c9-44be-8424-5643eb4852 GET /sales /accounts 200 2489

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Shadow-Devil commented 4 hours ago

I think this is already implemented: https://ballerina.io/learn/by-example/http-trace-logs/