forked from instana/python-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.py
More file actions
44 lines (36 loc) · 1.36 KB
/
Copy pathsimple.py
File metadata and controls
44 lines (36 loc) · 1.36 KB
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
39
40
41
42
43
44
import sys
import instana.options as o
import logging
import opentracing as ot
import instana.tracer
import time
import opentracing.ext.tags as ext
SERVICE = "python-overlord"
def main(argv):
instana.tracer.init(o.Options(service=SERVICE,
log_level=logging.DEBUG))
while (True):
time.sleep(2)
simple()
def simple():
parent_span = ot.tracer.start_span(operation_name="asteroid")
parent_span.set_tag(ext.COMPONENT, "Python simple example app")
parent_span.set_tag(ext.SPAN_KIND, ext.SPAN_KIND_RPC_SERVER)
parent_span.set_tag(ext.PEER_HOSTNAME, "localhost")
parent_span.set_tag(ext.HTTP_URL, "/python/simple/one")
parent_span.set_tag(ext.HTTP_METHOD, "GET")
parent_span.set_tag(ext.HTTP_STATUS_CODE, 200)
parent_span.log_kv({"foo": "bar"})
child_span = ot.tracer.start_span(operation_name="spacedust", child_of=parent_span)
child_span.set_tag(ext.SPAN_KIND, ext.SPAN_KIND_RPC_CLIENT)
child_span.set_tag(ext.PEER_HOSTNAME, "localhost")
child_span.set_tag(ext.HTTP_URL, "/python/simple/two")
child_span.set_tag(ext.HTTP_METHOD, "POST")
child_span.set_tag(ext.HTTP_STATUS_CODE, 204)
child_span.set_baggage_item("someBaggage", "someValue")
time.sleep(.1)
child_span.finish()
time.sleep(.2)
parent_span.finish()
if __name__ == "__main__":
main(sys.argv)