provide-foundation 0.0.0.dev0__py3-none-any.whl → 0.0.0.dev2__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.
- provide/foundation/__init__.py +41 -23
- provide/foundation/archive/__init__.py +23 -0
- provide/foundation/archive/base.py +70 -0
- provide/foundation/archive/bzip2.py +157 -0
- provide/foundation/archive/gzip.py +159 -0
- provide/foundation/archive/operations.py +334 -0
- provide/foundation/archive/tar.py +164 -0
- provide/foundation/archive/zip.py +203 -0
- provide/foundation/cli/__init__.py +2 -2
- provide/foundation/cli/commands/deps.py +13 -7
- provide/foundation/cli/commands/logs/__init__.py +1 -1
- provide/foundation/cli/commands/logs/query.py +1 -1
- provide/foundation/cli/commands/logs/send.py +1 -1
- provide/foundation/cli/commands/logs/tail.py +1 -1
- provide/foundation/cli/decorators.py +11 -10
- provide/foundation/cli/main.py +1 -1
- provide/foundation/cli/testing.py +2 -35
- provide/foundation/cli/utils.py +21 -17
- provide/foundation/config/__init__.py +35 -2
- provide/foundation/config/base.py +2 -2
- provide/foundation/config/converters.py +479 -0
- provide/foundation/config/defaults.py +67 -0
- provide/foundation/config/env.py +4 -19
- provide/foundation/config/loader.py +9 -3
- provide/foundation/config/sync.py +19 -4
- provide/foundation/console/input.py +5 -5
- provide/foundation/console/output.py +35 -13
- provide/foundation/context/__init__.py +8 -4
- provide/foundation/context/core.py +85 -109
- provide/foundation/core.py +1 -2
- provide/foundation/crypto/__init__.py +2 -0
- provide/foundation/crypto/certificates/__init__.py +34 -0
- provide/foundation/crypto/certificates/base.py +173 -0
- provide/foundation/crypto/certificates/certificate.py +290 -0
- provide/foundation/crypto/certificates/factory.py +213 -0
- provide/foundation/crypto/certificates/generator.py +138 -0
- provide/foundation/crypto/certificates/loader.py +130 -0
- provide/foundation/crypto/certificates/operations.py +198 -0
- provide/foundation/crypto/certificates/trust.py +107 -0
- provide/foundation/errors/__init__.py +2 -3
- provide/foundation/errors/decorators.py +0 -231
- provide/foundation/errors/types.py +0 -97
- provide/foundation/eventsets/__init__.py +0 -0
- provide/foundation/eventsets/display.py +84 -0
- provide/foundation/eventsets/registry.py +160 -0
- provide/foundation/eventsets/resolver.py +192 -0
- provide/foundation/eventsets/sets/das.py +128 -0
- provide/foundation/eventsets/sets/database.py +125 -0
- provide/foundation/eventsets/sets/http.py +153 -0
- provide/foundation/eventsets/sets/llm.py +139 -0
- provide/foundation/eventsets/sets/task_queue.py +107 -0
- provide/foundation/eventsets/types.py +70 -0
- provide/foundation/file/directory.py +13 -22
- provide/foundation/file/lock.py +3 -1
- provide/foundation/hub/components.py +77 -515
- provide/foundation/hub/config.py +151 -0
- provide/foundation/hub/discovery.py +62 -0
- provide/foundation/hub/handlers.py +81 -0
- provide/foundation/hub/lifecycle.py +194 -0
- provide/foundation/hub/manager.py +4 -4
- provide/foundation/hub/processors.py +44 -0
- provide/foundation/integrations/__init__.py +11 -0
- provide/foundation/{observability → integrations}/openobserve/__init__.py +10 -7
- provide/foundation/{observability → integrations}/openobserve/auth.py +1 -1
- provide/foundation/{observability → integrations}/openobserve/client.py +12 -12
- provide/foundation/{observability → integrations}/openobserve/commands.py +3 -3
- provide/foundation/integrations/openobserve/config.py +37 -0
- provide/foundation/{observability → integrations}/openobserve/formatters.py +1 -1
- provide/foundation/{observability → integrations}/openobserve/otlp.py +1 -1
- provide/foundation/{observability → integrations}/openobserve/search.py +2 -2
- provide/foundation/{observability → integrations}/openobserve/streaming.py +4 -4
- provide/foundation/logger/__init__.py +3 -10
- provide/foundation/logger/config/logging.py +68 -298
- provide/foundation/logger/config/telemetry.py +41 -121
- provide/foundation/logger/core.py +0 -2
- provide/foundation/logger/custom_processors.py +1 -0
- provide/foundation/logger/factories.py +11 -2
- provide/foundation/logger/processors/main.py +20 -84
- provide/foundation/logger/setup/__init__.py +5 -1
- provide/foundation/logger/setup/coordinator.py +76 -24
- provide/foundation/logger/setup/processors.py +2 -9
- provide/foundation/logger/trace.py +27 -0
- provide/foundation/metrics/otel.py +10 -10
- provide/foundation/observability/__init__.py +2 -2
- provide/foundation/process/__init__.py +9 -0
- provide/foundation/process/exit.py +47 -0
- provide/foundation/process/lifecycle.py +115 -59
- provide/foundation/resilience/__init__.py +35 -0
- provide/foundation/resilience/circuit.py +164 -0
- provide/foundation/resilience/decorators.py +220 -0
- provide/foundation/resilience/fallback.py +193 -0
- provide/foundation/resilience/retry.py +325 -0
- provide/foundation/streams/config.py +79 -0
- provide/foundation/streams/console.py +7 -8
- provide/foundation/streams/core.py +6 -3
- provide/foundation/streams/file.py +12 -2
- provide/foundation/testing/__init__.py +84 -2
- provide/foundation/testing/archive/__init__.py +24 -0
- provide/foundation/testing/archive/fixtures.py +217 -0
- provide/foundation/testing/cli.py +30 -17
- provide/foundation/testing/common/__init__.py +32 -0
- provide/foundation/testing/common/fixtures.py +236 -0
- provide/foundation/testing/file/__init__.py +40 -0
- provide/foundation/testing/file/content_fixtures.py +316 -0
- provide/foundation/testing/file/directory_fixtures.py +107 -0
- provide/foundation/testing/file/fixtures.py +52 -0
- provide/foundation/testing/file/special_fixtures.py +153 -0
- provide/foundation/testing/logger.py +117 -11
- provide/foundation/testing/mocking/__init__.py +46 -0
- provide/foundation/testing/mocking/fixtures.py +331 -0
- provide/foundation/testing/process/__init__.py +48 -0
- provide/foundation/testing/process/async_fixtures.py +405 -0
- provide/foundation/testing/process/fixtures.py +56 -0
- provide/foundation/testing/process/subprocess_fixtures.py +209 -0
- provide/foundation/testing/threading/__init__.py +38 -0
- provide/foundation/testing/threading/basic_fixtures.py +101 -0
- provide/foundation/testing/threading/data_fixtures.py +99 -0
- provide/foundation/testing/threading/execution_fixtures.py +263 -0
- provide/foundation/testing/threading/fixtures.py +54 -0
- provide/foundation/testing/threading/sync_fixtures.py +97 -0
- provide/foundation/testing/time/__init__.py +32 -0
- provide/foundation/testing/time/fixtures.py +409 -0
- provide/foundation/testing/transport/__init__.py +30 -0
- provide/foundation/testing/transport/fixtures.py +280 -0
- provide/foundation/tools/__init__.py +58 -0
- provide/foundation/tools/base.py +348 -0
- provide/foundation/tools/cache.py +268 -0
- provide/foundation/tools/downloader.py +224 -0
- provide/foundation/tools/installer.py +254 -0
- provide/foundation/tools/registry.py +223 -0
- provide/foundation/tools/resolver.py +321 -0
- provide/foundation/tools/verifier.py +186 -0
- provide/foundation/tracer/otel.py +7 -11
- provide/foundation/tracer/spans.py +2 -2
- provide/foundation/transport/__init__.py +155 -0
- provide/foundation/transport/base.py +171 -0
- provide/foundation/transport/client.py +266 -0
- provide/foundation/transport/config.py +140 -0
- provide/foundation/transport/errors.py +79 -0
- provide/foundation/transport/http.py +232 -0
- provide/foundation/transport/middleware.py +360 -0
- provide/foundation/transport/registry.py +167 -0
- provide/foundation/transport/types.py +45 -0
- provide/foundation/utils/deps.py +14 -12
- provide/foundation/utils/parsing.py +49 -4
- {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev2.dist-info}/METADATA +5 -28
- provide_foundation-0.0.0.dev2.dist-info/RECORD +225 -0
- provide/foundation/cli/commands/logs/generate_old.py +0 -569
- provide/foundation/crypto/certificates.py +0 -896
- provide/foundation/logger/emoji/__init__.py +0 -44
- provide/foundation/logger/emoji/matrix.py +0 -209
- provide/foundation/logger/emoji/sets.py +0 -458
- provide/foundation/logger/emoji/types.py +0 -56
- provide/foundation/logger/setup/emoji_resolver.py +0 -64
- provide_foundation-0.0.0.dev0.dist-info/RECORD +0 -149
- /provide/foundation/{observability → integrations}/openobserve/exceptions.py +0 -0
- /provide/foundation/{observability → integrations}/openobserve/models.py +0 -0
- {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev2.dist-info}/WHEEL +0 -0
- {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev2.dist-info}/entry_points.txt +0 -0
- {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev2.dist-info}/licenses/LICENSE +0 -0
- {provide_foundation-0.0.0.dev0.dist-info → provide_foundation-0.0.0.dev2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
"""
|
2
|
+
Event set resolution and enrichment logic.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import Any
|
6
|
+
|
7
|
+
from provide.foundation.eventsets.registry import get_registry
|
8
|
+
from provide.foundation.eventsets.types import EventMapping, EventSet, FieldMapping
|
9
|
+
|
10
|
+
|
11
|
+
class EventSetResolver:
|
12
|
+
"""
|
13
|
+
Resolves and applies event set enrichments to log events.
|
14
|
+
"""
|
15
|
+
|
16
|
+
def __init__(self) -> None:
|
17
|
+
"""Initialize the resolver with cached configurations."""
|
18
|
+
self._field_mappings: list[FieldMapping] = []
|
19
|
+
self._event_mappings_by_set: dict[str, list[EventMapping]] = {}
|
20
|
+
self._resolved = False
|
21
|
+
|
22
|
+
def resolve(self) -> None:
|
23
|
+
"""
|
24
|
+
Resolve all registered event sets into a unified configuration.
|
25
|
+
|
26
|
+
This merges all registered event sets by priority, building
|
27
|
+
the field mapping and event mapping lookup tables.
|
28
|
+
"""
|
29
|
+
registry = get_registry()
|
30
|
+
event_sets = registry.list_event_sets() # Already sorted by priority
|
31
|
+
|
32
|
+
# Clear existing state
|
33
|
+
self._field_mappings.clear()
|
34
|
+
self._event_mappings_by_set.clear()
|
35
|
+
|
36
|
+
# Process each event set in priority order
|
37
|
+
for event_set in event_sets:
|
38
|
+
# Store event mappings by event set name
|
39
|
+
self._event_mappings_by_set[event_set.name] = event_set.mappings
|
40
|
+
|
41
|
+
# Add field mappings
|
42
|
+
self._field_mappings.extend(event_set.field_mappings)
|
43
|
+
|
44
|
+
self._resolved = True
|
45
|
+
|
46
|
+
def enrich_event(self, event_dict: dict[str, Any]) -> dict[str, Any]:
|
47
|
+
"""
|
48
|
+
Enrich a log event with event set data.
|
49
|
+
|
50
|
+
Args:
|
51
|
+
event_dict: The event dictionary to enrich
|
52
|
+
|
53
|
+
Returns:
|
54
|
+
The enriched event dictionary
|
55
|
+
"""
|
56
|
+
if not self._resolved:
|
57
|
+
self.resolve()
|
58
|
+
|
59
|
+
enrichments = []
|
60
|
+
|
61
|
+
# Process each field in the event
|
62
|
+
for field_key, field_value in list(event_dict.items()):
|
63
|
+
if field_key == "event" or field_value is None:
|
64
|
+
continue
|
65
|
+
|
66
|
+
# Find appropriate event mapping for this field
|
67
|
+
event_mapping = self._find_event_mapping_for_field(field_key, field_value)
|
68
|
+
if not event_mapping:
|
69
|
+
continue
|
70
|
+
|
71
|
+
value_str = str(field_value).lower()
|
72
|
+
|
73
|
+
# Apply transformations
|
74
|
+
if value_str in event_mapping.transformations:
|
75
|
+
field_value = event_mapping.transformations[value_str](field_value)
|
76
|
+
value_str = str(field_value).lower()
|
77
|
+
|
78
|
+
# Get visual marker
|
79
|
+
visual_marker = event_mapping.visual_markers.get(
|
80
|
+
value_str,
|
81
|
+
event_mapping.visual_markers.get(event_mapping.default_key, "")
|
82
|
+
)
|
83
|
+
|
84
|
+
if visual_marker:
|
85
|
+
enrichments.append(visual_marker)
|
86
|
+
|
87
|
+
# Apply metadata fields
|
88
|
+
if value_str in event_mapping.metadata_fields:
|
89
|
+
for meta_key, meta_value in event_mapping.metadata_fields[value_str].items():
|
90
|
+
if meta_key not in event_dict:
|
91
|
+
event_dict[meta_key] = meta_value
|
92
|
+
|
93
|
+
# Add visual enrichments to event message
|
94
|
+
if enrichments:
|
95
|
+
prefix = "".join(f"[{e}]" for e in enrichments)
|
96
|
+
event_msg = event_dict.get("event", "")
|
97
|
+
event_dict["event"] = f"{prefix} {event_msg}" if event_msg else prefix
|
98
|
+
|
99
|
+
return event_dict
|
100
|
+
|
101
|
+
def _find_event_mapping_for_field(self, field_key: str, field_value: Any) -> EventMapping | None:
|
102
|
+
"""
|
103
|
+
Find the appropriate EventMapping for a given field.
|
104
|
+
|
105
|
+
This method uses a heuristic approach to match field keys to EventMappings:
|
106
|
+
1. Direct field name mapping (e.g., "domain" -> "domain" mapping)
|
107
|
+
2. Field prefix mapping (e.g., "http.method" -> "http_method" mapping)
|
108
|
+
3. Field pattern matching
|
109
|
+
"""
|
110
|
+
# First check for direct field name matches
|
111
|
+
simple_key = field_key.split('.')[-1] # Get last part of dotted key
|
112
|
+
|
113
|
+
for event_set_name, mappings in self._event_mappings_by_set.items():
|
114
|
+
for mapping in mappings:
|
115
|
+
# Direct name match
|
116
|
+
if mapping.name == simple_key or mapping.name == field_key:
|
117
|
+
return mapping
|
118
|
+
|
119
|
+
# Pattern matching for common cases
|
120
|
+
if field_key.startswith("http.") and mapping.name.startswith("http_"):
|
121
|
+
if field_key.replace(".", "_") == mapping.name:
|
122
|
+
return mapping
|
123
|
+
|
124
|
+
if field_key.startswith("llm.") and mapping.name.startswith("llm_"):
|
125
|
+
if field_key.replace(".", "_") == mapping.name:
|
126
|
+
return mapping
|
127
|
+
|
128
|
+
if field_key.startswith("db.") and mapping.name.startswith("db_"):
|
129
|
+
if field_key.replace(".", "_") == mapping.name:
|
130
|
+
return mapping
|
131
|
+
|
132
|
+
if field_key.startswith("task.") and mapping.name.startswith("task_"):
|
133
|
+
if field_key.replace(".", "_") == mapping.name:
|
134
|
+
return mapping
|
135
|
+
|
136
|
+
return None
|
137
|
+
|
138
|
+
def get_visual_markers(self, event_dict: dict[str, Any]) -> list[str]:
|
139
|
+
"""
|
140
|
+
Extract visual markers for an event without modifying it.
|
141
|
+
|
142
|
+
Args:
|
143
|
+
event_dict: The event dictionary to analyze
|
144
|
+
|
145
|
+
Returns:
|
146
|
+
List of visual markers that would be applied
|
147
|
+
"""
|
148
|
+
if not self._resolved:
|
149
|
+
self.resolve()
|
150
|
+
|
151
|
+
markers = []
|
152
|
+
|
153
|
+
for field_key, field_value in event_dict.items():
|
154
|
+
if field_key == "event" or field_value is None:
|
155
|
+
continue
|
156
|
+
|
157
|
+
event_mapping = self._find_event_mapping_for_field(field_key, field_value)
|
158
|
+
if not event_mapping:
|
159
|
+
continue
|
160
|
+
|
161
|
+
value_str = str(field_value).lower()
|
162
|
+
marker = event_mapping.visual_markers.get(
|
163
|
+
value_str,
|
164
|
+
event_mapping.visual_markers.get(event_mapping.default_key, "")
|
165
|
+
)
|
166
|
+
|
167
|
+
if marker:
|
168
|
+
markers.append(marker)
|
169
|
+
|
170
|
+
return markers
|
171
|
+
|
172
|
+
|
173
|
+
# Global resolver instance
|
174
|
+
_resolver = EventSetResolver()
|
175
|
+
|
176
|
+
|
177
|
+
def get_resolver() -> EventSetResolver:
|
178
|
+
"""Get the global event set resolver instance."""
|
179
|
+
return _resolver
|
180
|
+
|
181
|
+
|
182
|
+
def enrich_event(event_dict: dict[str, Any]) -> dict[str, Any]:
|
183
|
+
"""
|
184
|
+
Enrich a log event with event set data.
|
185
|
+
|
186
|
+
Args:
|
187
|
+
event_dict: The event dictionary to enrich
|
188
|
+
|
189
|
+
Returns:
|
190
|
+
The enriched event dictionary
|
191
|
+
"""
|
192
|
+
return _resolver.enrich_event(event_dict)
|
@@ -0,0 +1,128 @@
|
|
1
|
+
"""
|
2
|
+
Domain-Action-Status (DAS) event set.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from provide.foundation.eventsets.types import EventMapping, EventSet, FieldMapping
|
6
|
+
|
7
|
+
EVENT_SET = EventSet(
|
8
|
+
name="default",
|
9
|
+
description="Core Domain-Action-Status event enrichment",
|
10
|
+
mappings=[
|
11
|
+
EventMapping(
|
12
|
+
name="domain",
|
13
|
+
visual_markers={
|
14
|
+
"system": "⚙️",
|
15
|
+
"server": "🛎️",
|
16
|
+
"client": "🙋",
|
17
|
+
"network": "🌐",
|
18
|
+
"security": "🔐",
|
19
|
+
"config": "🔩",
|
20
|
+
"database": "🗄️",
|
21
|
+
"cache": "💾",
|
22
|
+
"task": "🔄",
|
23
|
+
"plugin": "🔌",
|
24
|
+
"telemetry": "🛰️",
|
25
|
+
"di": "💉",
|
26
|
+
"protocol": "📡",
|
27
|
+
"file": "📄",
|
28
|
+
"user": "👤",
|
29
|
+
"test": "🧪",
|
30
|
+
"utils": "🧰",
|
31
|
+
"core": "🌟",
|
32
|
+
"auth": "🔑",
|
33
|
+
"entity": "🦎",
|
34
|
+
"report": "📈",
|
35
|
+
"payment": "💳",
|
36
|
+
"default": "❓",
|
37
|
+
},
|
38
|
+
default_key="default"
|
39
|
+
),
|
40
|
+
EventMapping(
|
41
|
+
name="action",
|
42
|
+
visual_markers={
|
43
|
+
"init": "🌱",
|
44
|
+
"start": "🚀",
|
45
|
+
"stop": "🛑",
|
46
|
+
"connect": "🔗",
|
47
|
+
"disconnect": "💔",
|
48
|
+
"listen": "👂",
|
49
|
+
"send": "📤",
|
50
|
+
"receive": "📥",
|
51
|
+
"read": "📖",
|
52
|
+
"write": "📝",
|
53
|
+
"process": "⚙️",
|
54
|
+
"validate": "🛡️",
|
55
|
+
"execute": "▶️",
|
56
|
+
"query": "🔍",
|
57
|
+
"update": "🔄",
|
58
|
+
"delete": "🗑️",
|
59
|
+
"login": "➡️",
|
60
|
+
"logout": "⬅️",
|
61
|
+
"auth": "🔑",
|
62
|
+
"error": "🔥",
|
63
|
+
"encrypt": "🛡️",
|
64
|
+
"decrypt": "🔓",
|
65
|
+
"parse": "🧩",
|
66
|
+
"transmit": "📡",
|
67
|
+
"build": "🏗️",
|
68
|
+
"schedule": "📅",
|
69
|
+
"emit": "📢",
|
70
|
+
"load": "💡",
|
71
|
+
"observe": "🧐",
|
72
|
+
"request": "🗣️",
|
73
|
+
"interrupt": "🚦",
|
74
|
+
"register": "⚙️",
|
75
|
+
"default": "❓",
|
76
|
+
},
|
77
|
+
default_key="default"
|
78
|
+
),
|
79
|
+
EventMapping(
|
80
|
+
name="status",
|
81
|
+
visual_markers={
|
82
|
+
"success": "✅",
|
83
|
+
"failure": "❌",
|
84
|
+
"error": "🔥",
|
85
|
+
"warning": "⚠️",
|
86
|
+
"info": "ℹ️",
|
87
|
+
"debug": "🐞",
|
88
|
+
"trace": "👣",
|
89
|
+
"attempt": "⏳",
|
90
|
+
"retry": "🔁",
|
91
|
+
"skip": "⏭️",
|
92
|
+
"complete": "🏁",
|
93
|
+
"timeout": "⏱️",
|
94
|
+
"notfound": "❓",
|
95
|
+
"unauthorized": "🚫",
|
96
|
+
"invalid": "💢",
|
97
|
+
"cached": "🎯",
|
98
|
+
"ongoing": "🏃",
|
99
|
+
"idle": "💤",
|
100
|
+
"ready": "👍",
|
101
|
+
"default": "➡️",
|
102
|
+
},
|
103
|
+
default_key="default"
|
104
|
+
),
|
105
|
+
],
|
106
|
+
field_mappings=[
|
107
|
+
FieldMapping(
|
108
|
+
log_key="domain",
|
109
|
+
event_set_name="default",
|
110
|
+
description="System domain or component"
|
111
|
+
),
|
112
|
+
FieldMapping(
|
113
|
+
log_key="action",
|
114
|
+
event_set_name="default",
|
115
|
+
description="Action being performed"
|
116
|
+
),
|
117
|
+
FieldMapping(
|
118
|
+
log_key="status",
|
119
|
+
event_set_name="default",
|
120
|
+
description="Status or outcome of the action"
|
121
|
+
),
|
122
|
+
],
|
123
|
+
priority=0
|
124
|
+
)
|
125
|
+
|
126
|
+
# Alias for backward compatibility
|
127
|
+
das_event_set = EVENT_SET
|
128
|
+
default_event_set = EVENT_SET
|
@@ -0,0 +1,125 @@
|
|
1
|
+
"""
|
2
|
+
Database operations event set for Foundation.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from provide.foundation.eventsets.types import EventSet, EventMapping, FieldMapping
|
6
|
+
|
7
|
+
EVENT_SET = EventSet(
|
8
|
+
name="database",
|
9
|
+
description="Database interaction and query enrichment",
|
10
|
+
mappings=[
|
11
|
+
EventMapping(
|
12
|
+
name="db_system",
|
13
|
+
visual_markers={
|
14
|
+
"postgres": "🐘",
|
15
|
+
"mysql": "🐬",
|
16
|
+
"sqlite": "💾",
|
17
|
+
"mongodb": "🍃",
|
18
|
+
"redis": "🟥",
|
19
|
+
"elasticsearch": "🔍",
|
20
|
+
"default": "🗄️",
|
21
|
+
},
|
22
|
+
metadata_fields={
|
23
|
+
"postgres": {"db.type": "sql", "db.vendor": "postgresql"},
|
24
|
+
"mysql": {"db.type": "sql", "db.vendor": "mysql"},
|
25
|
+
"sqlite": {"db.type": "sql", "db.vendor": "sqlite"},
|
26
|
+
"mongodb": {"db.type": "nosql", "db.vendor": "mongodb"},
|
27
|
+
"redis": {"db.type": "cache", "db.vendor": "redis"},
|
28
|
+
"elasticsearch": {"db.type": "search", "db.vendor": "elastic"},
|
29
|
+
},
|
30
|
+
default_key="default"
|
31
|
+
),
|
32
|
+
EventMapping(
|
33
|
+
name="db_operation",
|
34
|
+
visual_markers={
|
35
|
+
"query": "🔍",
|
36
|
+
"select": "🔍",
|
37
|
+
"insert": "➕",
|
38
|
+
"update": "🔄",
|
39
|
+
"delete": "🗑️",
|
40
|
+
"connect": "🔗",
|
41
|
+
"disconnect": "💔",
|
42
|
+
"transaction_begin": "💳🟢",
|
43
|
+
"transaction_commit": "💳✅",
|
44
|
+
"transaction_rollback": "💳❌",
|
45
|
+
"default": "⚙️",
|
46
|
+
},
|
47
|
+
metadata_fields={
|
48
|
+
"select": {"db.read": True},
|
49
|
+
"query": {"db.read": True},
|
50
|
+
"insert": {"db.write": True},
|
51
|
+
"update": {"db.write": True},
|
52
|
+
"delete": {"db.write": True},
|
53
|
+
},
|
54
|
+
default_key="default"
|
55
|
+
),
|
56
|
+
EventMapping(
|
57
|
+
name="db_outcome",
|
58
|
+
visual_markers={
|
59
|
+
"success": "👍",
|
60
|
+
"error": "🔥",
|
61
|
+
"not_found": "❓🤷",
|
62
|
+
"timeout": "⏱️",
|
63
|
+
"default": "➡️",
|
64
|
+
},
|
65
|
+
metadata_fields={
|
66
|
+
"success": {"db.success": True},
|
67
|
+
"error": {"db.error": True},
|
68
|
+
"timeout": {"db.timeout": True},
|
69
|
+
},
|
70
|
+
default_key="default"
|
71
|
+
),
|
72
|
+
],
|
73
|
+
field_mappings=[
|
74
|
+
FieldMapping(
|
75
|
+
log_key="db.system",
|
76
|
+
event_set_name="database",
|
77
|
+
description="Database system type",
|
78
|
+
value_type="string"
|
79
|
+
),
|
80
|
+
FieldMapping(
|
81
|
+
log_key="db.operation",
|
82
|
+
event_set_name="database",
|
83
|
+
description="Database operation performed",
|
84
|
+
value_type="string"
|
85
|
+
),
|
86
|
+
FieldMapping(
|
87
|
+
log_key="db.outcome",
|
88
|
+
event_set_name="database",
|
89
|
+
description="Operation outcome",
|
90
|
+
value_type="string"
|
91
|
+
),
|
92
|
+
FieldMapping(
|
93
|
+
log_key="db.statement",
|
94
|
+
event_set_name="database",
|
95
|
+
description="SQL or query statement",
|
96
|
+
value_type="string"
|
97
|
+
),
|
98
|
+
FieldMapping(
|
99
|
+
log_key="db.table",
|
100
|
+
event_set_name="database",
|
101
|
+
description="Table name",
|
102
|
+
value_type="string",
|
103
|
+
default_override_key="default"
|
104
|
+
),
|
105
|
+
FieldMapping(
|
106
|
+
log_key="db.rows_affected",
|
107
|
+
event_set_name="database",
|
108
|
+
description="Number of rows affected",
|
109
|
+
value_type="integer"
|
110
|
+
),
|
111
|
+
FieldMapping(
|
112
|
+
log_key="duration_ms",
|
113
|
+
event_set_name="database",
|
114
|
+
description="Query duration in milliseconds",
|
115
|
+
value_type="integer"
|
116
|
+
),
|
117
|
+
FieldMapping(
|
118
|
+
log_key="trace_id",
|
119
|
+
event_set_name="database",
|
120
|
+
description="Distributed trace ID",
|
121
|
+
value_type="string"
|
122
|
+
),
|
123
|
+
],
|
124
|
+
priority=90
|
125
|
+
)
|
@@ -0,0 +1,153 @@
|
|
1
|
+
"""
|
2
|
+
HTTP request/response event set for Foundation.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from provide.foundation.eventsets.types import EventMapping, EventSet, FieldMapping
|
6
|
+
|
7
|
+
EVENT_SET = EventSet(
|
8
|
+
name="http",
|
9
|
+
description="HTTP client and server interaction enrichment",
|
10
|
+
mappings=[
|
11
|
+
EventMapping(
|
12
|
+
name="http_method",
|
13
|
+
visual_markers={
|
14
|
+
"get": "📥",
|
15
|
+
"post": "📤",
|
16
|
+
"put": "📝⬆️",
|
17
|
+
"delete": "🗑️",
|
18
|
+
"patch": "🩹",
|
19
|
+
"head": "👤❔",
|
20
|
+
"options": "⚙️❔",
|
21
|
+
"default": "🌐",
|
22
|
+
},
|
23
|
+
default_key="default"
|
24
|
+
),
|
25
|
+
EventMapping(
|
26
|
+
name="http_status_class",
|
27
|
+
visual_markers={
|
28
|
+
"1xx": "ℹ️",
|
29
|
+
"2xx": "✅",
|
30
|
+
"3xx": "↪️",
|
31
|
+
"4xx": "⚠️CLIENT",
|
32
|
+
"5xx": "🔥SERVER",
|
33
|
+
"default": "❓",
|
34
|
+
},
|
35
|
+
metadata_fields={
|
36
|
+
"2xx": {"http.success": True},
|
37
|
+
"4xx": {"http.client_error": True},
|
38
|
+
"5xx": {"http.server_error": True},
|
39
|
+
},
|
40
|
+
default_key="default"
|
41
|
+
),
|
42
|
+
EventMapping(
|
43
|
+
name="http_target_type",
|
44
|
+
visual_markers={
|
45
|
+
"path": "🛣️",
|
46
|
+
"query": "❓",
|
47
|
+
"fragment": "#️⃣",
|
48
|
+
"default": "🎯",
|
49
|
+
},
|
50
|
+
default_key="default"
|
51
|
+
),
|
52
|
+
],
|
53
|
+
field_mappings=[
|
54
|
+
FieldMapping(
|
55
|
+
log_key="http.method",
|
56
|
+
event_set_name="http",
|
57
|
+
description="HTTP request method",
|
58
|
+
value_type="string"
|
59
|
+
),
|
60
|
+
FieldMapping(
|
61
|
+
log_key="http.status_class",
|
62
|
+
event_set_name="http",
|
63
|
+
description="HTTP status code class",
|
64
|
+
value_type="string"
|
65
|
+
),
|
66
|
+
FieldMapping(
|
67
|
+
log_key="http.target",
|
68
|
+
event_set_name="http",
|
69
|
+
description="Request target path and query",
|
70
|
+
value_type="string",
|
71
|
+
default_override_key="path"
|
72
|
+
),
|
73
|
+
FieldMapping(
|
74
|
+
log_key="http.url",
|
75
|
+
event_set_name="http",
|
76
|
+
description="Full HTTP URL",
|
77
|
+
value_type="string"
|
78
|
+
),
|
79
|
+
FieldMapping(
|
80
|
+
log_key="http.scheme",
|
81
|
+
event_set_name="http",
|
82
|
+
description="URL scheme",
|
83
|
+
value_type="string"
|
84
|
+
),
|
85
|
+
FieldMapping(
|
86
|
+
log_key="http.host",
|
87
|
+
event_set_name="http",
|
88
|
+
description="Request hostname",
|
89
|
+
value_type="string"
|
90
|
+
),
|
91
|
+
FieldMapping(
|
92
|
+
log_key="http.status_code",
|
93
|
+
event_set_name="http",
|
94
|
+
description="HTTP response status code",
|
95
|
+
value_type="integer"
|
96
|
+
),
|
97
|
+
FieldMapping(
|
98
|
+
log_key="http.request.body.size",
|
99
|
+
event_set_name="http",
|
100
|
+
description="Request body size in bytes",
|
101
|
+
value_type="integer"
|
102
|
+
),
|
103
|
+
FieldMapping(
|
104
|
+
log_key="http.response.body.size",
|
105
|
+
event_set_name="http",
|
106
|
+
description="Response body size in bytes",
|
107
|
+
value_type="integer"
|
108
|
+
),
|
109
|
+
FieldMapping(
|
110
|
+
log_key="client.address",
|
111
|
+
event_set_name="http",
|
112
|
+
description="Client IP address",
|
113
|
+
value_type="string"
|
114
|
+
),
|
115
|
+
FieldMapping(
|
116
|
+
log_key="server.address",
|
117
|
+
event_set_name="http",
|
118
|
+
description="Server address or hostname",
|
119
|
+
value_type="string"
|
120
|
+
),
|
121
|
+
FieldMapping(
|
122
|
+
log_key="duration_ms",
|
123
|
+
event_set_name="http",
|
124
|
+
description="Request duration in milliseconds",
|
125
|
+
value_type="integer"
|
126
|
+
),
|
127
|
+
FieldMapping(
|
128
|
+
log_key="trace_id",
|
129
|
+
event_set_name="http",
|
130
|
+
description="Distributed trace ID",
|
131
|
+
value_type="string"
|
132
|
+
),
|
133
|
+
FieldMapping(
|
134
|
+
log_key="span_id",
|
135
|
+
event_set_name="http",
|
136
|
+
description="Span ID",
|
137
|
+
value_type="string"
|
138
|
+
),
|
139
|
+
FieldMapping(
|
140
|
+
log_key="error.message",
|
141
|
+
event_set_name="http",
|
142
|
+
description="Error message if request failed",
|
143
|
+
value_type="string"
|
144
|
+
),
|
145
|
+
FieldMapping(
|
146
|
+
log_key="error.type",
|
147
|
+
event_set_name="http",
|
148
|
+
description="Error type if request failed",
|
149
|
+
value_type="string"
|
150
|
+
),
|
151
|
+
],
|
152
|
+
priority=80
|
153
|
+
)
|