File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,4 @@ repro-zipfile
3030tenacity
3131toolz
3232tqdm
33+ yarl
Original file line number Diff line number Diff line change @@ -274,6 +274,7 @@ wrapt==1.16.0
274274 # opentelemetry-instrumentation-redis
275275yarl==1.12.1
276276 # via
277+ # -r requirements/_base.in
277278 # aio-pika
278279 # aiohttp
279280 # aiormq
Original file line number Diff line number Diff line change 2020from opentelemetry .sdk .trace .export import BatchSpanProcessor
2121from servicelib .logging_utils import log_context
2222from settings_library .tracing import TracingSettings
23+ from yarl import URL
2324
2425_logger = logging .getLogger (__name__ )
2526try :
@@ -54,7 +55,7 @@ def setup_tracing(
5455 """
5556 _ = app
5657 opentelemetry_collector_endpoint = (
57- tracing_settings .TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT
58+ f" { tracing_settings .TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT } "
5859 )
5960 opentelemetry_collector_port = tracing_settings .TRACING_OPENTELEMETRY_COLLECTOR_PORT
6061 if not opentelemetry_collector_endpoint and not opentelemetry_collector_port :
@@ -72,9 +73,9 @@ def setup_tracing(
7273 resource = Resource (attributes = {"service.name" : service_name })
7374 trace .set_tracer_provider (TracerProvider (resource = resource ))
7475 tracer_provider : trace .TracerProvider = trace .get_tracer_provider ()
75- tracing_destination : str = (
76- f" { opentelemetry_collector_endpoint } : { opentelemetry_collector_port } /v1/traces"
77- )
76+
77+ opentelemetry_collector_path = " /v1/traces"
78+ tracing_destination : str = f" { URL ( opentelemetry_collector_endpoint ). with_port ( opentelemetry_collector_port ). with_path ( opentelemetry_collector_path ) } "
7879
7980 _logger .info (
8081 "Trying to connect service %s to tracing collector at %s." ,
Original file line number Diff line number Diff line change 1717from opentelemetry .sdk .trace .export import BatchSpanProcessor
1818from servicelib .logging_utils import log_context
1919from settings_library .tracing import TracingSettings
20+ from yarl import URL
2021
2122_logger = logging .getLogger (__name__ )
2223
@@ -75,7 +76,14 @@ def setup_tracing(
7576 trace .set_tracer_provider (TracerProvider (resource = resource ))
7677 global_tracer_provider = trace .get_tracer_provider ()
7778 assert isinstance (global_tracer_provider , TracerProvider ) # nosec
78- tracing_destination : str = f"{ tracing_settings .TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT } :{ tracing_settings .TRACING_OPENTELEMETRY_COLLECTOR_PORT } /v1/traces"
79+
80+ opentelemetry_collector_endpoint : str = (
81+ f"{ tracing_settings .TRACING_OPENTELEMETRY_COLLECTOR_ENDPOINT } "
82+ )
83+
84+ opentelemetry_collector_path = "/v1/traces"
85+ tracing_destination : str = f"{ URL (opentelemetry_collector_endpoint ).with_port (tracing_settings .TRACING_OPENTELEMETRY_COLLECTOR_PORT ).with_path (opentelemetry_collector_path )} "
86+
7987 _logger .info (
8088 "Trying to connect service %s to opentelemetry tracing collector at %s." ,
8189 service_name ,
You can’t perform that action at this time.
0 commit comments