Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.

Commit eab4d43

Browse files
author
Stephen Gutekanst
committed
python: add a example Python script
1 parent c013096 commit eab4d43

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎python/example.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/python
2+
3+
# Twisted imports
4+
from twisted.internet import reactor
5+
6+
# Appdash imports
7+
import appdash
8+
9+
# Create a remote appdash collector.
10+
collector = appdash.RemoteCollectorFactory(reactor, debug=True)
11+
12+
13+
# TODO(slimsag): do not require direct usage of protobuf.
14+
import appdash.collector_pb2 as wire
15+
16+
# Send a few packets.
17+
for i in range(0, 7):
18+
# Create a collect packet
19+
p = wire.CollectPacket()
20+
p.spanid.trace = 6665
21+
p.spanid.span = 6665
22+
p.spanid.parent = 0
23+
24+
# Annotation 1
25+
a = p.annotation.add()
26+
a.key = "HTTPClient"
27+
a.value = "/foo/bar?eq=1"
28+
29+
# Annotation 2
30+
a2 = p.annotation.add()
31+
a2.key = "SQL"
32+
a2.value = "select * from table;"
33+
34+
# Collect the packet.
35+
collector.collect(p)
36+
37+
38+
# Have Twisted perform the connection and run.
39+
reactor.connectTCP("", 7701, collector)
40+
reactor.run()

0 commit comments

Comments
 (0)