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

Snapcloud #1

Merged
merged 3 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions raven/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ function _M.new(conf)
logger = conf.logger or "root",
tags = conf.tags or nil,
extra = conf.extra or nil,
environment = conf.environment or nil
}

return setmetatable(obj, raven_mt)
Expand All @@ -148,6 +149,15 @@ function _M.get_server_name()
return "undefined"
end

--- This method is reponsible to return the `request` field of an event.
-- The default implementation just returns `{}`, users are encouraged
-- to override this to something more sensible.
-- See [Sentry's docs](https://develop.sentry.dev/sdk/event-payloads/request/)
-- for the list of allowed properties.
function _M.get_request_data()
return {}
end

--- This table can be used to tune the message reporting.
-- @field tags Tags for the message, they will be coalesced with the ones
-- provided in the @{sentry_conf} table used in the constructor if any. In
Expand Down Expand Up @@ -296,11 +306,12 @@ function raven_mt:send_report(json, conf)
end
end

json.event_id = event_id
json.timestamp = iso8601()
json.level = self.level
json.platform = "lua"
json.logger = self.logger
json.event_id = event_id
json.timestamp = iso8601()
json.level = self.level
json.platform = "lua"
json.logger = self.logger
json.environment = self.environment

if conf then
json.tags = merge_tables(conf.tags, self.tags)
Expand All @@ -309,11 +320,18 @@ function raven_mt:send_report(json, conf)
if conf.level then
json.level = conf.level
end
if conf.user then
json.user = merge_tables(conf.user, self.user)
end
if conf.contexts then
json.contexts = conf.contexts
end
else
json.tags = self.tags
json.extra = self.extra
end

json.request = _M.get_request_data()
json.server_name = _M.get_server_name()

local json_str = json_encode(json)
Expand Down
2 changes: 1 addition & 1 deletion raven/senders/luasocket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function mt:send(json_str)
method = "POST",
url = self.server,
headers = {
['Content-Type'] = 'applicaion/json',
['Content-Type'] = 'application/json',
['User-Agent'] = "raven-lua-socket/" .. _VERSION,
['X-Sentry-Auth'] = generate_auth_header(self),
["Content-Length"] = tostring(#json_str),
Expand Down