Skip to content

Commit 8699445

Browse files
committed
wip
1 parent c8b8798 commit 8699445

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

packages/service-library/src/servicelib/aiohttp/tracing.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,31 @@
1515
from opentelemetry.instrumentation.aiohttp_server import (
1616
middleware as aiohttp_server_opentelemetry_middleware, # pylint:disable=no-name-in-module
1717
)
18-
from opentelemetry.instrumentation.aiopg import ( # pylint:disable=no-name-in-module
19-
AiopgInstrumentor,
20-
)
2118
from opentelemetry.instrumentation.requests import RequestsInstrumentor
2219
from opentelemetry.sdk.resources import Resource
2320
from opentelemetry.sdk.trace import TracerProvider
2421
from opentelemetry.sdk.trace.export import BatchSpanProcessor
2522
from settings_library.tracing import TracingSettings
2623

2724
_logger = logging.getLogger(__name__)
25+
try:
26+
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
27+
28+
HAS_BOTOCORE = True
29+
except ImportError:
30+
HAS_BOTOCORE = False
31+
try:
32+
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
33+
34+
HAS_AIOPG = True
35+
except ImportError:
36+
HAS_AIOPG = False
2837

2938

3039
def setup_tracing(
3140
app: web.Application,
3241
tracing_settings: TracingSettings,
3342
service_name: str,
34-
instrument_aiopg: bool = False, # noqa: FBT001, FBT002
3543
) -> None:
3644
"""
3745
Sets up this service for a distributed tracing system (opentelemetry)
@@ -91,6 +99,10 @@ def setup_tracing(
9199

92100
# Instrument aiohttp client
93101
AioHttpClientInstrumentor().instrument()
94-
if instrument_aiopg:
102+
if HAS_AIOPG:
95103
AiopgInstrumentor().instrument()
104+
_logger.info("Attempting to add aiopg opentelemetry autoinstrumentation...")
105+
if HAS_BOTOCORE:
106+
BotocoreInstrumentor().instrument()
107+
_logger.info("Attempting to add botocore opentelemetry autoinstrumentation...")
96108
RequestsInstrumentor().instrument()

services/storage/requirements/_base.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ aiofiles # i/o
1919
aiohttp # server
2020
aiohttp-swagger[performance] # server
2121
aiopg[sa] # db
22+
opentelemetry-instrumentation-botocore
2223
packaging
2324
tenacity
2425
typer

services/storage/src/simcore_service_storage/application.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def create(settings: Settings) -> web.Application:
5656
app,
5757
tracing_settings=tracing_settings,
5858
service_name=APP_NAME,
59-
instrument_aiopg=True,
6059
)
6160

6261
setup_db(app)

services/web/server/src/simcore_service_webserver/tracing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ def setup_app_tracing(app: web.Application):
2626
setup_tracing(
2727
app,
2828
tracing_settings=tracing_settings,
29-
instrument_aiopg=True,
3029
service_name=APP_NAME,
3130
)

0 commit comments

Comments
 (0)