tracing fixes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-08-04 15:20:29 +02:00
parent 977fc98ed2
commit ee9dea06fb
3 changed files with 34 additions and 30 deletions

View File

@@ -19,15 +19,16 @@ class MagicDoer:
@classmethod
def run_everything(cls, parameters: dict) -> dict:
span = opentracing.tracer.scope_manager.active().span
tag = parameters['tag']
sample_file_handle, sample_file_path = tempfile.mkstemp(prefix=f"{tag}_", suffix=".wav", dir="/dev/shm")
span = opentracing.tracer.scope_manager.active().span
span.log_kv({'event': 'sampleFileOpened', 'sampleTag': tag})
response = None
try:
with opentracing.tracer.start_active_span('downloadSample', child_of=span):
with opentracing.tracer.start_active_span('magicDoer.downloadSample'):
# Download Sample
object_path = urljoin(Config.STORAGE_SERVICE_URL, f"object/{tag}")
@@ -38,11 +39,11 @@ class MagicDoer:
logging.debug(f"Downloaded sample to {sample_file_path}")
with opentracing.tracer.start_active_span('loadClassifier', child_of=span):
with opentracing.tracer.start_active_span('magicDoer.getClassifier'):
# Get a classifier that uses the default model
model_details, classifier = cls.classifier_cache.get_default_classifier()
with opentracing.tracer.start_active_span('runClassifier', child_of=span) as child_span:
with opentracing.tracer.start_active_span('magicDoer.runClassifier'):
# do the majic
classification_start_time = time.time()
predicted_class_name, labeled_predictions = classifier.predict(sample_file_path)
@@ -63,6 +64,7 @@ class MagicDoer:
except FileNotFoundError:
pass
span = opentracing.tracer.scope_manager.active().span
span.log_kv({'event': 'sampleFileDeleted', 'sampleTag': tag})
if not response: