File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/service-library/src/servicelib/fastapi Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1515from opentelemetry .sdk .resources import Resource
1616from opentelemetry .sdk .trace import SpanProcessor , TracerProvider
1717from opentelemetry .sdk .trace .export import BatchSpanProcessor
18+ from opentelemetry .sdk .trace .sampling import ParentBased , TraceIdRatioBased
1819from settings_library .tracing import TracingSettings
1920from starlette .middleware .base import BaseHTTPMiddleware
2021from yarl import URL
@@ -87,7 +88,11 @@ def _startup(tracing_settings: TracingSettings, service_name: str) -> None:
8788 return
8889 # Set up the tracer provider
8990 resource = Resource (attributes = {"service.name" : service_name })
90- trace .set_tracer_provider (TracerProvider (resource = resource ))
91+ sampler = ParentBased (
92+ root = TraceIdRatioBased (tracing_settings .TRACING_SAMPLING_PROBABILITY )
93+ )
94+ trace_provider = TracerProvider (resource = resource , sampler = sampler )
95+ trace .set_tracer_provider (trace_provider )
9196 global_tracer_provider = trace .get_tracer_provider ()
9297 assert isinstance (global_tracer_provider , TracerProvider ) # nosec
9398
You can’t perform that action at this time.
0 commit comments