You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the backtracepython module will automatically capture unhandled exceptions and create and send error reports from them. This behavior can be adjusted with the ```disable_global_handler``` option to ```bt.initialize``` (see below).
30
+
By default, the `backtracepython` module automatically captures unhandled exceptions and creates and sends error reports from them. This behavior can be adjusted with the `disable_global_handler` option in `bt.initialize` (see below).
30
31
31
32
### Sending Reports Manually
32
33
33
-
You can also send error reports manually within code. However, in order to get a correct callstack and source code context, you must send an error with a python exception context. To do this, you can raise a python exception then immediately send a report via the ```send_last_exception call```. A simple example:
34
+
You can also send error reports manually in your code. However, to get a correct callstack and source code context, you must send an error with a Python exception context. To do this, you can raise a Python exception and then immediately send a report using the `send_last_exception` call. Here's an example:
34
35
35
-
```try:
36
+
```python
37
+
try:
36
38
raiseException("This report was sent manually.")
37
39
except:
38
40
bt.send_last_exception()
39
41
```
40
42
41
-
## Reference
42
-
### bt.initialize(**kwargs)
43
+
## Documentation
44
+
45
+
### bt.initialize
46
+
43
47
#### Arguments
44
-
* endpoint - Required. Example: https://yourcompany.sp.backtrace.io:6098 . Sets the HTTP/HTTPS endpoint that error reports will be sent to.
45
-
token - Required. Example: 51cc8e69c5b62fa8c72dc963e730f1e8eacbd243aeafc35d08d05ded9a024121 Sets the token that will be used for authentication when sending an error report.
46
-
* attributes - Dictionary that contains additional attributes to be sent along with every error report. These can be overridden on an individual report with report.set_attribute Example: { 'application': "ApplicationName", 'serverId': "foo" }
47
-
* timeout - Defaults to 4. Maximum amount of seconds to wait for error report processing and sending before concluding it failed.
48
-
* debug_backtrace - Defaults to False . Set to True to have an error during collecting the report raise an exception, and to print some debugging information to stderr.
49
-
* disable_global_handler - Defaults to False. If this is False this module will insert itself in the sys.excepthook chain and report those errors automatically before re-raising the exception. Set to True to disable this. Note that in this case the only way error reports will be reported is if you manually create and send them.
50
-
* context_line_count - Defaults to 200 . When an error is reported, this many lines above and below each stack function are included in the report.
51
-
* tab_width - Defaults to 8. If there are any hard tabs in the source code, it is unclear how many spaces they should be indented to correctly display the source code. Therefore the error report can override this number to specify how many spaces a hard tab should be represented by when viewing source code.
48
+
49
+
- endpoint - Required. Example: https://yourcompany.sp.backtrace.io:6098 or https://submit.backtrace.io/{universe}/{token}/json. Sets the HTTP/HTTPS endpoint that error reports will be sent to. If submit.backtrace.io url is provided, the token argument is not required.
50
+
token - Required only if endpoint is not set to submit.backtrace.io. Example: 51cc8e69c5b62fa8c72dc963e730f1e8eacbd243aeafc35d08d05ded9a024121 Sets the token that will be used for authentication when sending an error report.
51
+
- attributes - Dictionary that contains additional attributes to be sent along with every error report. These can be overridden on an individual report with report.set_attribute Example: { 'application': "ApplicationName", 'serverId': "foo" }. Attributes values should be set to a primitive value such as boolean, integer or string.
52
+
- attachments - A list of file paths that will be sent with each report.
53
+
- ignore_ssl_certificate - Defaults to False. If True, ssl verification will be ignored during HTTP submission.
54
+
- timeout - Defaults to 4. Maximum amount of seconds to wait for error report processing and sending before concluding it failed.
55
+
- debug_backtrace - Defaults to False . Set to True to have an error during collecting the report raise an exception, and to print some debugging information to stderr.
56
+
- disable_global_handler - Defaults to False. If this is False this module will insert itself in the sys.excepthook chain and report those errors automatically before re-raising the exception. Set to True to disable this. Note that in this case the only way error reports will be reported is if you manually create and send them.
57
+
- context_line_count - Defaults to 200 . When an error is reported, this many lines above and below each stack function are included in the report.
58
+
- tab_width - Defaults to 8. If there are any hard tabs in the source code, it is unclear how many spaces they should be indented to correctly display the source code. Therefore the error report can override this number to specify how many spaces a hard tab should be represented by when viewing source code.
59
+
- collect_source_code - Default to True. By default Backtrace client collects corresponded source code and send it with the report. If set to False, the source code will not be collected.
52
60
53
61
### bt.BacktraceReport
54
62
55
63
Create a report object that you can later choose whether or not to send. This may be useful to track something like a request.
56
64
57
-
```report.set_attribute(key, value) ```
65
+
`report.set_attribute(key, value) `
58
66
Adds an attribute to a specific report. Valid types for value are str, float, int, and bool.
59
-
Attributes are indexed and searchable. See also ```addAnnotation```
67
+
Attributes are indexed and searchable. See also `addAnnotation`
60
68
61
-
```report.set_dict_attributes(dict)```
69
+
`report.set_dict_attributes(dict)`
62
70
63
71
Adds all key-value pairs of dict into the report recursively.
64
72
65
-
```report.set_annotation(key, value) ```
73
+
`report.get_attributes() `
74
+
75
+
Returns all report attributes.
76
+
77
+
`report.set_annotation(key, value) `
66
78
67
79
Adds an annotation to a specific report. Annotations, unlike attributes, are not indexed and searchable. However, they are available for inspection when you view a specific report.
error is an Error object. Backtrace will extract information from this object such as the error message and stack trace and send this information along with the report.
79
99
80
-
```report.capture_last_exception() ```
100
+
`report.capture_last_exception() `
81
101
82
-
This is the same as report.set_exception(*sys.exc_info())
102
+
This is the same as report.set_exception(\*sys.exc_info())
83
103
84
-
```report.log(line)```
104
+
`report.log(line)`
85
105
86
106
Adds a timestamped log message to the report. Log output is available when you view a report.
87
107
88
-
```report.send()```
108
+
`report.send()`
89
109
90
110
Sends the error report to the endpoint specified in initialize.
91
111
92
-
### bt.send_last_exception(**kwargs)
93
-
* attributes - dictionary of attributes to add to the report. See report.set_dict_attributes
94
-
* annotations - dictionary of annotations to add to the report. See report.set_dict_annotations
112
+
### bt.send_last_exception(\*\*kwargs)
95
113
114
+
- attributes - dictionary of attributes to add to the report. See report.set_dict_attributes
115
+
- annotations - dictionary of annotations to add to the report. See report.set_dict_annotations
96
116
97
117
## Contributing
98
118
99
119
To run the test suite:
100
120
101
121
```
102
-
python setup.py test
122
+
pytest
103
123
```
104
124
105
125
Since all of these implementations of Python are supported, be sure to run the
0 commit comments