Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/service-library/requirements/_base.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ repro-zipfile
tenacity
toolz
tqdm
yarl
1 change: 1 addition & 0 deletions packages/service-library/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ wrapt==1.16.0
# opentelemetry-instrumentation-redis
yarl==1.12.1
# via
# -r requirements/_base.in
# aio-pika
# aiohttp
# aiormq
Expand Down
8 changes: 4 additions & 4 deletions packages/service-library/src/servicelib/aiohttp/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from servicelib.logging_utils import log_context
from settings_library.tracing import TracingSettings
from yarl import URL

_logger = logging.getLogger(__name__)
try:
Expand Down Expand Up @@ -54,7 +55,7 @@ def setup_tracing(
"""
_ = app
opentelemetry_collector_endpoint = (
tracing_settings.TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT
f"{tracing_settings.TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT}"
)
opentelemetry_collector_port = tracing_settings.TRACING_OPENTELEMETRY_COLLECTOR_PORT
if not opentelemetry_collector_endpoint and not opentelemetry_collector_port:
Expand All @@ -72,9 +73,8 @@ def setup_tracing(
resource = Resource(attributes={"service.name": service_name})
trace.set_tracer_provider(TracerProvider(resource=resource))
tracer_provider: trace.TracerProvider = trace.get_tracer_provider()
tracing_destination: str = (
f"{opentelemetry_collector_endpoint}:{opentelemetry_collector_port}/v1/traces"
)

tracing_destination: str = f"{URL(opentelemetry_collector_endpoint).with_port(opentelemetry_collector_port).with_path('/v1/traces')}"

_logger.info(
"Trying to connect service %s to tracing collector at %s.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from servicelib.logging_utils import log_context
from settings_library.tracing import TracingSettings
from yarl import URL

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -75,7 +76,13 @@ def setup_tracing(
trace.set_tracer_provider(TracerProvider(resource=resource))
global_tracer_provider = trace.get_tracer_provider()
assert isinstance(global_tracer_provider, TracerProvider) # nosec
tracing_destination: str = f"{tracing_settings.TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT}:{tracing_settings.TRACING_OPENTELEMETRY_COLLECTOR_PORT}/v1/traces"

opentelemetry_collector_endpoint: str = (
f"{tracing_settings.TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT}"
)

tracing_destination: str = f"{URL(opentelemetry_collector_endpoint).with_port(tracing_settings.TRACING_OPENTELEMETRY_COLLECTOR_PORT).with_path('/v1/traces')}"

_logger.info(
"Trying to connect service %s to opentelemetry tracing collector at %s.",
service_name,
Expand Down
Loading