Skip to content

Commit 9cde3aa

Browse files
committed
Fix issue with Elastic logger when conn is present in metadata
The formatter was dropping the keys that are not specific for HTTP request because a Jason.Encoder struct was merged in a parent map
1 parent e181c26 commit 9cde3aa

File tree

2 files changed

+419
-8
lines changed

2 files changed

+419
-8
lines changed

lib/logger_json/formatters/elastic.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,15 @@ defmodule LoggerJSON.Formatters.Elastic do
229229
# - url.path: https://www.elastic.co/guide/en/ecs/8.11/ecs-url.html
230230
# - user_agent.original: https://www.elastic.co/guide/en/ecs/8.11/ecs-user_agent.html
231231
defp format_http_request(%{conn: %Plug.Conn{} = conn}) do
232-
Jason.Helpers.json_map(
232+
%{
233233
"client.ip": LoggerJSON.Formatter.Plug.remote_ip(conn),
234234
"http.version": Plug.Conn.get_http_protocol(conn),
235235
"http.request.method": conn.method,
236236
"http.request.referrer": LoggerJSON.Formatter.Plug.get_header(conn, "referer"),
237237
"http.response.status_code": conn.status,
238238
"url.path": conn.request_path,
239239
"user_agent.original": LoggerJSON.Formatter.Plug.get_header(conn, "user-agent")
240-
)
240+
}
241241
end
242242
end
243243

0 commit comments

Comments
 (0)