Module sentry
Provides an interface to Sentry from GLua
Github Page
Info:
- Copyright: 2018 Lex Robinson
- Author: Lex Robinson
ISODate (time) |
Generates an ISO 8601/RFC 6350 formatted date |
GetOSName () |
Generates a pretty printed name of the current operating sytem |
-
CaptureException (err, extra)
-
Captures an exception for sentry, using the current stack as the error's stack
Most useful inside an xpcall handler
Parameters:
- err
The raw Lua error that happened, with or without file details
- extra
Any other information about the error to upload to Sentry with it
Returns:
The generated error's ID or nil if it was automatically discarded
-
pcall ([extra], func, ...)
-
Works like normal pcall
but uploads the error to Sentry as well as returning it
Parameters:
- extra
Other info to send to the server if func errors
(optional)
- func
The function to pcall
- ...
Arguments to pass to func
Returns:
Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.
-
ExecuteInTransaction ([name][, txn], func, ...)
-
Executes a function in transaction context.
If the function throws an error, the error will be reported to sentry and then will be re-raised.
If you don't want the error re-raised, use sentry.pcall
Both name and txn are optional
Parameters:
- name
The name of the transaction or nil if not applicable
(optional)
- txn
The data to attach to the transaction
(optional)
- func
The function to execute
- ...
Arguments to pass to the function
Returns:
Whatever func returns
Usage:
sentry.ExecuteInTransaction("My Thing", mything)
sentry.ExecuteInTransaction({ tags = { mything = "awesome"} }, mything)
-
Setup (dsn[, extra])
-
Configures and activates Sentry
Parameters:
- dsn
The DSN sentry gave you when you set up your project
- extra
Additional config values to store in sentry. Valid keys
tags
, release
, environment
, server_name
, no_detour
(optional)
Usage:
sentry.Setup("https://key@sentry.io/1337", {server_name="server 7", release="v23", environment="production"})
-
DetectedModules
-
All the modules Sentry has detected.
Anything added to this will also be sent to Sentry
Usage:
sentry.DetectedModules["foo"] = "7.2"
-
DetectionFuncs
-
More complex ways of detecting a module's version
Fields:
Usage:
sentry.DetectionFuncs["global name"] = function(global_value) return "version", "optional override name" end
-
ISODate (time)
-
Generates an ISO 8601/RFC 6350 formatted date
Parameters:
- time
The unix timestamp to generate the date from
Returns:
The date string
-
GetOSName ()
-
Generates a pretty printed name of the current operating sytem
Returns:
"Windows", "macOS", "Linux" or nil.
-
IsInTransaction ()
-
Checks if Sentry thinks a transaction is active
Ideally true, but could be false if an undetoured entrypoint is used
Returns:
true or false
-
ExecuteTransaction (name, txn, func, ...)
-
[INTERNAL] Executes a function in transaction context
Parameters:
- name
The name of the transaction or nil if not applicable
- txn
The data to attach to the transaction
- func
The function to execute
- ...
Arguments to pass to the function
Returns:
Whatever func returns
-
MergeContext (data)
-
Add data to the current transaction's context.
Anything here will override the transaction's starting values
Does nothing if no transaction is active
Parameters:
Usage:
sentry.MergeContext({ culprit = "your mum" })
-
ClearContext ()
-
Remove any extra data from the current transaction.
Does not affect the data the transaction was started with.
Does nothing if no transaction is active
-
TagsContext (tags)
-
Merge tags into the current transaction's context
Does nothing if no transaction is active
Parameters:
- tags
A table of tag names as keys, values as values
Usage:
sentry.TagsContext({ somecondition = "passed" })
-
ExtraContext (tags)
-
Merge the extra field into the current transaction's context
Does nothing if no transaction is active
Parameters:
- tags
A table of arbitrary data to send to Sentry
Usage:
sentry.ExtraContext({ numplayers = 23 })
-
UserContext (user)
-
Set the current player for this context
Does nothing if no transaction is active
Parameters:
Usage:
sentry.UserContext(ply)