Commit 5f2b40c4 authored by Nane Kratzke's avatar Nane Kratzke
Browse files

Instrumenting subsequent calls

parent e593b8fe
from flask import Flask, redirect
from jaeger_client import Config
from flask_opentracing import FlaskTracing
from flask_opentracing import FlaskTracing, FlaskTracer
import opentracing
import requests
import traceback
import os
# A very boring and basic hip-hop-service to demonstrate
# observalability and tracing.
# observability via tracing.
service = os.environ.get('HIPHOP', 'hiphop')
tier = int(os.environ.get('TIER', '1'))
app = Flask(__name__)
print("Hello World")
config = Config(config = {
'sampler': {
'type': 'const',
......@@ -35,11 +33,12 @@ def index():
def hip():
r = ""
try:
current_span = tracing.get_span(request)
text_carrier = {}
tracing.inject(span, opentracing.Format.TEXT_MAP, text_carrier)
print(text_carrier)
r = requests.get(f"http://{service}-{tier + 1}", headers=text_carrier, allow_redirects=True)
parent_span = flask_tracer.get_span()
with opentracing.tracer.start_span(f"{service}-{tier + 1}", child_of=parent_span) as span:
url = f"http://{service}-{tier + 1}"
span.set_tag("http.url", url)
r = requests.get(url)
span.set_tag("http.status_code", r.status_code)
print(r)
r = r.content.decode('utf-8')
except Exception as ex:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment