Skip to content

Instantly share code, notes, and snippets.

@itsderek23
Last active June 3, 2022 12:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save itsderek23/68d4336f582e3a6c7d58798a6462f191 to your computer and use it in GitHub Desktop.
Save itsderek23/68d4336f582e3a6c7d58798a6462f191 to your computer and use it in GitHub Desktop.
from flask import Flask
from flask import request
import requests
from jaeger_client import Config
from flask_opentracing import FlaskTracer
app = Flask(__name__)
@app.route('/')
def pull_requests():
# Fetch a list of pull requests on the opentracing repository
github_url = "https://api.github.com/repos/opentracing/opentracing-python/pulls"
r = requests.get(github_url)
json = r.json()
pull_request_titles = map(lambda item: item['title'], json)
return 'OpenTracing Pull Requests: ' + ', '.join(pull_request_titles)
def initialize_tracer():
config = Config(
config={
'sampler': {'type': 'const', 'param': 1}
},
service_name='hello-world')
return config.initialize_tracer() # also sets opentracing.tracer
flask_tracer = FlaskTracer(initialize_tracer, True, app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment