backtrace-labs / backtrace-python Goto Github PK
View Code? Open in Web Editor NEWPython integration into the Backtrace object store.
License: MIT License
Python integration into the Backtrace object store.
License: MIT License
"application": "foo", // source application of fault
"cpu.boottime": 1234234234, // time when system was booted
"cpu.context": 1234, // the number of context switches on the system
"cpu.idle": 1234234, // idle cpu time
"cpu.iowait": 1234143, // time waiting for I/O to complete
"cpu.irq": 1234113, // time servicing interrupts
"cpu.kernel": "foo", // kernel cpu utilization
"cpu.nice": "foo", // scheduling nice value
"cpu.process.blocked": 1234, // number of blocked processes
"cpu.process.count": 1234, // number of processes
"cpu.process.running": 1234, // number of running processes
"cpu.softirq": "foo", // time servicing soft-interrupts
"cpu.user": 1234, // user cpu utilization
"descriptor.count": 1234, // descriptor table size
// memory address associated with fault [memory_address]
"fault.address": "foo",
"fingerprint": "foo", // primary fault signature [sha256]
"hostname": "foo", // hostname of the faulting system [hostname]
"sched.cs.involuntary": 1234, // number of involuntary context switches
"sched.cs.voluntary": 1234, // number of voluntary context switches
"system.memory.active": 1234, // recently used memory [bytes]
// temporary storage for raw disk blocks [bytes]
"system.memory.buffers": 1234,
"system.memory.cached": 1234, // buffer cache size for files [bytes]
// memory waiting to get written back to disk [bytes]
"system.memory.dirty": 1234,
"system.memory.free": 1234, // amount of free memory [bytes]
// memory that has not been recently used [bytes]
"system.memory.inactive": 1234,
"system.memory.slab": 1234, // kernel data structure cache [bytes]
"system.memory.swap.cached": 1234, // memory still backed by swap [bytes]
"system.memory.swap.free": 1234, // unused swap space [bytes]
"system.memory.swap.total": 1234, // total swap space [bytes]
"system.memory.total": 1234, // total usable memory [bytes]
// largest free contiguous block of vmalloc area [bytes]
"system.memory.vmalloc.chunk": 1234,
"system.memory.vmalloc.total": 1234, // vmalloc memory area [bytes]
"system.memory.vmalloc.used": 1234, // used vmalloc memory area [bytes]
// memory that is being written back to disk [bytes]
"system.memory.writeback": 1234,
"uname.machine": "x86_64", // machine hardware name
"uname.release": "4.4.0-38-generic", // kernel release
"uname.sysname": "Linux", // kernel name
// kernel version
"uname.version": "#57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016",
"vm.data.size": 1234, // size of data segment [bytes]
"vm.locked.size": 1234, // locked memory size [bytes]
"vm.pte.size": 1234, // page table entries size [bytes]
"vm.rss.peak": 1234, // peak resident memory size [bytes]
"vm.rss.size": 1234, // resident memory size [bytes]
"vm.shared.size": 1234, // shared library size [bytes]
"vm.stack.size": 1234, // size of stack segment [bytes]
"vm.swap.size": 1234, // swap memory size [bytes]
"vm.vma.peak": 1234, // peak virtual memory size [bytes]
"vm.vma.size": 1234, // virtual memory size [bytes]
"mem.rss": 1234,
"mem.heap.total": 1234,
"mem.heap.used": 1234,
Test case:
import sys, os
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, root_dir)
import backtracepython as bt
host, port = sys.argv[1:]
endpoint = "http://{}:{}".format(host, port)
bt.initialize(
endpoint=endpoint,
token="FakeToken",
debug_backtrace=True,
context_line_count=2,
)
import threading
import time
def thread_one():
while True:
time.sleep(0.1)
def thread_two():
while True:
time.sleep(0.2)
threading.Thread(target=thread_one).start()
threading.Thread(target=thread_one).start()
threading.Thread(target=thread_two).start()
this = broken
The child trying to read stdin never gets input, even though we write it over the pipe.
Tested on Python2/Python3 on MacOs
https://xxxxxxxxxxx.sp.backtrace.io/p/xxxxxxxx/settings/integration-guides?doc=python
Error:
Vincents-MacBook-Pro-7:petportal vincentlussenburg$ python3
Python 3.7.3 (default, Mar 27 2019, 09:23:32)
[Clang 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import backtracepython as bt
>>>
>>> bt.initialize(
... endpoint="https://submit.backtrace.io/testing-jknkjnnl/abshsdbfjsdhfbsdjfbsjdhf/json",
... token="abshsdbfjsdhfbsdjfbsjdhf"
... )
>>> try:
... data = open("foo.txt").read()
... except:
... bt.send_last_exception()
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'foo.txt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/local/lib/python3.7/site-packages/backtracepython/__init__.py", line 249, in send_last_exception
report = BacktraceReport()
File "/usr/local/lib/python3.7/site-packages/backtracepython/__init__.py", line 112, in __init__
entry_path = os.path.abspath(__main__.__file__)
AttributeError: module '__main__' has no attribute '__file__'
DOES WORK when put into a python file directly
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.