Skip to content

Commit

Permalink
fixes bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Oct 20, 2021
1 parent 890951d commit ef687d5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/service-library/src/servicelib/aiohttp/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setup_tracing(
zipkin_address = URL(f"{jaeger_base_url}") / "api/v2/spans"

log.debug(
"Settings up tracing for %s(%s:%d) -> %s",
"Settings up tracing for %s at %s:%d -> %s",
service_name,
host,
port,
Expand All @@ -67,7 +67,7 @@ def setup_tracing(
)

# WARNING: adds a middleware that should be the outermost since
# it expects stream responses and not flexible handler returns
# it expects stream responses while we allow data returns from a handler
az.setup(app, tracer)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
from models_library.basic_types import VersionTag
from pydantic import BaseSettings, Field

from ._meta import api_vtag
from .constants import APP_CONFIG_KEY, APP_OPENAPI_SPECS_KEY

from ._meta import API_VTAG
from .constants import APP_CONFIG_KEY, APP_OPENAPI_SPECS_KEY

CONFIG_SECTION_NAME = "rest"

Expand Down
35 changes: 27 additions & 8 deletions services/web/server/src/simcore_service_webserver/tracing.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
import logging
from typing import Tuple

import trafaret as T
from aiohttp import web
from servicelib.aiohttp.application_keys import APP_CONFIG_KEY
from servicelib.aiohttp.application_setup import ModuleCategory, app_module_setup
from servicelib.aiohttp.tracing import schema, setup_tracing

from ._meta import APP_NAME
from servicelib.aiohttp.tracing import setup_tracing
from settings_library.tracing import TracingSettings

CONFIG_SECTION_NAME = "tracing"

log = logging.getLogger(__name__)


# TODO: deprecated by TracingSettings in https://github.com/ITISFoundation/osparc-simcore/pull/2376
# NOT used
schema = T.Dict(
{
T.Key("enabled", default=True, optional=True): T.Or(T.Bool(), T.ToInt),
T.Key("zipkin_endpoint", default="http://jaeger:9411"): T.String(),
}
)


@app_module_setup(__name__, ModuleCategory.ADDON, logger=log)
def setup_app_tracing(app: web.Application):
config = app[APP_CONFIG_KEY]
host = config["main"]["host"]
port = config["main"]["port"]
return setup_tracing(
app, "simcore_service_webserver", host, port, config["tracing"]
)

# TODO: this should be part of app settings but
# temporary here until
# https://github.com/ITISFoundation/osparc-simcore/pull/2376 is completed
cfg = config[CONFIG_SECTION_NAME]

settings = TracingSettings()
assert str(settings.TRACING_ZIPKIN_ENDPOINT) == str(cfg["zipkin_endpoint"]) # nosec

__all__: Tuple[str, ...] = ("schema", "setup_app_tracing")
return setup_tracing(
app,
service_name="simcore_service_webserver",
host=host,
port=port,
jaeger_base_url=str(settings.TRACING_ZIPKIN_ENDPOINT),
)

0 comments on commit ef687d5

Please sign in to comment.