Skip to content

Commit

Permalink
fix otel docker
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Dec 18, 2023
1 parent 14b1d61 commit c9ed074
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ services:
LETSENCRYPT_HOST: openpredict.semanticscience.org
VIRTUAL_PORT: 8808

JAEGER_ENABLED: true
OTEL_SERVICE_NAME: OPENPREDICT
JAEGER_HOST: jaeger-otel-agent.sri
JAEGER_PORT: 6831
OTEL_SERVICE_NAME: OPENPREDICT

# OPENPREDICT_APIKEY: ${OPENPREDICT_APIKEY}

Expand Down
8 changes: 4 additions & 4 deletions src/trapi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
app.include_router(drkg_model_api)


def configure_otel(service_name, app):
def configure_otel(app):
# open telemetry https://github.com/ranking-agent/aragorn/blob/main/src/otel_config.py#L4
# https://ncatstranslator.github.io/TranslatorTechnicalDocumentation/deployment-guide/monitoring/
# https://github.com/TranslatorSRI/Jaeger-demo
if os.environ.get('JAEGER_ENABLED') == "True":
if os.environ.get('OTEL_SERVICE_NAME'):
logging.info("starting up jaeger telemetry")
import warnings
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
Expand All @@ -132,6 +132,7 @@ def configure_otel(service_name, app):
# these supresses such warnings.
logging.captureWarnings(capture=True)
warnings.filterwarnings("ignore",category=ResourceWarning)
service_name = os.environ.get('OTEL_SERVICE_NAME', 'OPENPREDICT')
trace.set_tracer_provider(
TracerProvider(
resource=Resource.create({telemetery_service_name_key: service_name})
Expand All @@ -151,5 +152,4 @@ def configure_otel(service_name, app):
HTTPXClientInstrumentor().instrument()

# Configure open telemetry if enabled
service_name = os.environ.get('OTEL_SERVICE_NAME', 'OPENPREDICT')
configure_otel(service_name, app)
configure_otel(app)

0 comments on commit c9ed074

Please sign in to comment.