From ea47a6011fe01d5431662eda9b6a3a27dbf30ae5 Mon Sep 17 00:00:00 2001 From: Mark Dietzer Date: Thu, 19 Aug 2021 20:02:38 -0700 Subject: [PATCH 1/3] Add call_ext --- raven/init.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/raven/init.lua b/raven/init.lua index 0bed5b4..2ae3dff 100644 --- a/raven/init.lua +++ b/raven/init.lua @@ -377,12 +377,27 @@ end -- end -- return rvn:call(func, 1, 'foo', true) function raven_mt:call(f, ...) + return self:call_ext(nil, f, ...) +end + +--- Call given function and report any errors to Sentry with conf overrides. +-- @function Raven:call_ext +-- @param conf Conf overrides +-- @param f function to be called +-- @param ... function's arguments +-- @return the same as @{xpcall} +-- @usage +-- function func(a, b, c) +-- return a * b + c +-- end +-- return rvn:call_ext({}, func, 1, 'foo', true) +function raven_mt:call_ext(conf, f, ...) -- When used with ngx_lua, connecting a tcp socket in xpcall error handler -- will cause a "yield across C-call boundary" error. To avoid this, we -- move all the network operations outside of the xpcall error handler. local res = { xpcall(f, capture_error_handler, ...) } if not res[1] then - self:send_report(res[2]) + self:send_report(res[2], conf) res[2] = res[2].message -- turn the error object back to its initial form end From f3cc6ab9b158c9f3b32f94762dfcc1eb3af331f0 Mon Sep 17 00:00:00 2001 From: Mark Dietzer Date: Mon, 26 Sep 2022 23:42:17 -0700 Subject: [PATCH 2/3] Upstream merge (#1) Co-authored-by: Daniela Bento Co-authored-by: Michael Ball --- raven/init.lua | 2 +- raven/senders/ngx.lua | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/raven/init.lua b/raven/init.lua index 2ae3dff..fa581fa 100644 --- a/raven/init.lua +++ b/raven/init.lua @@ -163,7 +163,7 @@ end --- This method can be used to tag a release in Sentry. -- Typically you can use it with a commit hash. function _M.get_release() - return '' + return nil end --- This table can be used to tune the message reporting. diff --git a/raven/senders/ngx.lua b/raven/senders/ngx.lua index 5e92548..9d63553 100644 --- a/raven/senders/ngx.lua +++ b/raven/senders/ngx.lua @@ -268,8 +268,33 @@ function _M.get_request_data() url = ngx.var.request_uri or nil, query_string = ngx.var.query_string or nil, env = { + -- some information can be only accessed if the request is at log phase + HOSTNAME = ngx.var.hostname, + METHOD = ngx.var.request_method or nil, + BODY_BYTES_SENT = ngx.var.body_bytes_sent or nil, + BYTES_RECEIVED = ngx.var.bytes_received or nil, + BYTES_SENT = ngx.var.bytes_sent or nil, + NGINX_VERSION = ngx.var.nginx_version or nil, REMOTE_ADDR = ngx.var.remote_addr or nil, - }, + REMOTE_PORT = ngx.var.remote_port or nil, + REQUEST_TIME = ngx.var.request_time or nil, + STATUS = ngx.var.status or nil, + USER_AGENT = ngx.var.http_user_agent or nil, + CONTENT_TYPE = ngx.var.http_content_type or nil, + CONTENT_LENGTH = ngx.var.http_content_length or nil, + -- proxy related information + PROXY_ADD_X_FORWARDED_FOR = ngx.var.proxy_add_x_forwarded_for or nil, + UPSTREAM_ADDR = ngx.var.upstream_add or nil, + UPSTREAM_BYTES_RECEIVED = ngx.var.upstream_bytes_received or nil, + UPSTREAM_BYTES_SENT = ngx.var.upstream_bytes_sent or nil, + UPSTREAM_CACHE_STATUS = ngx.var.upstream_cache_status or nil, + UPSTREAM_CONNECT_TIME = ngx.var.upstream_connect_time or nil, + UPSTREAM_FIRST_BYTE_TIME = ngx.var.upstream_first_byte_time or nil, + UPSTREAM_HEADER_TIME = ngx.var.upstream_header_time or nil, + UPSTREAM_RESPONSE_LENGTH = ngx.var.upstream_response_length or nil, + UPSTREAM_RESPONSE_TIME = ngx.var.upstream_response_time or nil, + UPSTREAM_STATUS = ngx.var.upstream_status or nil, + }, } end return { From 6736f8e7b1682b1683665d27203c9c659869f999 Mon Sep 17 00:00:00 2001 From: Mark Dietzer Date: Mon, 26 Sep 2022 23:42:38 -0700 Subject: [PATCH 3/3] Revert "Upstream merge (#1)" This reverts commit f3cc6ab9b158c9f3b32f94762dfcc1eb3af331f0. --- raven/init.lua | 2 +- raven/senders/ngx.lua | 27 +-------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/raven/init.lua b/raven/init.lua index fa581fa..2ae3dff 100644 --- a/raven/init.lua +++ b/raven/init.lua @@ -163,7 +163,7 @@ end --- This method can be used to tag a release in Sentry. -- Typically you can use it with a commit hash. function _M.get_release() - return nil + return '' end --- This table can be used to tune the message reporting. diff --git a/raven/senders/ngx.lua b/raven/senders/ngx.lua index 9d63553..5e92548 100644 --- a/raven/senders/ngx.lua +++ b/raven/senders/ngx.lua @@ -268,33 +268,8 @@ function _M.get_request_data() url = ngx.var.request_uri or nil, query_string = ngx.var.query_string or nil, env = { - -- some information can be only accessed if the request is at log phase - HOSTNAME = ngx.var.hostname, - METHOD = ngx.var.request_method or nil, - BODY_BYTES_SENT = ngx.var.body_bytes_sent or nil, - BYTES_RECEIVED = ngx.var.bytes_received or nil, - BYTES_SENT = ngx.var.bytes_sent or nil, - NGINX_VERSION = ngx.var.nginx_version or nil, REMOTE_ADDR = ngx.var.remote_addr or nil, - REMOTE_PORT = ngx.var.remote_port or nil, - REQUEST_TIME = ngx.var.request_time or nil, - STATUS = ngx.var.status or nil, - USER_AGENT = ngx.var.http_user_agent or nil, - CONTENT_TYPE = ngx.var.http_content_type or nil, - CONTENT_LENGTH = ngx.var.http_content_length or nil, - -- proxy related information - PROXY_ADD_X_FORWARDED_FOR = ngx.var.proxy_add_x_forwarded_for or nil, - UPSTREAM_ADDR = ngx.var.upstream_add or nil, - UPSTREAM_BYTES_RECEIVED = ngx.var.upstream_bytes_received or nil, - UPSTREAM_BYTES_SENT = ngx.var.upstream_bytes_sent or nil, - UPSTREAM_CACHE_STATUS = ngx.var.upstream_cache_status or nil, - UPSTREAM_CONNECT_TIME = ngx.var.upstream_connect_time or nil, - UPSTREAM_FIRST_BYTE_TIME = ngx.var.upstream_first_byte_time or nil, - UPSTREAM_HEADER_TIME = ngx.var.upstream_header_time or nil, - UPSTREAM_RESPONSE_LENGTH = ngx.var.upstream_response_length or nil, - UPSTREAM_RESPONSE_TIME = ngx.var.upstream_response_time or nil, - UPSTREAM_STATUS = ngx.var.upstream_status or nil, - }, + }, } end return {