-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 27 additions & 8 deletions
35
services/web/server/src/simcore_service_webserver/tracing.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
) |