forked from sourcegraph/appdash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_opentracing_socket.py
More file actions
38 lines (28 loc) · 883 Bytes
/
Copy pathexample_opentracing_socket.py
File metadata and controls
38 lines (28 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# Imports
import time
import appdash
# Appdash: Socket Collector
from appdash.sockcollector import RemoteCollector
# Create a remote appdash collector.
collector = RemoteCollector(debug=True)
collector.connect(host="localhost", port=7701)
# Create a tracer
tracer = appdash.create_new_tracer(collector)
for i in range(0, 7):
# Generate a few spans with some annotations.
span = None
# Name the span.
if i == 0:
span = tracer.start_span("Request")
else:
span = tracer.start_span("SQL Query")
span.set_tag("query", "SELECT * FROM table_name;")
span.set_tag("foo", "bar")
if i % 2 == 0:
span.log_event("Hello world!")
child_span = tracer.start_span("child", child_of=span)
child_span.finish()
span.finish(finish_time=time.time()+2)
# Close the collector's connection.
collector.close()