|
1 | 1 | """
|
2 | 2 | Core stubs that don't have circular import dependencies.
|
3 |
| -These are the basic stubs needed early in the import process. |
| 3 | +These are the wrapt-related stubs needed early in the import process. |
4 | 4 | """
|
5 | 5 |
|
6 |
| -from typing import Dict |
7 |
| -from typing import List |
8 |
| - |
9 | 6 | from ._instrumentation_enabled import _INSTRUMENTATION_ENABLED
|
10 | 7 |
|
11 | 8 |
|
12 | 9 | if _INSTRUMENTATION_ENABLED:
|
13 |
| - import logging |
14 |
| - |
15 | 10 | import wrapt
|
16 | 11 | from wrapt.importer import when_imported
|
17 | 12 | else:
|
18 | 13 | # Provide minimal stubs when instrumentation is disabled
|
19 | 14 |
|
20 |
| - class logging: # type: ignore[no-redef] |
21 |
| - DEBUG = 10 |
22 |
| - INFO = 20 |
23 |
| - WARNING = 30 |
24 |
| - ERROR = 40 |
25 |
| - CRITICAL = 50 |
26 |
| - |
27 |
| - class Logger: |
28 |
| - def debug(self, *args, **kwargs): |
29 |
| - pass |
30 |
| - |
31 |
| - def info(self, *args, **kwargs): |
32 |
| - pass |
33 |
| - |
34 |
| - def warning(self, *args, **kwargs): |
35 |
| - pass |
36 |
| - |
37 |
| - def error(self, *args, **kwargs): |
38 |
| - pass |
39 |
| - |
40 |
| - def critical(self, *args, **kwargs): |
41 |
| - pass |
42 |
| - |
43 |
| - def setLevel(self, level): |
44 |
| - pass |
45 |
| - |
46 |
| - def addHandler(self, handler): |
47 |
| - pass |
48 |
| - |
49 |
| - def addFilter(self, _filter): |
50 |
| - pass |
51 |
| - |
52 |
| - def isEnabledFor(self, level): |
53 |
| - return False |
54 |
| - |
55 |
| - handlers: List = [] |
56 |
| - |
57 |
| - class LogRecord: |
58 |
| - def __init__(self, *args, **kwargs): |
59 |
| - self.name = "" |
60 |
| - self.msg = "" |
61 |
| - self.pathname = "" |
62 |
| - self.lineno = 0 |
63 |
| - self.levelno = 0 |
64 |
| - |
65 |
| - @staticmethod |
66 |
| - def getLogger(name): |
67 |
| - return logging.Logger() |
68 |
| - |
69 |
| - class StreamHandler: |
70 |
| - def __init__(self): |
71 |
| - pass |
72 |
| - |
73 |
| - def setLevel(self, level): |
74 |
| - pass |
75 |
| - |
76 |
| - def setFormatter(self, formatter): |
77 |
| - pass |
78 |
| - |
79 |
| - def set_name(self, name): |
80 |
| - pass |
81 |
| - |
82 |
| - class Formatter: |
83 |
| - def __init__(self, fmt): |
84 |
| - pass |
85 |
| - |
86 |
| - @staticmethod |
87 |
| - def warning(msg, *args): |
88 |
| - pass |
89 |
| - |
90 | 15 | class wrapt: # type: ignore[no-redef]
|
91 | 16 | class ObjectProxy:
|
92 | 17 | def __init__(self, wrapped):
|
@@ -114,78 +39,5 @@ def when_imported(x):
|
114 | 39 | return lambda y: None
|
115 | 40 |
|
116 | 41 |
|
117 |
| -# Configuration stubs - comprehensive version that implements ConfigProtocol |
118 |
| -class _NullConfig: |
119 |
| - # Implement all the Protocol attributes with sensible defaults |
120 |
| - _data_streams_enabled: bool = False |
121 |
| - _from_endpoint: Dict = {} |
122 |
| - _remote_config_enabled: bool = False |
123 |
| - _sca_enabled: bool = False |
124 |
| - _trace_safe_instrumentation_enabled: bool = False |
125 |
| - _modules_to_report = None |
126 |
| - _report_handled_errors = None |
127 |
| - _configured_modules = None |
128 |
| - _instrument_user_code: bool = False |
129 |
| - _instrument_third_party_code: bool = False |
130 |
| - _instrument_all: bool = False |
131 |
| - _stacktrace_resolver = None |
132 |
| - _enabled: bool = False |
133 |
| - _http_tag_query_string: bool = False |
134 |
| - _health_metrics_enabled: bool = False |
135 |
| - _trace_writer_interval_seconds: float = 1.0 |
136 |
| - _trace_writer_connection_reuse: bool = False |
137 |
| - _trace_writer_log_err_payload: bool = False |
138 |
| - _trace_api: str = "v0.5" |
139 |
| - _trace_writer_buffer_size: int = 1000 |
140 |
| - _trace_writer_payload_size: int = 1000 |
141 |
| - _http = None |
142 |
| - _logs_injection: bool = False |
143 |
| - _dd_site = None |
144 |
| - _dd_api_key = None |
145 |
| - _llmobs_ml_app = None |
146 |
| - _llmobs_instrumented_proxy_urls = None |
147 |
| - _llmobs_agentless_enabled = False |
148 |
| - _trace_compute_stats: bool = False |
149 |
| - _tracing_enabled: bool = False |
150 |
| - |
151 |
| - # Common properties |
152 |
| - service = None |
153 |
| - env = None |
154 |
| - version = None |
155 |
| - tags: Dict = {} |
156 |
| - service_mapping: Dict = {} |
157 |
| - |
158 |
| - def __getattr__(self, name): |
159 |
| - # Handle dynamic attributes and integration configs |
160 |
| - if name.endswith("_enabled"): |
161 |
| - return False |
162 |
| - if name.endswith("_timeout"): |
163 |
| - return 0 |
164 |
| - if name.startswith("_") and "interval" in name: |
165 |
| - return 1.0 |
166 |
| - if name.startswith("_") and ("size" in name or "limit" in name): |
167 |
| - return 1000 |
168 |
| - return False |
169 |
| - |
170 |
| - def _add_extra_service(self, service_name: str) -> None: |
171 |
| - pass # No-op for null config |
172 |
| - |
173 |
| - def _get_extra_services(self): |
174 |
| - return set() |
175 |
| - |
176 |
| - |
177 |
| -# Function to get the appropriate config instance based on instrumentation status |
178 |
| -def get_config(): |
179 |
| - """Get the appropriate config instance - real Config when instrumentation enabled, _NullConfig otherwise.""" |
180 |
| - if _INSTRUMENTATION_ENABLED: |
181 |
| - # Import the real config when instrumentation is enabled (lazy import to avoid circular imports) |
182 |
| - from ddtrace.settings._config import config |
183 |
| - |
184 |
| - return config |
185 |
| - else: |
186 |
| - # Use the null config when instrumentation is disabled |
187 |
| - return _NullConfig() |
188 |
| - |
189 |
| - |
190 | 42 | # Export the core stubs
|
191 |
| -__all__ = ["logging", "wrapt", "_NullConfig", "when_imported", "get_config"] |
| 43 | +__all__ = ["wrapt", "when_imported"] |
0 commit comments