Skip to content

Instantly share code, notes, and snippets.

Created January 17, 2018 15:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pglombardo/d9064796954cd9e7cb10c5e149b7560e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import datetime
from functools import wraps
import instana
import tornado.httpserver
import tornado.ioloop
import tornado.ioloop
import tornado.web
import tornado.web
import opentracing
from opentracing import Tracer
from instana import options
from instana import tracer
import opentracing.ext.tags as tags
import logging
instana.service_name = "Python Service"
class MainHandler(tornado.web.RequestHandler):
def initialize(self):
print ("INITIALIZE this BITCH!")
self.root_span = opentracing.tracer.start_span(operation_name='root')
self.requestmethod = ""
self.clazzName = self.__class__.__name__
def get(self):
self.requestmethod = "GET"
get_span = opentracing.tracer.start_span(operation_name="tornade-request", child_of=self.root_span)
get_span.set_tag(tags.COMPONENT, "Tornado")
get_span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_SERVER)
get_span.set_tag(tags.PEER_HOSTNAME, "localhost")
get_span.set_tag(tags.HTTP_URL, "/tornado")
get_span.set_tag(tags.HTTP_METHOD, "GET")
get_span.set_tag(tags.HTTP_STATUS_CODE, 200)
status = self.__class__.get_status(self)
request = self.request
self.write("<h1>Welcome to the Python Tracing</h1>")
welcomeMessage = """Welcome to the Instana Python Sensor and Tracing Example.
The instana package provides Python metrics and traces (request, queue & cross-host) for Instana. Build Status OpenTracing Badge
Note This package supports Python 2.7 or greater.
Any and all feedback is welcome. Happy Python visibility. See the
<a href="">Python Sensor</a>
Installation : pip install instana into the virtual-env or container (hosted on pypi)
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
if __name__ == "__main__":
app = make_app()
portNumber = 8889
print ("Starting Tornado Server on port " + str(portNumber))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment