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

Commit bc09fcc

Browse files
author
Stephen Gutekanst
committed
python: Update example to not require direct usage of protobuf.
1 parent 3b2490c commit bc09fcc

1 file changed

Lines changed: 17 additions & 24 deletions

File tree

‎python/example.py‎

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,25 @@
99
# Create a remote appdash collector.
1010
collector = appdash.RemoteCollectorFactory(reactor, debug=True)
1111

12+
# Create a trace.
13+
trace = appdash.SpanID(root=True)
1214

13-
# TODO(slimsag): do not require direct usage of protobuf.
14-
import appdash.collector_pb2 as wire
15-
16-
# Send a few packets.
17-
traceID = appdash.generateID()
15+
# Generate a few spans with some annotations.
16+
span = trace
1817
for i in range(0, 7):
19-
# Create a collect packet
20-
p = wire.CollectPacket()
21-
p.spanid.trace = traceID
22-
p.spanid.span = appdash.generateID()
23-
p.spanid.parent = 0
24-
25-
# Annotation 1
26-
a = p.annotation.add()
27-
a.key = "HTTPClient"
28-
a.value = "/foo/bar?eq=1"
29-
30-
# Annotation 2
31-
a2 = p.annotation.add()
32-
a2.key = "SQL"
33-
a2.value = "select * from table;"
34-
35-
# Collect the packet.
36-
collector.collect(p)
37-
18+
# Collect some annotations.
19+
a1 = appdash.Annotation(
20+
key="HTTPClient",
21+
value="/foo/bar?eq=1",
22+
)
23+
a2 = appdash.Annotation(
24+
key="SQL",
25+
value="select * from table;",
26+
)
27+
collector.collect(span, a1, a2)
28+
29+
# Create a new child span whose parent is the last span we created.
30+
span = appdash.SpanID(parent=span)
3831

3932
# Have Twisted perform the connection and run.
4033
reactor.connectTCP("", 7701, collector)

0 commit comments

Comments
 (0)