Commit a604531a authored by Nane Kratzke's avatar Nane Kratzke
Browse files

Aktualisieren space/requirements.txt, space/service.py Dateien

parent add19267
......@@ -3,3 +3,4 @@ requests
opentracing
jaeger-client
joblib
elastic-apm[flask]
\ No newline at end of file
......@@ -6,6 +6,8 @@ import traceback
import os
import json
from joblib import Parallel, delayed
from elasticapm.contrib.flask import ElasticAPM
apm = ElasticAPM(app)
# A very boring and basic space-service to demonstrate
# observability via tracing.
......@@ -13,13 +15,13 @@ from joblib import Parallel, delayed
service = os.environ.get('SERVICE', 'space')
app = Flask(__name__)
config = Config(config = {
'sampler': { 'type': 'const', 'param': 1 },
'logging': True,
'reporter_batch_size': 1
}, service_name=service)
# config = Config(config = {
# 'sampler': { 'type': 'const', 'param': 1 },
# 'logging': True,
# 'reporter_batch_size': 1
# }, service_name=service)
tracer = config.initialize_tracer()
# tracer = config.initialize_tracer()
@app.route('/')
def index():
......@@ -33,7 +35,7 @@ def load_url(key, url):
@app.route('/space')
def space():
with tracer.start_span(operation_name="space") as parent_span:
#with tracer.start_span(operation_name="space") as parent_span:
try:
lat = float(request.args.get('lat', "0.0001"))
lon = float(request.args.get('lon', "0.0001"))
......@@ -47,7 +49,7 @@ def space():
"passtime": f"http://api.open-notify.org/iss-pass.json?lat={ lat }&lon={ lon }"
}
with tracer.start_span(operation_name="parallel", child_of=parent_span) as span:
#with tracer.start_span(operation_name="parallel", child_of=parent_span) as span:
results = Parallel(n_jobs=3)(delayed(load_url)(key, url) for key, url in queries.items())
result = { key: content for key, content in results }
......
Markdown is supported
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