def init_tracer(config): """Set the whitelists and initialise the JaegerClient tracer Args: config (HomeserverConfig): The config used by the homeserver """ global opentracing if not config.opentracer_enabled: # We don't have a tracer opentracing = None return if not opentracing or not JaegerConfig: raise ConfigError( "The server has been configured to use opentracing but opentracing is not " "installed.") # Include the worker name name = config.worker_name if config.worker_name else "master" # Pull out the jaeger config if it was given. Otherwise set it to something sensible. # See https://github.com/jaegertracing/jaeger-client-python/blob/master/jaeger_client/config.py set_homeserver_whitelist(config.opentracer_whitelist) JaegerConfig( config=config.jaeger_config, service_name="{} {}".format(config.server_name, name), scope_manager=LogContextScopeManager(config), ).initialize_tracer()
def init_tracer(hs: "HomeServer"): """Set the whitelists and initialise the JaegerClient tracer""" global opentracing if not hs.config.opentracer_enabled: # We don't have a tracer opentracing = None return if not opentracing or not JaegerConfig: raise ConfigError( "The server has been configured to use opentracing but opentracing is not " "installed.") # Pull out the jaeger config if it was given. Otherwise set it to something sensible. # See https://github.com/jaegertracing/jaeger-client-python/blob/master/jaeger_client/config.py set_homeserver_whitelist(hs.config.opentracer_whitelist) from jaeger_client.metrics.prometheus import PrometheusMetricsFactory config = JaegerConfig( config=hs.config.jaeger_config, service_name=f"{hs.config.server_name} {hs.get_instance_name()}", scope_manager=LogContextScopeManager(hs.config), metrics_factory=PrometheusMetricsFactory(), ) # If we have the rust jaeger reporter available let's use that. if RustReporter: logger.info("Using rust_python_jaeger_reporter library") tracer = config.create_tracer(RustReporter(), config.sampler) opentracing.set_global_tracer(tracer) else: config.initialize_tracer()
def new_tracer(service_name: str): """Create a new tracer.""" new_config = JaegerConfig( config={ # usually read from some yaml config 'sampler': {'type': 'const', 'param': 1}, 'logging': True, 'reporter_batch_size': 1, 'trace_id_header': 'registries-trace-id', }, service_name=service_name, ) return new_config.new_tracer()
def init_jaeger_tracer(service_name): """Create a Jaeger/OpenTracing configuration.""" config = JaegerConfig( config={ "sampler": {"type": "const", "param": 1}, "logging": True, "local_agent": {"reporting_host": Configuration.JAEGER_HOST}, }, service_name=service_name, validate=True, metrics_factory=PrometheusMetricsFactory(namespace=service_name), ) return config.initialize_tracer()
def init_tracer(service): """ initialize tracer""" config = JaegerConfig( config={ # usually read from some yaml config 'sampler': { 'type': 'const', 'param': 1, }, 'logging': True, 'reporter_batch_size': 1, }, service_name=service, ) # this call also sets opentracing.tracer return config.initialize_tracer()
def initialize_tracer(): install_all_patches() jaeger_config = JaegerConfig( config={ 'sampler': { 'type': 'const', 'param': 1, }, 'logging': True, 'local_agent': { 'reporting_host': ConfigEnv.JAEGER_HOST, 'reporting_port': ConfigEnv.JAEGER_PORT, } }, service_name=ConfigEnv.JAEGER_SERVICE_NAME, ) return jaeger_config.initialize_tracer()
def init_tracer(config): """Set the whitelists and initialise the JaegerClient tracer Args: config (HomeserverConfig): The config used by the homeserver """ global opentracing if not config.opentracer_enabled: # We don't have a tracer opentracing = None return if not opentracing or not JaegerConfig: raise ConfigError( "The server has been configured to use opentracing but opentracing is not " "installed.") # Include the worker name name = config.worker_name if config.worker_name else "master" set_homeserver_whitelist(config.opentracer_whitelist) jaeger_config = JaegerConfig( config={ "sampler": { "type": "const", "param": 1 }, "logging": True }, service_name="{} {}".format(config.server_name, name), scope_manager=LogContextScopeManager(config), ) jaeger_config.initialize_tracer() # Set up tags to be opentracing's tags global tags tags = opentracing.tags