tigrcorn-observability 0.3.16.dev5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tigrcorn_observability/__init__.py +1 -0
- tigrcorn_observability/events.py +35 -0
- tigrcorn_observability/logging.py +341 -0
- tigrcorn_observability/metrics.py +360 -0
- tigrcorn_observability/py.typed +1 -0
- tigrcorn_observability/tracing.py +180 -0
- tigrcorn_observability-0.3.16.dev5.dist-info/METADATA +236 -0
- tigrcorn_observability-0.3.16.dev5.dist-info/RECORD +11 -0
- tigrcorn_observability-0.3.16.dev5.dist-info/WHEEL +5 -0
- tigrcorn_observability-0.3.16.dev5.dist-info/licenses/LICENSE +163 -0
- tigrcorn_observability-0.3.16.dev5.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Logging, metrics, tracing helpers."""
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(slots=True)
|
|
7
|
+
class Event:
|
|
8
|
+
name: str
|
|
9
|
+
attrs: dict[str, object]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
DOS_WARNING_EVENT = "tigrcorn.dos.warning"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def dos_warning(
|
|
16
|
+
*,
|
|
17
|
+
surface: str,
|
|
18
|
+
reason: str,
|
|
19
|
+
action: str,
|
|
20
|
+
resource: str | None = None,
|
|
21
|
+
limit: int | float | None = None,
|
|
22
|
+
observed: int | float | None = None,
|
|
23
|
+
) -> Event:
|
|
24
|
+
attrs: dict[str, object] = {
|
|
25
|
+
"surface": surface,
|
|
26
|
+
"reason": reason,
|
|
27
|
+
"action": action,
|
|
28
|
+
}
|
|
29
|
+
if resource is not None:
|
|
30
|
+
attrs["resource"] = resource
|
|
31
|
+
if limit is not None:
|
|
32
|
+
attrs["limit"] = limit
|
|
33
|
+
if observed is not None:
|
|
34
|
+
attrs["observed"] = observed
|
|
35
|
+
return Event(DOS_WARNING_EVENT, attrs)
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
import logging
|
|
6
|
+
import logging.config
|
|
7
|
+
import socket
|
|
8
|
+
from logging import Logger
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any, Mapping
|
|
11
|
+
|
|
12
|
+
from tigrcorn_config.files import ConfigFileError, load_config_source
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class LoggingConfigError(RuntimeError):
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
_ALLOWED_PROFILE_KEYS = {
|
|
20
|
+
'level',
|
|
21
|
+
'structured',
|
|
22
|
+
'access_log',
|
|
23
|
+
'access_log_file',
|
|
24
|
+
'access_log_format',
|
|
25
|
+
'error_log_file',
|
|
26
|
+
'format',
|
|
27
|
+
'stream',
|
|
28
|
+
'syslog_app_name',
|
|
29
|
+
'syslog_enterprise_id',
|
|
30
|
+
'syslog_msgid',
|
|
31
|
+
'syslog_procid',
|
|
32
|
+
'use_colors',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass(slots=True)
|
|
37
|
+
class ResolvedLoggingConfig:
|
|
38
|
+
level: str = 'info'
|
|
39
|
+
structured: bool = False
|
|
40
|
+
access_log: bool = True
|
|
41
|
+
access_log_file: str | None = None
|
|
42
|
+
access_log_format: str | None = None
|
|
43
|
+
error_log_file: str | None = None
|
|
44
|
+
format: str = 'default'
|
|
45
|
+
stream: bool = True
|
|
46
|
+
syslog_app_name: str = 'tigrcorn'
|
|
47
|
+
syslog_enterprise_id: int = 32473
|
|
48
|
+
syslog_msgid: str = '-'
|
|
49
|
+
syslog_procid: str = '-'
|
|
50
|
+
use_colors: bool | None = None
|
|
51
|
+
log_config: str | None = None
|
|
52
|
+
dict_config: dict[str, Any] | None = None
|
|
53
|
+
explicit_fields: tuple[str, ...] = ()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class JSONFormatter(logging.Formatter):
|
|
57
|
+
def format(self, record: logging.LogRecord) -> str:
|
|
58
|
+
payload: dict[str, Any] = {
|
|
59
|
+
'timestamp': self.formatTime(record, self.datefmt),
|
|
60
|
+
'level': record.levelname,
|
|
61
|
+
'logger': record.name,
|
|
62
|
+
'message': record.getMessage(),
|
|
63
|
+
}
|
|
64
|
+
for key in ('event', 'peer', 'method', 'path', 'proto', 'status', 'result', 'trace_id', 'span_id'):
|
|
65
|
+
value = getattr(record, key, None)
|
|
66
|
+
if value is not None:
|
|
67
|
+
payload[key] = value
|
|
68
|
+
return json.dumps(payload, sort_keys=True)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class ColorFormatter(logging.Formatter):
|
|
72
|
+
_COLORS = {
|
|
73
|
+
logging.DEBUG: '\x1b[36m',
|
|
74
|
+
logging.INFO: '\x1b[32m',
|
|
75
|
+
logging.WARNING: '\x1b[33m',
|
|
76
|
+
logging.ERROR: '\x1b[31m',
|
|
77
|
+
logging.CRITICAL: '\x1b[35m',
|
|
78
|
+
}
|
|
79
|
+
_RESET = '\x1b[0m'
|
|
80
|
+
|
|
81
|
+
def format(self, record: logging.LogRecord) -> str:
|
|
82
|
+
message = super().format(record)
|
|
83
|
+
color = self._COLORS.get(record.levelno)
|
|
84
|
+
if not color:
|
|
85
|
+
return message
|
|
86
|
+
return f'{color}{message}{self._RESET}'
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class RFC5424Formatter(logging.Formatter):
|
|
90
|
+
_SEVERITY = {
|
|
91
|
+
logging.DEBUG: 7,
|
|
92
|
+
logging.INFO: 6,
|
|
93
|
+
logging.WARNING: 4,
|
|
94
|
+
logging.ERROR: 3,
|
|
95
|
+
logging.CRITICAL: 2,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
def __init__(
|
|
99
|
+
self,
|
|
100
|
+
*,
|
|
101
|
+
app_name: str = 'tigrcorn',
|
|
102
|
+
procid: str = '-',
|
|
103
|
+
msgid: str = '-',
|
|
104
|
+
enterprise_id: int = 32473,
|
|
105
|
+
) -> None:
|
|
106
|
+
super().__init__()
|
|
107
|
+
self.app_name = app_name or '-'
|
|
108
|
+
self.procid = procid or '-'
|
|
109
|
+
self.msgid = msgid or '-'
|
|
110
|
+
self.enterprise_id = enterprise_id
|
|
111
|
+
self.hostname = socket.gethostname() or '-'
|
|
112
|
+
|
|
113
|
+
def format(self, record: logging.LogRecord) -> str:
|
|
114
|
+
timestamp = self.formatTime(record, '%Y-%m-%dT%H:%M:%S%z')
|
|
115
|
+
if timestamp.endswith('+0000'):
|
|
116
|
+
timestamp = timestamp[:-5] + 'Z'
|
|
117
|
+
priority = 8 + self._SEVERITY.get(record.levelno, 6)
|
|
118
|
+
structured_data = self._structured_data(record)
|
|
119
|
+
return (
|
|
120
|
+
f'<{priority}>1 {timestamp} {self._nil_safe(self.hostname)} '
|
|
121
|
+
f'{self._nil_safe(self.app_name)} {self._nil_safe(self.procid)} '
|
|
122
|
+
f'{self._nil_safe(self.msgid)} {structured_data} {record.getMessage()}'
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def _structured_data(self, record: logging.LogRecord) -> str:
|
|
126
|
+
pairs: list[str] = []
|
|
127
|
+
for key in ('event', 'peer', 'method', 'path', 'proto', 'status', 'result', 'trace_id', 'span_id'):
|
|
128
|
+
value = getattr(record, key, None)
|
|
129
|
+
if value is not None:
|
|
130
|
+
pairs.append(f'{key}="{self._escape_param(str(value))}"')
|
|
131
|
+
if not pairs:
|
|
132
|
+
return '-'
|
|
133
|
+
return f'[tigrcorn@{self.enterprise_id} {" ".join(pairs)}]'
|
|
134
|
+
|
|
135
|
+
@staticmethod
|
|
136
|
+
def _escape_param(value: str) -> str:
|
|
137
|
+
return value.replace('\\', '\\\\').replace('"', '\\"').replace(']', '\\]')
|
|
138
|
+
|
|
139
|
+
@staticmethod
|
|
140
|
+
def _nil_safe(value: str) -> str:
|
|
141
|
+
cleaned = str(value).strip()
|
|
142
|
+
return cleaned if cleaned else '-'
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class CloseAfterEmitFileHandler(logging.Handler):
|
|
146
|
+
terminator = '\n'
|
|
147
|
+
|
|
148
|
+
def __init__(self, path: str) -> None:
|
|
149
|
+
super().__init__()
|
|
150
|
+
self.baseFilename = str(Path(path))
|
|
151
|
+
Path(path).parent.mkdir(parents=True, exist_ok=True)
|
|
152
|
+
|
|
153
|
+
def emit(self, record: logging.LogRecord) -> None:
|
|
154
|
+
try:
|
|
155
|
+
message = self.format(record)
|
|
156
|
+
with open(self.baseFilename, 'a', encoding='utf-8') as stream:
|
|
157
|
+
stream.write(message + self.terminator)
|
|
158
|
+
except Exception:
|
|
159
|
+
self.handleError(record)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class AccessLogger:
|
|
163
|
+
def __init__(self, logger: Logger, *, enabled: bool = True, fmt: str | None = None) -> None:
|
|
164
|
+
self.logger = logger
|
|
165
|
+
self.enabled = enabled
|
|
166
|
+
self.fmt = fmt or '{peer} "{method} {path} {proto}" {status}'
|
|
167
|
+
|
|
168
|
+
def _peer(self, client: tuple[str, int] | None) -> str:
|
|
169
|
+
return f"{client[0]}:{client[1]}" if client else '-'
|
|
170
|
+
|
|
171
|
+
def log_http(self, client: tuple[str, int] | None, method: str, path: str, status: int, proto: str) -> None:
|
|
172
|
+
if not self.enabled:
|
|
173
|
+
return
|
|
174
|
+
peer = self._peer(client)
|
|
175
|
+
message = self.fmt.format(peer=peer, method=method, path=path, status=status, proto=proto)
|
|
176
|
+
self.logger.info(message, extra={'event': 'access.http', 'peer': peer, 'method': method, 'path': path, 'status': status, 'proto': proto})
|
|
177
|
+
|
|
178
|
+
def log_ws(self, client: tuple[str, int] | None, path: str, result: str) -> None:
|
|
179
|
+
if not self.enabled:
|
|
180
|
+
return
|
|
181
|
+
peer = self._peer(client)
|
|
182
|
+
message = f'{peer} "WEBSOCKET {path}" {result}'
|
|
183
|
+
self.logger.info(message, extra={'event': 'access.websocket', 'peer': peer, 'path': path, 'result': result})
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _coerce_level(level: str) -> int:
|
|
187
|
+
return getattr(logging, str(level).upper(), logging.INFO)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _file_handler(path: str, formatter: logging.Formatter) -> logging.Handler:
|
|
191
|
+
handler = CloseAfterEmitFileHandler(path)
|
|
192
|
+
handler.setFormatter(formatter)
|
|
193
|
+
return handler
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def _coerce_profile_bool(name: str, value: Any) -> bool:
|
|
197
|
+
if isinstance(value, bool):
|
|
198
|
+
return value
|
|
199
|
+
raise LoggingConfigError(f'logging profile {name!r} must be a boolean')
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def load_logging_profile(path: str | Path) -> dict[str, Any]:
|
|
203
|
+
try:
|
|
204
|
+
payload = load_config_source(path)
|
|
205
|
+
except ConfigFileError as exc:
|
|
206
|
+
raise LoggingConfigError(str(exc)) from exc
|
|
207
|
+
if 'logging' in payload and isinstance(payload['logging'], Mapping):
|
|
208
|
+
payload = dict(payload['logging'])
|
|
209
|
+
if not isinstance(payload, Mapping):
|
|
210
|
+
raise LoggingConfigError('log_config must resolve to a mapping or a top-level logging mapping')
|
|
211
|
+
if 'version' in payload:
|
|
212
|
+
return {'dict_config': dict(payload)}
|
|
213
|
+
unknown = sorted(set(payload) - _ALLOWED_PROFILE_KEYS)
|
|
214
|
+
if unknown:
|
|
215
|
+
raise LoggingConfigError(f'log_config contains unsupported keys: {unknown}')
|
|
216
|
+
result: dict[str, Any] = {}
|
|
217
|
+
for key, value in payload.items():
|
|
218
|
+
if key in {'structured', 'access_log', 'stream', 'use_colors'}:
|
|
219
|
+
result[key] = _coerce_profile_bool(key, value)
|
|
220
|
+
elif key in {
|
|
221
|
+
'level',
|
|
222
|
+
'access_log_file',
|
|
223
|
+
'access_log_format',
|
|
224
|
+
'error_log_file',
|
|
225
|
+
'format',
|
|
226
|
+
'syslog_app_name',
|
|
227
|
+
'syslog_procid',
|
|
228
|
+
'syslog_msgid',
|
|
229
|
+
}:
|
|
230
|
+
if value is not None and not isinstance(value, str):
|
|
231
|
+
raise LoggingConfigError(f'logging profile {key!r} must be a string or null')
|
|
232
|
+
result[key] = value
|
|
233
|
+
elif key == 'syslog_enterprise_id':
|
|
234
|
+
if not isinstance(value, int) or value <= 0:
|
|
235
|
+
raise LoggingConfigError("logging profile 'syslog_enterprise_id' must be a positive integer")
|
|
236
|
+
result[key] = value
|
|
237
|
+
if result.get('format') not in {None, 'default', 'json', 'rfc5424'}:
|
|
238
|
+
raise LoggingConfigError("logging profile 'format' must be one of default, json, or rfc5424")
|
|
239
|
+
return result
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def resolve_logging_config(level: str = 'info', *, config: Any | None = None) -> ResolvedLoggingConfig:
|
|
243
|
+
resolved = ResolvedLoggingConfig(level=level)
|
|
244
|
+
if config is None:
|
|
245
|
+
return resolved
|
|
246
|
+
|
|
247
|
+
explicit_fields = tuple(sorted(set(getattr(config, 'explicit_fields', []) or ())))
|
|
248
|
+
log_config_path = getattr(config, 'log_config', None)
|
|
249
|
+
if log_config_path:
|
|
250
|
+
file_profile = load_logging_profile(log_config_path)
|
|
251
|
+
for key, value in file_profile.items():
|
|
252
|
+
if hasattr(resolved, key):
|
|
253
|
+
setattr(resolved, key, value)
|
|
254
|
+
resolved.log_config = str(log_config_path)
|
|
255
|
+
|
|
256
|
+
source_fields = (
|
|
257
|
+
'level',
|
|
258
|
+
'structured',
|
|
259
|
+
'access_log',
|
|
260
|
+
'access_log_file',
|
|
261
|
+
'access_log_format',
|
|
262
|
+
'error_log_file',
|
|
263
|
+
'use_colors',
|
|
264
|
+
)
|
|
265
|
+
if not log_config_path:
|
|
266
|
+
for field_name in source_fields:
|
|
267
|
+
value = getattr(config, field_name, getattr(resolved, field_name))
|
|
268
|
+
setattr(resolved, field_name, value)
|
|
269
|
+
else:
|
|
270
|
+
for field_name in explicit_fields:
|
|
271
|
+
if field_name in source_fields:
|
|
272
|
+
setattr(resolved, field_name, getattr(config, field_name, getattr(resolved, field_name)))
|
|
273
|
+
|
|
274
|
+
resolved.explicit_fields = explicit_fields
|
|
275
|
+
return resolved
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def validate_logging_contract(config: Any | None) -> None:
|
|
279
|
+
if config is None:
|
|
280
|
+
return
|
|
281
|
+
if getattr(config, 'log_config', None):
|
|
282
|
+
resolve_logging_config(getattr(config, 'level', 'info'), config=config)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def _stream_formatter(*, resolved: ResolvedLoggingConfig, use_colors: bool) -> logging.Formatter:
|
|
286
|
+
if resolved.format == 'rfc5424':
|
|
287
|
+
return RFC5424Formatter(
|
|
288
|
+
app_name=resolved.syslog_app_name,
|
|
289
|
+
procid=resolved.syslog_procid,
|
|
290
|
+
msgid=resolved.syslog_msgid,
|
|
291
|
+
enterprise_id=resolved.syslog_enterprise_id,
|
|
292
|
+
)
|
|
293
|
+
structured = resolved.structured or resolved.format == 'json'
|
|
294
|
+
if structured:
|
|
295
|
+
return JSONFormatter()
|
|
296
|
+
if use_colors:
|
|
297
|
+
return ColorFormatter('%(asctime)s %(levelname)s %(name)s %(message)s')
|
|
298
|
+
return logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s')
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def configure_logging(level: str = 'info', *, config: Any | None = None) -> logging.Logger:
|
|
302
|
+
resolved = resolve_logging_config(level, config=config)
|
|
303
|
+
if resolved.dict_config is not None:
|
|
304
|
+
logging.config.dictConfig(resolved.dict_config)
|
|
305
|
+
logger = logging.getLogger('tigrcorn')
|
|
306
|
+
if 'level' in resolved.explicit_fields:
|
|
307
|
+
logger.setLevel(_coerce_level(resolved.level))
|
|
308
|
+
return logger
|
|
309
|
+
|
|
310
|
+
logger = logging.getLogger('tigrcorn')
|
|
311
|
+
for handler in list(logger.handlers):
|
|
312
|
+
logger.removeHandler(handler)
|
|
313
|
+
try:
|
|
314
|
+
handler.close()
|
|
315
|
+
except Exception:
|
|
316
|
+
pass
|
|
317
|
+
|
|
318
|
+
logger.setLevel(_coerce_level(resolved.level))
|
|
319
|
+
logger.propagate = False
|
|
320
|
+
|
|
321
|
+
if resolved.stream:
|
|
322
|
+
stream_handler = logging.StreamHandler()
|
|
323
|
+
enable_colors = resolved.use_colors
|
|
324
|
+
if enable_colors is None:
|
|
325
|
+
stream = getattr(stream_handler, 'stream', None)
|
|
326
|
+
enable_colors = bool(getattr(stream, 'isatty', lambda: False)())
|
|
327
|
+
stream_handler.setFormatter(_stream_formatter(resolved=resolved, use_colors=bool(enable_colors)))
|
|
328
|
+
logger.addHandler(stream_handler)
|
|
329
|
+
|
|
330
|
+
file_formatter: logging.Formatter = _stream_formatter(resolved=resolved, use_colors=False)
|
|
331
|
+
if resolved.access_log_file:
|
|
332
|
+
logger.addHandler(_file_handler(resolved.access_log_file, file_formatter))
|
|
333
|
+
if resolved.error_log_file and resolved.error_log_file != resolved.access_log_file:
|
|
334
|
+
logger.addHandler(_file_handler(resolved.error_log_file, file_formatter))
|
|
335
|
+
|
|
336
|
+
if not logger.handlers:
|
|
337
|
+
stream_handler = logging.StreamHandler()
|
|
338
|
+
stream_handler.setFormatter(_stream_formatter(resolved=resolved, use_colors=False))
|
|
339
|
+
logger.addHandler(stream_handler)
|
|
340
|
+
|
|
341
|
+
return logger
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
import socket
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from time import monotonic, time
|
|
8
|
+
from typing import Any, Mapping
|
|
9
|
+
from urllib.parse import urlparse
|
|
10
|
+
|
|
11
|
+
STATSD_EXPORT_SCHEMA_VERSION = 'statsd-dogstatsd-v1'
|
|
12
|
+
OTEL_EXPORT_SCHEMA_VERSION = 'otlp-http-json-v1'
|
|
13
|
+
STATSD_EXPORT_MODES = ('statsd', 'dogstatsd')
|
|
14
|
+
|
|
15
|
+
@dataclass(slots=True)
|
|
16
|
+
class Metrics:
|
|
17
|
+
started_at: float = field(default_factory=monotonic)
|
|
18
|
+
connections_opened: int = 0
|
|
19
|
+
connections_closed: int = 0
|
|
20
|
+
active_connections: int = 0
|
|
21
|
+
requests_served: int = 0
|
|
22
|
+
requests_failed: int = 0
|
|
23
|
+
websocket_connections: int = 0
|
|
24
|
+
websocket_connections_closed: int = 0
|
|
25
|
+
active_websocket_connections: int = 0
|
|
26
|
+
scheduler_tasks_spawned: int = 0
|
|
27
|
+
scheduler_tasks_rejected: int = 0
|
|
28
|
+
scheduler_rejections: int = 0
|
|
29
|
+
streams_opened: int = 0
|
|
30
|
+
websocket_pings_sent: int = 0
|
|
31
|
+
websocket_ping_timeouts: int = 0
|
|
32
|
+
protocol_errors: int = 0
|
|
33
|
+
bytes_received: int = 0
|
|
34
|
+
bytes_sent: int = 0
|
|
35
|
+
quic_datagrams_received: int = 0
|
|
36
|
+
quic_datagrams_sent: int = 0
|
|
37
|
+
quic_sessions_opened: int = 0
|
|
38
|
+
quic_sessions_closed: int = 0
|
|
39
|
+
active_quic_sessions: int = 0
|
|
40
|
+
tls_handshakes_completed: int = 0
|
|
41
|
+
quic_retry_sent: int = 0
|
|
42
|
+
quic_early_data_attempted: int = 0
|
|
43
|
+
quic_early_data_accepted: int = 0
|
|
44
|
+
quic_early_data_rejected: int = 0
|
|
45
|
+
quic_path_challenges: int = 0
|
|
46
|
+
quic_path_responses: int = 0
|
|
47
|
+
quic_path_migrations: int = 0
|
|
48
|
+
quic_packets_lost: int = 0
|
|
49
|
+
quic_pto_expirations: int = 0
|
|
50
|
+
http3_requests_served: int = 0
|
|
51
|
+
http3_stream_resets: int = 0
|
|
52
|
+
http3_goaway_received: int = 0
|
|
53
|
+
http3_qpack_encoder_streams: int = 0
|
|
54
|
+
http3_qpack_decoder_streams: int = 0
|
|
55
|
+
|
|
56
|
+
def connection_opened(self) -> None:
|
|
57
|
+
self.connections_opened += 1
|
|
58
|
+
self.active_connections += 1
|
|
59
|
+
|
|
60
|
+
def connection_closed(self) -> None:
|
|
61
|
+
self.connections_closed += 1
|
|
62
|
+
self.active_connections = max(0, self.active_connections - 1)
|
|
63
|
+
|
|
64
|
+
def websocket_opened(self) -> None:
|
|
65
|
+
self.websocket_connections += 1
|
|
66
|
+
self.active_websocket_connections += 1
|
|
67
|
+
|
|
68
|
+
def websocket_closed(self) -> None:
|
|
69
|
+
self.websocket_connections_closed += 1
|
|
70
|
+
self.active_websocket_connections = max(0, self.active_websocket_connections - 1)
|
|
71
|
+
|
|
72
|
+
def scheduler_task_spawned(self) -> None:
|
|
73
|
+
self.scheduler_tasks_spawned += 1
|
|
74
|
+
|
|
75
|
+
def scheduler_task_rejected(self) -> None:
|
|
76
|
+
self.scheduler_tasks_rejected += 1
|
|
77
|
+
self.scheduler_rejections += 1
|
|
78
|
+
|
|
79
|
+
def websocket_ping_sent(self) -> None:
|
|
80
|
+
self.websocket_pings_sent += 1
|
|
81
|
+
|
|
82
|
+
def websocket_ping_timeout(self) -> None:
|
|
83
|
+
self.websocket_ping_timeouts += 1
|
|
84
|
+
|
|
85
|
+
def quic_session_opened(self) -> None:
|
|
86
|
+
self.quic_sessions_opened += 1
|
|
87
|
+
self.active_quic_sessions += 1
|
|
88
|
+
|
|
89
|
+
def quic_session_closed(self) -> None:
|
|
90
|
+
self.quic_sessions_closed += 1
|
|
91
|
+
self.active_quic_sessions = max(0, self.active_quic_sessions - 1)
|
|
92
|
+
|
|
93
|
+
def quic_datagram_received(self, length: int = 0) -> None:
|
|
94
|
+
self.quic_datagrams_received += 1
|
|
95
|
+
if length > 0:
|
|
96
|
+
self.bytes_received += int(length)
|
|
97
|
+
|
|
98
|
+
def quic_datagram_sent(self, length: int = 0) -> None:
|
|
99
|
+
self.quic_datagrams_sent += 1
|
|
100
|
+
if length > 0:
|
|
101
|
+
self.bytes_sent += int(length)
|
|
102
|
+
|
|
103
|
+
def tls_handshake_completed(self) -> None:
|
|
104
|
+
self.tls_handshakes_completed += 1
|
|
105
|
+
|
|
106
|
+
def quic_retry_emitted(self) -> None:
|
|
107
|
+
self.quic_retry_sent += 1
|
|
108
|
+
|
|
109
|
+
def quic_early_data_observed(self, *, accepted: bool) -> None:
|
|
110
|
+
self.quic_early_data_attempted += 1
|
|
111
|
+
if accepted:
|
|
112
|
+
self.quic_early_data_accepted += 1
|
|
113
|
+
else:
|
|
114
|
+
self.quic_early_data_rejected += 1
|
|
115
|
+
|
|
116
|
+
def quic_path_challenge_observed(self) -> None:
|
|
117
|
+
self.quic_path_challenges += 1
|
|
118
|
+
|
|
119
|
+
def quic_path_response_observed(self) -> None:
|
|
120
|
+
self.quic_path_responses += 1
|
|
121
|
+
|
|
122
|
+
def quic_path_migrated(self) -> None:
|
|
123
|
+
self.quic_path_migrations += 1
|
|
124
|
+
|
|
125
|
+
def quic_packets_lost_observed(self, count: int) -> None:
|
|
126
|
+
self.quic_packets_lost += max(0, int(count))
|
|
127
|
+
|
|
128
|
+
def quic_pto_expired(self) -> None:
|
|
129
|
+
self.quic_pto_expirations += 1
|
|
130
|
+
|
|
131
|
+
def http3_request_served(self) -> None:
|
|
132
|
+
self.http3_requests_served += 1
|
|
133
|
+
|
|
134
|
+
def http3_stream_reset(self) -> None:
|
|
135
|
+
self.http3_stream_resets += 1
|
|
136
|
+
|
|
137
|
+
def http3_goaway_observed(self) -> None:
|
|
138
|
+
self.http3_goaway_received += 1
|
|
139
|
+
|
|
140
|
+
def http3_qpack_encoder_stream_opened(self) -> None:
|
|
141
|
+
self.http3_qpack_encoder_streams += 1
|
|
142
|
+
|
|
143
|
+
def http3_qpack_decoder_stream_opened(self) -> None:
|
|
144
|
+
self.http3_qpack_decoder_streams += 1
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def uptime_seconds(self) -> float:
|
|
148
|
+
return max(0.0, monotonic() - self.started_at)
|
|
149
|
+
|
|
150
|
+
def snapshot(self) -> dict[str, Any]:
|
|
151
|
+
return {
|
|
152
|
+
'uptime_seconds': round(self.uptime_seconds, 6),
|
|
153
|
+
'connections_opened': self.connections_opened,
|
|
154
|
+
'connections_closed': self.connections_closed,
|
|
155
|
+
'active_connections': self.active_connections,
|
|
156
|
+
'requests_served': self.requests_served,
|
|
157
|
+
'requests_failed': self.requests_failed,
|
|
158
|
+
'websocket_connections': self.websocket_connections,
|
|
159
|
+
'websocket_connections_closed': self.websocket_connections_closed,
|
|
160
|
+
'active_websocket_connections': self.active_websocket_connections,
|
|
161
|
+
'scheduler_tasks_spawned': self.scheduler_tasks_spawned,
|
|
162
|
+
'scheduler_tasks_rejected': self.scheduler_tasks_rejected,
|
|
163
|
+
'scheduler_rejections': self.scheduler_rejections,
|
|
164
|
+
'streams_opened': self.streams_opened,
|
|
165
|
+
'websocket_pings_sent': self.websocket_pings_sent,
|
|
166
|
+
'websocket_ping_timeouts': self.websocket_ping_timeouts,
|
|
167
|
+
'protocol_errors': self.protocol_errors,
|
|
168
|
+
'bytes_received': self.bytes_received,
|
|
169
|
+
'bytes_sent': self.bytes_sent,
|
|
170
|
+
'quic_datagrams_received': self.quic_datagrams_received,
|
|
171
|
+
'quic_datagrams_sent': self.quic_datagrams_sent,
|
|
172
|
+
'quic_sessions_opened': self.quic_sessions_opened,
|
|
173
|
+
'quic_sessions_closed': self.quic_sessions_closed,
|
|
174
|
+
'active_quic_sessions': self.active_quic_sessions,
|
|
175
|
+
'tls_handshakes_completed': self.tls_handshakes_completed,
|
|
176
|
+
'quic_retry_sent': self.quic_retry_sent,
|
|
177
|
+
'quic_early_data_attempted': self.quic_early_data_attempted,
|
|
178
|
+
'quic_early_data_accepted': self.quic_early_data_accepted,
|
|
179
|
+
'quic_early_data_rejected': self.quic_early_data_rejected,
|
|
180
|
+
'quic_path_challenges': self.quic_path_challenges,
|
|
181
|
+
'quic_path_responses': self.quic_path_responses,
|
|
182
|
+
'quic_path_migrations': self.quic_path_migrations,
|
|
183
|
+
'quic_packets_lost': self.quic_packets_lost,
|
|
184
|
+
'quic_pto_expirations': self.quic_pto_expirations,
|
|
185
|
+
'http3_requests_served': self.http3_requests_served,
|
|
186
|
+
'http3_stream_resets': self.http3_stream_resets,
|
|
187
|
+
'http3_goaway_received': self.http3_goaway_received,
|
|
188
|
+
'http3_qpack_encoder_streams': self.http3_qpack_encoder_streams,
|
|
189
|
+
'http3_qpack_decoder_streams': self.http3_qpack_decoder_streams,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
def render_prometheus(self, *, prefix: str = 'tigrcorn') -> str:
|
|
193
|
+
snapshot = self.snapshot()
|
|
194
|
+
lines = []
|
|
195
|
+
for key, value in snapshot.items():
|
|
196
|
+
metric_name = f"{prefix}_{key}"
|
|
197
|
+
lines.append(f"# TYPE {metric_name} gauge")
|
|
198
|
+
lines.append(f"{metric_name} {value}")
|
|
199
|
+
return '\n'.join(lines) + '\n'
|
|
200
|
+
|
|
201
|
+
def render_statsd(self, *, prefix: str = 'tigrcorn', previous: Mapping[str, Any] | None = None) -> str:
|
|
202
|
+
return '\n'.join(iter_statsd_lines(self.snapshot(), previous=previous, prefix=prefix))
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _is_gauge_metric(name: str) -> bool:
|
|
206
|
+
return name.startswith('active_') or name == 'uptime_seconds'
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def iter_statsd_lines(snapshot: Mapping[str, Any], *, previous: Mapping[str, Any] | None = None, prefix: str = 'tigrcorn') -> list[str]:
|
|
210
|
+
lines: list[str] = []
|
|
211
|
+
previous = previous or {}
|
|
212
|
+
for key, raw_value in snapshot.items():
|
|
213
|
+
metric_name = f'{prefix}.{key}'
|
|
214
|
+
if _is_gauge_metric(key):
|
|
215
|
+
lines.append(f'{metric_name}:{raw_value}|g')
|
|
216
|
+
continue
|
|
217
|
+
current = float(raw_value)
|
|
218
|
+
baseline = float(previous.get(key, 0))
|
|
219
|
+
delta = current - baseline
|
|
220
|
+
if delta < 0:
|
|
221
|
+
delta = current
|
|
222
|
+
lines.append(f'{metric_name}:{delta}|c')
|
|
223
|
+
return lines
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def parse_statsd_target(target: str) -> tuple[str, int, str]:
|
|
227
|
+
target = str(target).strip()
|
|
228
|
+
if not target:
|
|
229
|
+
raise ValueError('statsd_host cannot be empty')
|
|
230
|
+
mode = 'statsd'
|
|
231
|
+
if '://' in target:
|
|
232
|
+
parsed = urlparse(target)
|
|
233
|
+
if parsed.scheme not in STATSD_EXPORT_MODES:
|
|
234
|
+
raise ValueError('statsd_host scheme must be statsd:// or dogstatsd://')
|
|
235
|
+
if not parsed.hostname or parsed.port is None:
|
|
236
|
+
raise ValueError('statsd_host URL must include host and port')
|
|
237
|
+
host = parsed.hostname
|
|
238
|
+
port_value = int(parsed.port)
|
|
239
|
+
mode = parsed.scheme
|
|
240
|
+
if port_value <= 0 or port_value > 65535:
|
|
241
|
+
raise ValueError('statsd_host port must be between 1 and 65535')
|
|
242
|
+
return host, port_value, mode
|
|
243
|
+
if target.startswith('[') and ']:' in target:
|
|
244
|
+
host, port = target.rsplit(':', 1)
|
|
245
|
+
host = host[1:-1]
|
|
246
|
+
elif ':' in target:
|
|
247
|
+
host, port = target.rsplit(':', 1)
|
|
248
|
+
else:
|
|
249
|
+
raise ValueError('statsd_host must be host:port')
|
|
250
|
+
port_value = int(port)
|
|
251
|
+
if port_value <= 0 or port_value > 65535:
|
|
252
|
+
raise ValueError('statsd_host port must be between 1 and 65535')
|
|
253
|
+
if not host:
|
|
254
|
+
raise ValueError('statsd_host host cannot be empty')
|
|
255
|
+
return host, port_value, mode
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def parse_statsd_host(target: str) -> tuple[str, int]:
|
|
259
|
+
host, port, _mode = parse_statsd_target(target)
|
|
260
|
+
return host, port
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class StatsdExporter:
|
|
264
|
+
def __init__(self, target: str, *, prefix: str = 'tigrcorn', interval: float = 1.0, logger: logging.Logger | None = None) -> None:
|
|
265
|
+
self.host, self.port, self.mode = parse_statsd_target(target)
|
|
266
|
+
self.prefix = prefix
|
|
267
|
+
self.interval = max(0.1, float(interval))
|
|
268
|
+
self.logger = logger
|
|
269
|
+
self._task: asyncio.Task[None] | None = None
|
|
270
|
+
self._socket: socket.socket | None = None
|
|
271
|
+
self._sockaddr: tuple[Any, ...] | None = None
|
|
272
|
+
self._last_snapshot: dict[str, Any] | None = None
|
|
273
|
+
self.sent_packets = 0
|
|
274
|
+
self.send_failures = 0
|
|
275
|
+
self.last_payload: str | None = None
|
|
276
|
+
self.last_error: str | None = None
|
|
277
|
+
|
|
278
|
+
def _ensure_socket(self) -> socket.socket:
|
|
279
|
+
if self._socket is not None:
|
|
280
|
+
return self._socket
|
|
281
|
+
infos = socket.getaddrinfo(self.host, self.port, type=socket.SOCK_DGRAM)
|
|
282
|
+
family, socktype, proto, _canon, sockaddr = infos[0]
|
|
283
|
+
sock = socket.socket(family, socktype, proto)
|
|
284
|
+
sock.setblocking(False)
|
|
285
|
+
self._socket = sock
|
|
286
|
+
self._sockaddr = sockaddr
|
|
287
|
+
return sock
|
|
288
|
+
|
|
289
|
+
async def start(self, metrics: Metrics) -> None:
|
|
290
|
+
if self._task is not None:
|
|
291
|
+
return
|
|
292
|
+
await self.export_now(metrics)
|
|
293
|
+
self._task = asyncio.create_task(self._run(metrics), name='tigrcorn-statsd-exporter')
|
|
294
|
+
|
|
295
|
+
async def _run(self, metrics: Metrics) -> None:
|
|
296
|
+
try:
|
|
297
|
+
while True:
|
|
298
|
+
await asyncio.sleep(self.interval)
|
|
299
|
+
await self.export_now(metrics)
|
|
300
|
+
except asyncio.CancelledError:
|
|
301
|
+
raise
|
|
302
|
+
|
|
303
|
+
async def export_now(self, metrics: Metrics) -> None:
|
|
304
|
+
snapshot = metrics.snapshot()
|
|
305
|
+
payload = '\n'.join(iter_statsd_lines(snapshot, previous=self._last_snapshot, prefix=self.prefix))
|
|
306
|
+
self._last_snapshot = dict(snapshot)
|
|
307
|
+
self.last_payload = payload
|
|
308
|
+
if not payload:
|
|
309
|
+
return
|
|
310
|
+
try:
|
|
311
|
+
sock = self._ensure_socket()
|
|
312
|
+
assert self._sockaddr is not None
|
|
313
|
+
await asyncio.get_running_loop().sock_sendto(sock, payload.encode('utf-8'), self._sockaddr)
|
|
314
|
+
self.sent_packets += 1
|
|
315
|
+
except Exception as exc: # pragma: no cover - bounded failure path exercised in tests
|
|
316
|
+
self.send_failures += 1
|
|
317
|
+
self.last_error = str(exc)
|
|
318
|
+
if self.logger is not None:
|
|
319
|
+
self.logger.warning('statsd exporter send failed: %s', exc)
|
|
320
|
+
|
|
321
|
+
async def stop(self, metrics: Metrics | None = None) -> None:
|
|
322
|
+
if metrics is not None:
|
|
323
|
+
await self.export_now(metrics)
|
|
324
|
+
if self._task is not None:
|
|
325
|
+
self._task.cancel()
|
|
326
|
+
try:
|
|
327
|
+
await self._task
|
|
328
|
+
except asyncio.CancelledError:
|
|
329
|
+
pass
|
|
330
|
+
self._task = None
|
|
331
|
+
if self._socket is not None:
|
|
332
|
+
try:
|
|
333
|
+
self._socket.close()
|
|
334
|
+
finally:
|
|
335
|
+
self._socket = None
|
|
336
|
+
self._sockaddr = None
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def otel_metric_payload(snapshot: Mapping[str, Any], *, prefix: str = 'tigrcorn') -> list[dict[str, Any]]:
|
|
340
|
+
now_nanos = str(int(time() * 1_000_000_000))
|
|
341
|
+
metrics_payload: list[dict[str, Any]] = []
|
|
342
|
+
for key, value in snapshot.items():
|
|
343
|
+
name = f'{prefix}.{key}'
|
|
344
|
+
if _is_gauge_metric(key):
|
|
345
|
+
metrics_payload.append({
|
|
346
|
+
'name': name,
|
|
347
|
+
'gauge': {
|
|
348
|
+
'dataPoints': [{'timeUnixNano': now_nanos, 'asDouble': float(value)}],
|
|
349
|
+
},
|
|
350
|
+
})
|
|
351
|
+
else:
|
|
352
|
+
metrics_payload.append({
|
|
353
|
+
'name': name,
|
|
354
|
+
'sum': {
|
|
355
|
+
'aggregationTemporality': 2,
|
|
356
|
+
'isMonotonic': True,
|
|
357
|
+
'dataPoints': [{'timeUnixNano': now_nanos, 'asInt': int(value)}],
|
|
358
|
+
},
|
|
359
|
+
})
|
|
360
|
+
return metrics_payload
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import json
|
|
5
|
+
import logging
|
|
6
|
+
import random
|
|
7
|
+
import time
|
|
8
|
+
import urllib.error
|
|
9
|
+
import urllib.parse
|
|
10
|
+
import urllib.request
|
|
11
|
+
from contextlib import contextmanager
|
|
12
|
+
from contextvars import ContextVar
|
|
13
|
+
from dataclasses import asdict, dataclass
|
|
14
|
+
from typing import Any, Iterator
|
|
15
|
+
from uuid import uuid4
|
|
16
|
+
|
|
17
|
+
from tigrcorn_observability.metrics import Metrics, OTEL_EXPORT_SCHEMA_VERSION, otel_metric_payload
|
|
18
|
+
|
|
19
|
+
_current_trace_id: ContextVar[str | None] = ContextVar('tigrcorn_trace_id', default=None)
|
|
20
|
+
_current_span_id: ContextVar[str | None] = ContextVar('tigrcorn_span_id', default=None)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass(slots=True)
|
|
24
|
+
class SpanRecord:
|
|
25
|
+
name: str
|
|
26
|
+
trace_id: str
|
|
27
|
+
span_id: str
|
|
28
|
+
start_time: float
|
|
29
|
+
end_time: float | None = None
|
|
30
|
+
attrs: dict[str, Any] | None = None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@contextmanager
|
|
34
|
+
def span(name: str, *, attrs: dict[str, Any] | None = None, sample_rate: float = 1.0, sink: callable | None = None) -> Iterator[SpanRecord | None]:
|
|
35
|
+
if sample_rate <= 0 or random.random() > sample_rate:
|
|
36
|
+
yield None
|
|
37
|
+
return
|
|
38
|
+
trace_id = _current_trace_id.get() or uuid4().hex
|
|
39
|
+
span_id = uuid4().hex[:16]
|
|
40
|
+
token_trace = _current_trace_id.set(trace_id)
|
|
41
|
+
token_span = _current_span_id.set(span_id)
|
|
42
|
+
record = SpanRecord(name=name, trace_id=trace_id, span_id=span_id, start_time=time.time(), attrs=dict(attrs or {}))
|
|
43
|
+
try:
|
|
44
|
+
yield record
|
|
45
|
+
finally:
|
|
46
|
+
record.end_time = time.time()
|
|
47
|
+
if sink is not None:
|
|
48
|
+
sink(record)
|
|
49
|
+
_current_span_id.reset(token_span)
|
|
50
|
+
_current_trace_id.reset(token_trace)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def parse_otel_endpoint(endpoint: str) -> str:
|
|
54
|
+
parsed = urllib.parse.urlparse(str(endpoint).strip())
|
|
55
|
+
if parsed.scheme not in {'http', 'https'}:
|
|
56
|
+
raise ValueError('otel_endpoint must use http:// or https://')
|
|
57
|
+
if not parsed.netloc:
|
|
58
|
+
raise ValueError('otel_endpoint must include a network location')
|
|
59
|
+
return urllib.parse.urlunparse(parsed)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class OtelExporter:
|
|
63
|
+
def __init__(self, endpoint: str, *, service_name: str = 'tigrcorn', interval: float = 1.0, logger: logging.Logger | None = None, timeout: float = 2.0) -> None:
|
|
64
|
+
self.endpoint = parse_otel_endpoint(endpoint)
|
|
65
|
+
self.service_name = service_name
|
|
66
|
+
self.interval = max(0.1, float(interval))
|
|
67
|
+
self.logger = logger
|
|
68
|
+
self.timeout = float(timeout)
|
|
69
|
+
self._task: asyncio.Task[None] | None = None
|
|
70
|
+
self._span_buffer: list[dict[str, Any]] = []
|
|
71
|
+
self.buffer_limit = 256
|
|
72
|
+
self.sent_batches = 0
|
|
73
|
+
self.send_failures = 0
|
|
74
|
+
self.last_error: str | None = None
|
|
75
|
+
self.last_payload: dict[str, Any] | None = None
|
|
76
|
+
|
|
77
|
+
def record_span(self, record: SpanRecord) -> None:
|
|
78
|
+
payload = {
|
|
79
|
+
'traceId': record.trace_id,
|
|
80
|
+
'spanId': record.span_id,
|
|
81
|
+
'name': record.name,
|
|
82
|
+
'startTimeUnixNano': str(int(record.start_time * 1_000_000_000)),
|
|
83
|
+
'endTimeUnixNano': str(int((record.end_time or record.start_time) * 1_000_000_000)),
|
|
84
|
+
'attributes': [
|
|
85
|
+
{
|
|
86
|
+
'key': key,
|
|
87
|
+
'value': {'stringValue': str(value)},
|
|
88
|
+
}
|
|
89
|
+
for key, value in sorted((record.attrs or {}).items())
|
|
90
|
+
],
|
|
91
|
+
}
|
|
92
|
+
self._span_buffer.append(payload)
|
|
93
|
+
if len(self._span_buffer) > self.buffer_limit:
|
|
94
|
+
self._span_buffer = self._span_buffer[-self.buffer_limit :]
|
|
95
|
+
|
|
96
|
+
def _resource(self) -> dict[str, Any]:
|
|
97
|
+
return {
|
|
98
|
+
'attributes': [
|
|
99
|
+
{'key': 'service.name', 'value': {'stringValue': self.service_name}},
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
def _build_payload(self, metrics: Metrics) -> dict[str, Any]:
|
|
104
|
+
snapshot = metrics.snapshot()
|
|
105
|
+
spans = list(self._span_buffer)
|
|
106
|
+
return {
|
|
107
|
+
'resourceMetrics': [
|
|
108
|
+
{
|
|
109
|
+
'resource': self._resource(),
|
|
110
|
+
'scopeMetrics': [
|
|
111
|
+
{
|
|
112
|
+
'scope': {'name': 'tigrcorn', 'version': OTEL_EXPORT_SCHEMA_VERSION},
|
|
113
|
+
'metrics': otel_metric_payload(snapshot),
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
'resourceSpans': [
|
|
119
|
+
{
|
|
120
|
+
'resource': self._resource(),
|
|
121
|
+
'scopeSpans': [
|
|
122
|
+
{
|
|
123
|
+
'scope': {'name': 'tigrcorn', 'version': OTEL_EXPORT_SCHEMA_VERSION},
|
|
124
|
+
'spans': spans,
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
def _post_json(self, payload: dict[str, Any]) -> None:
|
|
132
|
+
body = json.dumps(payload, sort_keys=True).encode('utf-8')
|
|
133
|
+
request = urllib.request.Request(self.endpoint, data=body, method='POST', headers={'content-type': 'application/json'})
|
|
134
|
+
with urllib.request.urlopen(request, timeout=self.timeout) as response: # noqa: S310
|
|
135
|
+
response.read()
|
|
136
|
+
|
|
137
|
+
async def start(self, metrics: Metrics) -> None:
|
|
138
|
+
if self._task is not None:
|
|
139
|
+
return
|
|
140
|
+
await self.export_now(metrics)
|
|
141
|
+
self._task = asyncio.create_task(self._run(metrics), name='tigrcorn-otel-exporter')
|
|
142
|
+
|
|
143
|
+
async def _run(self, metrics: Metrics) -> None:
|
|
144
|
+
try:
|
|
145
|
+
while True:
|
|
146
|
+
await asyncio.sleep(self.interval)
|
|
147
|
+
await self.export_now(metrics)
|
|
148
|
+
except asyncio.CancelledError:
|
|
149
|
+
raise
|
|
150
|
+
|
|
151
|
+
async def export_now(self, metrics: Metrics) -> None:
|
|
152
|
+
payload = self._build_payload(metrics)
|
|
153
|
+
self.last_payload = payload
|
|
154
|
+
spans_before = list(self._span_buffer)
|
|
155
|
+
try:
|
|
156
|
+
await asyncio.to_thread(self._post_json, payload)
|
|
157
|
+
self.sent_batches += 1
|
|
158
|
+
self._span_buffer.clear()
|
|
159
|
+
except Exception as exc: # pragma: no cover - bounded failure path exercised in tests
|
|
160
|
+
self.send_failures += 1
|
|
161
|
+
self.last_error = str(exc)
|
|
162
|
+
self._span_buffer = spans_before
|
|
163
|
+
if self.logger is not None:
|
|
164
|
+
self.logger.warning('otel exporter post failed: %s', exc)
|
|
165
|
+
|
|
166
|
+
async def stop(self, metrics: Metrics | None = None) -> None:
|
|
167
|
+
if metrics is not None:
|
|
168
|
+
await self.export_now(metrics)
|
|
169
|
+
if self._task is not None:
|
|
170
|
+
self._task.cancel()
|
|
171
|
+
try:
|
|
172
|
+
await self._task
|
|
173
|
+
except asyncio.CancelledError:
|
|
174
|
+
pass
|
|
175
|
+
self._task = None
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def validate_otel_endpoint(endpoint: str | None) -> None:
|
|
179
|
+
if endpoint:
|
|
180
|
+
parse_otel_endpoint(endpoint)
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tigrcorn-observability
|
|
3
|
+
Version: 0.3.16.dev5
|
|
4
|
+
Summary: Logging, metrics, tracing, DoS warning events, and release-evidence metadata for the Tigrcorn Python web server.
|
|
5
|
+
Author-email: Jacob Stewart <jacob@swarmauri.com>
|
|
6
|
+
License: Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
|
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
15
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
16
|
+
|
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by the
|
|
18
|
+
copyright owner that is granting the License.
|
|
19
|
+
|
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
21
|
+
entities that control, are controlled by, or are under common control with
|
|
22
|
+
that entity. For the purposes of this definition, "control" means (i) the
|
|
23
|
+
power, direct or indirect, to cause the direction or management of such
|
|
24
|
+
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
|
|
25
|
+
(50%) or more of the outstanding shares, or (iii) beneficial ownership of
|
|
26
|
+
such entity.
|
|
27
|
+
|
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
29
|
+
permissions granted by this License.
|
|
30
|
+
|
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
32
|
+
including but not limited to software source code, documentation source, and
|
|
33
|
+
configuration files.
|
|
34
|
+
|
|
35
|
+
"Object" form shall mean any form resulting from mechanical transformation
|
|
36
|
+
or translation of a Source form, including but not limited to compiled object
|
|
37
|
+
code, generated documentation, and conversions to other media types.
|
|
38
|
+
|
|
39
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
40
|
+
made available under the License, as indicated by a copyright notice that is
|
|
41
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
42
|
+
below).
|
|
43
|
+
|
|
44
|
+
"Derivative Works" shall mean any work, whether in Source or Object form,
|
|
45
|
+
that is based on (or derived from) the Work and for which the editorial
|
|
46
|
+
revisions, annotations, elaborations, or other modifications represent, as a
|
|
47
|
+
whole, an original work of authorship. For the purposes of this License,
|
|
48
|
+
Derivative Works shall not include works that remain separable from, or
|
|
49
|
+
merely link (or bind by name) to the interfaces of, the Work and Derivative
|
|
50
|
+
Works thereof.
|
|
51
|
+
|
|
52
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
53
|
+
version of the Work and any modifications or additions to that Work or
|
|
54
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
55
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
56
|
+
Entity authorized to submit on behalf of the copyright owner. For the
|
|
57
|
+
purposes of this definition, "submitted" means any form of electronic,
|
|
58
|
+
verbal, or written communication sent to the Licensor or its representatives,
|
|
59
|
+
including but not limited to communication on electronic mailing lists,
|
|
60
|
+
source code control systems, and issue tracking systems that are managed by,
|
|
61
|
+
or on behalf of, the Licensor for the purpose of discussing and improving the
|
|
62
|
+
Work, but excluding communication that is conspicuously marked or otherwise
|
|
63
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
64
|
+
|
|
65
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on
|
|
66
|
+
behalf of whom a Contribution has been received by Licensor and subsequently
|
|
67
|
+
incorporated within the Work.
|
|
68
|
+
|
|
69
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
70
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
71
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
72
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
73
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
74
|
+
Object form.
|
|
75
|
+
|
|
76
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
77
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
78
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
79
|
+
section) patent license to make, have made, use, offer to sell, sell, import,
|
|
80
|
+
and otherwise transfer the Work, where such license applies only to those
|
|
81
|
+
patent claims licensable by such Contributor that are necessarily infringed by
|
|
82
|
+
their Contribution(s) alone or by combination of their Contribution(s) with
|
|
83
|
+
the Work to which such Contribution(s) was submitted. If You institute patent
|
|
84
|
+
litigation against any entity (including a cross-claim or counterclaim in a
|
|
85
|
+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
|
|
86
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
87
|
+
licenses granted to You under this License for that Work shall terminate as of
|
|
88
|
+
the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
91
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
92
|
+
Source or Object form, provided that You meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
95
|
+
of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
98
|
+
You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
101
|
+
distribute, all copyright, patent, trademark, and attribution notices
|
|
102
|
+
from the Source form of the Work, excluding those notices that do not
|
|
103
|
+
pertain to any part of the Derivative Works; and
|
|
104
|
+
|
|
105
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
106
|
+
then any Derivative Works that You distribute must include a readable copy
|
|
107
|
+
of the attribution notices contained within such NOTICE file, excluding
|
|
108
|
+
those notices that do not pertain to any part of the Derivative Works, in
|
|
109
|
+
at least one of the following places: within a NOTICE text file distributed
|
|
110
|
+
as part of the Derivative Works; within the Source form or documentation,
|
|
111
|
+
if provided along with the Derivative Works; or, within a display generated
|
|
112
|
+
by the Derivative Works, if and wherever such third-party notices normally
|
|
113
|
+
appear. The contents of the NOTICE file are for informational purposes only
|
|
114
|
+
and do not modify the License. You may add Your own attribution notices
|
|
115
|
+
within Derivative Works that You distribute, alongside or as an addendum to
|
|
116
|
+
the NOTICE text from the Work, provided that such additional attribution
|
|
117
|
+
notices cannot be construed as modifying the License.
|
|
118
|
+
|
|
119
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
120
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
121
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
122
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
123
|
+
complies with the conditions stated in this License.
|
|
124
|
+
|
|
125
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
126
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
127
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
128
|
+
additional terms or conditions. Notwithstanding the above, nothing herein
|
|
129
|
+
shall supersede or modify the terms of any separate license agreement you may
|
|
130
|
+
have executed with Licensor regarding such Contributions.
|
|
131
|
+
|
|
132
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
133
|
+
trademarks, service marks, or product names of the Licensor, except as
|
|
134
|
+
required for reasonable and customary use in describing the origin of the Work
|
|
135
|
+
and reproducing the content of the NOTICE file.
|
|
136
|
+
|
|
137
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
138
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
139
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
140
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
141
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
142
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
143
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
144
|
+
associated with Your exercise of permissions under this License.
|
|
145
|
+
|
|
146
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
147
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
148
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
149
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
150
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
151
|
+
character arising as a result of this License or out of the use or inability
|
|
152
|
+
to use the Work (including but not limited to damages for loss of goodwill,
|
|
153
|
+
work stoppage, computer failure or malfunction, or any and all other
|
|
154
|
+
commercial damages or losses), even if such Contributor has been advised of
|
|
155
|
+
the possibility of such damages.
|
|
156
|
+
|
|
157
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
158
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
159
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
160
|
+
and/or rights consistent with this License. However, in accepting such
|
|
161
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
162
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
163
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
164
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
165
|
+
accepting any such warranty or additional liability.
|
|
166
|
+
|
|
167
|
+
END OF TERMS AND CONDITIONS
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
Keywords: tigrcorn,observability,logging,metrics,tracing,dos-warning,release-evidence
|
|
171
|
+
Classifier: Development Status :: 3 - Alpha
|
|
172
|
+
Classifier: Framework :: AsyncIO
|
|
173
|
+
Classifier: Intended Audience :: Developers
|
|
174
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
175
|
+
Classifier: Operating System :: OS Independent
|
|
176
|
+
Classifier: Programming Language :: Python :: 3
|
|
177
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
178
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
179
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
180
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
181
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
182
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
183
|
+
Classifier: Typing :: Typed
|
|
184
|
+
Requires-Python: >=3.11
|
|
185
|
+
Description-Content-Type: text/markdown
|
|
186
|
+
License-File: LICENSE
|
|
187
|
+
Requires-Dist: tigrcorn-core==0.3.16.dev5
|
|
188
|
+
Requires-Dist: tigrcorn-config==0.3.16.dev5
|
|
189
|
+
Dynamic: license-file
|
|
190
|
+
|
|
191
|
+
<div align="center">
|
|
192
|
+
<h1>tigrcorn-observability</h1>
|
|
193
|
+
|
|
194
|
+
<p><strong>Logging, metrics, tracing, DoS warning events, and release-evidence metadata for the Tigrcorn Python web server.</strong></p>
|
|
195
|
+
|
|
196
|
+
<a href="https://pypi.org/project/tigrcorn-observability/"><img alt="PyPI version for tigrcorn-observability" src="https://img.shields.io/pypi/v/tigrcorn-observability?label=PyPI"></a>
|
|
197
|
+
<a href="https://pypi.org/project/tigrcorn-observability/"><img alt="tigrcorn-observability package on PyPI" src="https://img.shields.io/badge/package-PyPI-blue"></a>
|
|
198
|
+
<a href="LICENSE"><img alt="Apache 2.0 license" src="https://img.shields.io/badge/license-Apache%202.0-525252"></a>
|
|
199
|
+
<a href="pyproject.toml"><img alt="Python 3.11 supported" src="https://img.shields.io/badge/python-3.11-3776ab"></a>
|
|
200
|
+
<a href="pyproject.toml"><img alt="Python 3.12 supported" src="https://img.shields.io/badge/python-3.12-3776ab"></a>
|
|
201
|
+
<a href="pyproject.toml"><img alt="Python 3.13 supported" src="https://img.shields.io/badge/python-3.13-3776ab"></a>
|
|
202
|
+
<a href="src/tigrcorn_observability/py.typed"><img alt="typed package" src="https://img.shields.io/badge/typed-py.typed-2f7ed8"></a>
|
|
203
|
+
<a href="https://pypi.org/project/tigrcorn-observability/"><img alt="observability role package" src="https://img.shields.io/badge/role-observability-0a7f5a"></a>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
## Install
|
|
207
|
+
|
|
208
|
+
~~~bash
|
|
209
|
+
pip install tigrcorn-observability
|
|
210
|
+
~~~
|
|
211
|
+
|
|
212
|
+
Use the aggregate [tigrcorn](https://pypi.org/project/tigrcorn/) distribution when you want the full ASGI3 Python web server stack. Install <code>tigrcorn-observability</code> directly when you want only this package boundary and its declared dependencies.
|
|
213
|
+
|
|
214
|
+
## What It Owns
|
|
215
|
+
|
|
216
|
+
<code>tigrcorn-observability</code> owns logging, metrics, tracing, DoS warning events, and evidence metadata export surfaces. Its import package is <code>tigrcorn_observability</code>, and its declared package dependencies are: tigrcorn-core, tigrcorn-config.
|
|
217
|
+
|
|
218
|
+
This package page is written for developers searching for Tigrcorn ASGI3 server components, Python web server packages, HTTP/3 and QUIC support, WebSocket and WebTransport runtime surfaces, typed package boundaries, and Apache 2.0 licensed infrastructure.
|
|
219
|
+
|
|
220
|
+
## Use It When
|
|
221
|
+
|
|
222
|
+
Use <code>tigrcorn-observability</code> when you need searchable Tigrcorn observability signals for runtime telemetry, protocol stalls, metrics, tracing, or release evidence. It is part of Tigrcorn's split-package architecture, so it can be installed independently while remaining linked to the rest of the Tigrcorn package family on PyPI.
|
|
223
|
+
|
|
224
|
+
## Import Surface
|
|
225
|
+
|
|
226
|
+
~~~python
|
|
227
|
+
import tigrcorn_observability
|
|
228
|
+
|
|
229
|
+
print(tigrcorn_observability.__name__)
|
|
230
|
+
~~~
|
|
231
|
+
|
|
232
|
+
The package exposes its supported public surface through the <code>tigrcorn_observability</code> namespace. The root [tigrcorn](https://pypi.org/project/tigrcorn/) package keeps compatibility shims for users who install the full server distribution.
|
|
233
|
+
|
|
234
|
+
## Package Graph
|
|
235
|
+
|
|
236
|
+
[tigrcorn](https://pypi.org/project/tigrcorn/) | [tigrcorn-core](https://pypi.org/project/tigrcorn-core/) | [tigrcorn-config](https://pypi.org/project/tigrcorn-config/) | [tigrcorn-asgi](https://pypi.org/project/tigrcorn-asgi/) | [tigrcorn-contract](https://pypi.org/project/tigrcorn-contract/) | [tigrcorn-transports](https://pypi.org/project/tigrcorn-transports/) | [tigrcorn-protocols](https://pypi.org/project/tigrcorn-protocols/) | [tigrcorn-http](https://pypi.org/project/tigrcorn-http/) | [tigrcorn-security](https://pypi.org/project/tigrcorn-security/) | [tigrcorn-runtime](https://pypi.org/project/tigrcorn-runtime/) | [tigrcorn-static](https://pypi.org/project/tigrcorn-static/) | [tigrcorn-observability](https://pypi.org/project/tigrcorn-observability/) | [tigrcorn-compat](https://pypi.org/project/tigrcorn-compat/) | [tigrcorn-certification](https://pypi.org/project/tigrcorn-certification/)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
tigrcorn_observability/__init__.py,sha256=uzT17-65ZfvM3GF9HaKwtpkAiw0RA6zy3-IOL9ligzQ,40
|
|
2
|
+
tigrcorn_observability/events.py,sha256=AvlCLkxztUquuf7j5IPdRh0aKSKbePmpnIVQIqwf9xY,749
|
|
3
|
+
tigrcorn_observability/logging.py,sha256=Yo3n0AfP_8Ldwrqerr-00FDOhngoMSXXfcNTbCw--wA,12196
|
|
4
|
+
tigrcorn_observability/metrics.py,sha256=64dnNMGR7-A8O_yBQYiPj-SwkgdEibENGAVmidCY9Q4,13830
|
|
5
|
+
tigrcorn_observability/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
6
|
+
tigrcorn_observability/tracing.py,sha256=DNwfmAr45izrMtDCQwmx961Rs2UoFda8inpOad-dbYk,6600
|
|
7
|
+
tigrcorn_observability-0.3.16.dev5.dist-info/licenses/LICENSE,sha256=xhBSirl227aDQNeQ8tk2v_yiU9nbQpJ4EZp6OtATX-s,9591
|
|
8
|
+
tigrcorn_observability-0.3.16.dev5.dist-info/METADATA,sha256=eVLuEtyW90UljRAXK6iRtxqZ2ImhGgfkDqSbeUR7spw,15866
|
|
9
|
+
tigrcorn_observability-0.3.16.dev5.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
10
|
+
tigrcorn_observability-0.3.16.dev5.dist-info/top_level.txt,sha256=h4gAnmVbhRM9JHPNrpLglQZii7bWoLAo1UB5KeCNjbc,23
|
|
11
|
+
tigrcorn_observability-0.3.16.dev5.dist-info/RECORD,,
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the
|
|
13
|
+
copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
16
|
+
entities that control, are controlled by, or are under common control with
|
|
17
|
+
that entity. For the purposes of this definition, "control" means (i) the
|
|
18
|
+
power, direct or indirect, to cause the direction or management of such
|
|
19
|
+
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
|
|
20
|
+
(50%) or more of the outstanding shares, or (iii) beneficial ownership of
|
|
21
|
+
such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation source, and
|
|
28
|
+
configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical transformation
|
|
31
|
+
or translation of a Source form, including but not limited to compiled object
|
|
32
|
+
code, generated documentation, and conversions to other media types.
|
|
33
|
+
|
|
34
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
35
|
+
made available under the License, as indicated by a copyright notice that is
|
|
36
|
+
included in or attached to the work (an example is provided in the Appendix
|
|
37
|
+
below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object form,
|
|
40
|
+
that is based on (or derived from) the Work and for which the editorial
|
|
41
|
+
revisions, annotations, elaborations, or other modifications represent, as a
|
|
42
|
+
whole, an original work of authorship. For the purposes of this License,
|
|
43
|
+
Derivative Works shall not include works that remain separable from, or
|
|
44
|
+
merely link (or bind by name) to the interfaces of, the Work and Derivative
|
|
45
|
+
Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
48
|
+
version of the Work and any modifications or additions to that Work or
|
|
49
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
50
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
51
|
+
Entity authorized to submit on behalf of the copyright owner. For the
|
|
52
|
+
purposes of this definition, "submitted" means any form of electronic,
|
|
53
|
+
verbal, or written communication sent to the Licensor or its representatives,
|
|
54
|
+
including but not limited to communication on electronic mailing lists,
|
|
55
|
+
source code control systems, and issue tracking systems that are managed by,
|
|
56
|
+
or on behalf of, the Licensor for the purpose of discussing and improving the
|
|
57
|
+
Work, but excluding communication that is conspicuously marked or otherwise
|
|
58
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
59
|
+
|
|
60
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on
|
|
61
|
+
behalf of whom a Contribution has been received by Licensor and subsequently
|
|
62
|
+
incorporated within the Work.
|
|
63
|
+
|
|
64
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
65
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
66
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
67
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
68
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
69
|
+
Object form.
|
|
70
|
+
|
|
71
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
72
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
73
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
74
|
+
section) patent license to make, have made, use, offer to sell, sell, import,
|
|
75
|
+
and otherwise transfer the Work, where such license applies only to those
|
|
76
|
+
patent claims licensable by such Contributor that are necessarily infringed by
|
|
77
|
+
their Contribution(s) alone or by combination of their Contribution(s) with
|
|
78
|
+
the Work to which such Contribution(s) was submitted. If You institute patent
|
|
79
|
+
litigation against any entity (including a cross-claim or counterclaim in a
|
|
80
|
+
lawsuit) alleging that the Work or a Contribution incorporated within the Work
|
|
81
|
+
constitutes direct or contributory patent infringement, then any patent
|
|
82
|
+
licenses granted to You under this License for that Work shall terminate as of
|
|
83
|
+
the date such litigation is filed.
|
|
84
|
+
|
|
85
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
86
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
87
|
+
Source or Object form, provided that You meet the following conditions:
|
|
88
|
+
|
|
89
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
90
|
+
of this License; and
|
|
91
|
+
|
|
92
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
93
|
+
You changed the files; and
|
|
94
|
+
|
|
95
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
96
|
+
distribute, all copyright, patent, trademark, and attribution notices
|
|
97
|
+
from the Source form of the Work, excluding those notices that do not
|
|
98
|
+
pertain to any part of the Derivative Works; and
|
|
99
|
+
|
|
100
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
101
|
+
then any Derivative Works that You distribute must include a readable copy
|
|
102
|
+
of the attribution notices contained within such NOTICE file, excluding
|
|
103
|
+
those notices that do not pertain to any part of the Derivative Works, in
|
|
104
|
+
at least one of the following places: within a NOTICE text file distributed
|
|
105
|
+
as part of the Derivative Works; within the Source form or documentation,
|
|
106
|
+
if provided along with the Derivative Works; or, within a display generated
|
|
107
|
+
by the Derivative Works, if and wherever such third-party notices normally
|
|
108
|
+
appear. The contents of the NOTICE file are for informational purposes only
|
|
109
|
+
and do not modify the License. You may add Your own attribution notices
|
|
110
|
+
within Derivative Works that You distribute, alongside or as an addendum to
|
|
111
|
+
the NOTICE text from the Work, provided that such additional attribution
|
|
112
|
+
notices cannot be construed as modifying the License.
|
|
113
|
+
|
|
114
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
115
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
116
|
+
distribution of Your modifications, or for any such Derivative Works as a
|
|
117
|
+
whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
118
|
+
complies with the conditions stated in this License.
|
|
119
|
+
|
|
120
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
121
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
122
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
123
|
+
additional terms or conditions. Notwithstanding the above, nothing herein
|
|
124
|
+
shall supersede or modify the terms of any separate license agreement you may
|
|
125
|
+
have executed with Licensor regarding such Contributions.
|
|
126
|
+
|
|
127
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
128
|
+
trademarks, service marks, or product names of the Licensor, except as
|
|
129
|
+
required for reasonable and customary use in describing the origin of the Work
|
|
130
|
+
and reproducing the content of the NOTICE file.
|
|
131
|
+
|
|
132
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
133
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
134
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
135
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
136
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
137
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
138
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
139
|
+
associated with Your exercise of permissions under this License.
|
|
140
|
+
|
|
141
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
142
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
143
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
144
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
145
|
+
direct, indirect, special, incidental, or consequential damages of any
|
|
146
|
+
character arising as a result of this License or out of the use or inability
|
|
147
|
+
to use the Work (including but not limited to damages for loss of goodwill,
|
|
148
|
+
work stoppage, computer failure or malfunction, or any and all other
|
|
149
|
+
commercial damages or losses), even if such Contributor has been advised of
|
|
150
|
+
the possibility of such damages.
|
|
151
|
+
|
|
152
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
153
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
154
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
155
|
+
and/or rights consistent with this License. However, in accepting such
|
|
156
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
157
|
+
responsibility, not on behalf of any other Contributor, and only if You agree
|
|
158
|
+
to indemnify, defend, and hold each Contributor harmless for any liability
|
|
159
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
160
|
+
accepting any such warranty or additional liability.
|
|
161
|
+
|
|
162
|
+
END OF TERMS AND CONDITIONS
|
|
163
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tigrcorn_observability
|