def test_deprecation(self): # ensure `deprecation` properly raise a DeprecationWarning with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") deprecation(name="fn", message="message", version="1.0.0") self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) self.assertIn("message", str(w[-1].message))
def __init__( self, url=None, # type: Optional[str] dogstatsd_url=None, # type: Optional[str] ): # type: (...) -> None """ Create a new ``Tracer`` instance. A global tracer is already initialized for common usage, so there is no need to initialize your own ``Tracer``. :param url: The Datadog agent URL. :param dogstatsd_url: The DogStatsD URL. """ self.log = log self._filters = [] # type: List[TraceFilter] # globally set tags self.tags = config.tags.copy() # a buffer for service info so we don't perpetually send the same things self._services = set() # type: Set[str] # Runtime id used for associating data collected during runtime to # traces self._pid = getpid() self.enabled = asbool(get_env("trace", "enabled", default=True)) self.context_provider = DefaultContextProvider() self.sampler = DatadogSampler() # type: BaseSampler self.priority_sampler = RateByServiceSampler( ) # type: Optional[BasePrioritySampler] self._dogstatsd_url = agent.get_stats_url( ) if dogstatsd_url is None else dogstatsd_url if self._use_log_writer() and url is None: writer = LogWriter() # type: TraceWriter else: url = url or agent.get_trace_url() agent.verify_url(url) writer = AgentWriter( agent_url=url, sampler=self.sampler, priority_sampler=self.priority_sampler, dogstatsd=get_dogstatsd_client(self._dogstatsd_url), report_metrics=config.health_metrics_enabled, sync_mode=self._use_sync_mode(), ) self.writer = writer # type: TraceWriter # DD_TRACER_... should be deprecated after version 1.0.0 is released pfe_default_value = False pfms_default_value = 500 if "DD_TRACER_PARTIAL_FLUSH_ENABLED" in os.environ or "DD_TRACER_PARTIAL_FLUSH_MIN_SPANS" in os.environ: deprecation("DD_TRACER_... use DD_TRACE_... instead", version="1.0.0") pfe_default_value = asbool( get_env("tracer", "partial_flush_enabled", default=pfe_default_value)) pfms_default_value = int( get_env("tracer", "partial_flush_min_spans", default=pfms_default_value) # type: ignore[arg-type] ) self._partial_flush_enabled = asbool( get_env("trace", "partial_flush_enabled", default=pfe_default_value)) self._partial_flush_min_spans = int( get_env("trace", "partial_flush_min_spans", default=pfms_default_value) # type: ignore[arg-type] ) self._initialize_span_processors() self._hooks = _hooks.Hooks() atexit.register(self._atexit) forksafe.register(self._child_after_fork) self._shutdown_lock = RLock() self._new_process = False
from ddtrace.contrib.trace_utils import NORMALIZE_PATTERN from ddtrace.contrib.trace_utils import REQUEST from ddtrace.contrib.trace_utils import RESPONSE from ddtrace.contrib.trace_utils import _normalize_tag_name from ddtrace.contrib.trace_utils import _normalized_header_name from ddtrace.contrib.trace_utils import _store_headers from ddtrace.contrib.trace_utils import _store_request_headers as store_request_headers from ddtrace.contrib.trace_utils import _store_response_headers as store_response_headers from ddtrace.internal.utils.deprecation import deprecation __all__ = ( "store_request_headers", "store_response_headers", "NORMALIZE_PATTERN", "REQUEST", "RESPONSE", "_store_headers", "_normalized_header_name", "_normalize_tag_name", ) deprecation( name="ddtrace.http.headers", message="The http.headers module has been merged into ddtrace.contrib.trace_utils", version="1.0.0", )
""" Standard system tags """ from ddtrace.constants import PID from ddtrace.internal.utils.deprecation import deprecation deprecation( name="ddtrace.ext.system", message="Use `ddtrace.constants` module instead", version="1.0.0", ) __all__ = ["PID"]
""" import traceback from ddtrace.constants import ERROR_MSG from ddtrace.constants import ERROR_STACK from ddtrace.constants import ERROR_TYPE from ddtrace.internal.utils.deprecation import deprecated from ddtrace.internal.utils.deprecation import deprecation __all__ = [ERROR_MSG, ERROR_TYPE, ERROR_STACK] deprecation( name="ddtrace.ext.errors", message= ("Use `ddtrace.constants` module instead. " "Shorthand error constants will be removed. Use ERROR_MSG, ERROR_TYPE, and ERROR_STACK instead." ), version="1.0.0", ) # shorthand for ERROR constants to be removed in v1.0-----^ MSG = ERROR_MSG TYPE = ERROR_TYPE STACK = ERROR_STACK @deprecated("This method and module will be removed altogether", "1.0.0") def get_traceback(tb=None, error=None): t = None if error: t = type(error)
"get_connection_response", "getrandbits", "httplib", "is_integer", "iscoroutinefunction", "iteritems", "main_thread", "make_async_decorator", "monotonic", "monotonic_ns", "msgpack_type", "numeric_types", "parse", "pattern_type", "process_time_ns", "reload_module", "reraise", "string_type", "stringify", "time_ns", "to_unicode", "urlencode", ] deprecation( name="ddtrace.compat", message= "The compat module has been moved to ddtrace.internal and will no longer be part of the public API.", version="1.0.0", )