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
@@ -1,458 +0,0 @@
|
|
1
|
-
# src/provide/foundation/telemetry/emoji_sets.py
|
2
|
-
"""
|
3
|
-
Predefined Emoji Sets for Foundation Telemetry.
|
4
|
-
|
5
|
-
This module contains definitions for built-in emoji set configurations that provide
|
6
|
-
visual emoji mappings for common technologies and domains like LLMs, HTTP interactions,
|
7
|
-
and databases.
|
8
|
-
"""
|
9
|
-
|
10
|
-
from provide.foundation.logger.emoji.matrix import (
|
11
|
-
PRIMARY_EMOJI,
|
12
|
-
SECONDARY_EMOJI,
|
13
|
-
TERTIARY_EMOJI,
|
14
|
-
)
|
15
|
-
from provide.foundation.logger.emoji.types import (
|
16
|
-
EmojiSet,
|
17
|
-
EmojiSetConfig,
|
18
|
-
FieldToEmojiMapping,
|
19
|
-
)
|
20
|
-
|
21
|
-
# --- Core DAS Layer Definition (Internal representation) ---
|
22
|
-
# This serves as the default Domain-Action-Status system when no custom layers are active.
|
23
|
-
# It handles the standard keys "domain", "action", "status".
|
24
|
-
LEGACY_DAS_EMOJI_SETS: list[EmojiSet] = [
|
25
|
-
EmojiSet(name="_legacy_domain", emojis=PRIMARY_EMOJI, default_emoji_key="default"),
|
26
|
-
EmojiSet(
|
27
|
-
name="_legacy_action", emojis=SECONDARY_EMOJI, default_emoji_key="default"
|
28
|
-
),
|
29
|
-
EmojiSet(name="_legacy_status", emojis=TERTIARY_EMOJI, default_emoji_key="default"),
|
30
|
-
]
|
31
|
-
LEGACY_DAS_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
|
32
|
-
FieldToEmojiMapping(log_key="domain", emoji_set_name="_legacy_domain"),
|
33
|
-
FieldToEmojiMapping(log_key="action", emoji_set_name="_legacy_action"),
|
34
|
-
FieldToEmojiMapping(log_key="status", emoji_set_name="_legacy_status"),
|
35
|
-
]
|
36
|
-
# Note: The core DAS system is not a formal "EmojiSetConfig" that users enable by name.
|
37
|
-
# It's the default behavior used in the `add_das_emoji_prefix` processor.
|
38
|
-
|
39
|
-
# --- LLM Layer ---
|
40
|
-
LLM_EMOJI_SETS: list[EmojiSet] = [
|
41
|
-
EmojiSet(
|
42
|
-
name="llm_provider",
|
43
|
-
emojis={
|
44
|
-
"openai": "🤖",
|
45
|
-
"anthropic": "📚",
|
46
|
-
"google": "🇬",
|
47
|
-
"meta": "🦙",
|
48
|
-
"mistral": "🌬️",
|
49
|
-
"perplexity": "❓",
|
50
|
-
"cohere": "🔊",
|
51
|
-
"default": "💡",
|
52
|
-
},
|
53
|
-
default_emoji_key="default",
|
54
|
-
),
|
55
|
-
EmojiSet(
|
56
|
-
name="llm_task",
|
57
|
-
emojis={
|
58
|
-
"generation": "✍️",
|
59
|
-
"completion": "✅",
|
60
|
-
"embedding": "🔗",
|
61
|
-
"chat": "💬",
|
62
|
-
"tool_use": "🛠️",
|
63
|
-
"summarization": "📜",
|
64
|
-
"translation": "🌐",
|
65
|
-
"classification": "🏷️",
|
66
|
-
"default": "⚡",
|
67
|
-
},
|
68
|
-
default_emoji_key="default",
|
69
|
-
),
|
70
|
-
EmojiSet(
|
71
|
-
name="llm_outcome",
|
72
|
-
emojis={
|
73
|
-
"success": "👍",
|
74
|
-
"error": "🔥",
|
75
|
-
"filtered_input": "🛡️👁️",
|
76
|
-
"filtered_output": "🛡️🗣️",
|
77
|
-
"rate_limit": "⏳",
|
78
|
-
"partial_success": "🤏",
|
79
|
-
"tool_call": "📞",
|
80
|
-
"default": "➡️",
|
81
|
-
},
|
82
|
-
default_emoji_key="default",
|
83
|
-
),
|
84
|
-
]
|
85
|
-
LLM_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
|
86
|
-
FieldToEmojiMapping(
|
87
|
-
log_key="llm.provider",
|
88
|
-
description="Name of the LLM provider (e.g., openai, anthropic)",
|
89
|
-
value_type="string",
|
90
|
-
emoji_set_name="llm_provider",
|
91
|
-
),
|
92
|
-
FieldToEmojiMapping(
|
93
|
-
log_key="llm.task",
|
94
|
-
description="The specific LLM task being performed (e.g., generation, chat)",
|
95
|
-
value_type="string",
|
96
|
-
emoji_set_name="llm_task",
|
97
|
-
),
|
98
|
-
FieldToEmojiMapping(
|
99
|
-
log_key="llm.model",
|
100
|
-
description="Identifier of the LLM model used",
|
101
|
-
value_type="string",
|
102
|
-
emoji_set_name="llm_provider",
|
103
|
-
), # Reuses provider emojis for model by default
|
104
|
-
FieldToEmojiMapping(
|
105
|
-
log_key="llm.outcome",
|
106
|
-
description="Outcome of the LLM operation",
|
107
|
-
value_type="string",
|
108
|
-
emoji_set_name="llm_outcome",
|
109
|
-
),
|
110
|
-
FieldToEmojiMapping(
|
111
|
-
log_key="llm.input.tokens",
|
112
|
-
description="Number of input tokens",
|
113
|
-
value_type="integer",
|
114
|
-
),
|
115
|
-
FieldToEmojiMapping(
|
116
|
-
log_key="llm.output.tokens",
|
117
|
-
description="Number of output tokens",
|
118
|
-
value_type="integer",
|
119
|
-
),
|
120
|
-
FieldToEmojiMapping(
|
121
|
-
log_key="llm.tool.name",
|
122
|
-
description="Name of the tool called by the LLM",
|
123
|
-
value_type="string",
|
124
|
-
),
|
125
|
-
FieldToEmojiMapping(
|
126
|
-
log_key="llm.tool.call_id",
|
127
|
-
description="Identifier for a specific tool call",
|
128
|
-
value_type="string",
|
129
|
-
),
|
130
|
-
FieldToEmojiMapping(
|
131
|
-
log_key="duration_ms",
|
132
|
-
description="Duration of the LLM operation in milliseconds",
|
133
|
-
value_type="integer",
|
134
|
-
),
|
135
|
-
FieldToEmojiMapping(
|
136
|
-
log_key="trace_id",
|
137
|
-
description="Distributed trace ID for the operation",
|
138
|
-
value_type="string",
|
139
|
-
),
|
140
|
-
]
|
141
|
-
LLM_EMOJI_SET = EmojiSetConfig(
|
142
|
-
name="llm",
|
143
|
-
description="Emoji mappings for logging Large Language Model interactions.",
|
144
|
-
emoji_sets=LLM_EMOJI_SETS,
|
145
|
-
field_definitions=LLM_FIELD_DEFINITIONS,
|
146
|
-
priority=100, # High priority
|
147
|
-
)
|
148
|
-
|
149
|
-
# --- Database Layer ---
|
150
|
-
DB_EMOJI_SETS: list[EmojiSet] = [
|
151
|
-
EmojiSet(
|
152
|
-
name="db_system",
|
153
|
-
emojis={
|
154
|
-
"postgres": "🐘",
|
155
|
-
"mysql": "🐬",
|
156
|
-
"sqlite": "💾",
|
157
|
-
"mongodb": "🍃",
|
158
|
-
"redis": "🟥",
|
159
|
-
"elasticsearch": "🔍",
|
160
|
-
"default": "🗄️",
|
161
|
-
},
|
162
|
-
default_emoji_key="default",
|
163
|
-
),
|
164
|
-
EmojiSet(
|
165
|
-
name="db_operation",
|
166
|
-
emojis={
|
167
|
-
"query": "🔍",
|
168
|
-
"select": "🔍",
|
169
|
-
"insert": "➕",
|
170
|
-
"update": "🔄",
|
171
|
-
"delete": "🗑️",
|
172
|
-
"connect": "🔗",
|
173
|
-
"disconnect": "💔",
|
174
|
-
"transaction_begin": "💳🟢",
|
175
|
-
"transaction_commit": "💳✅",
|
176
|
-
"transaction_rollback": "💳❌",
|
177
|
-
"default": "⚙️",
|
178
|
-
},
|
179
|
-
default_emoji_key="default",
|
180
|
-
),
|
181
|
-
EmojiSet( # Can reuse llm_outcome or define specific DB outcomes
|
182
|
-
name="db_outcome",
|
183
|
-
emojis={
|
184
|
-
"success": "👍",
|
185
|
-
"error": "🔥",
|
186
|
-
"not_found": "❓🤷",
|
187
|
-
"timeout": "⏱️",
|
188
|
-
"default": "➡️",
|
189
|
-
},
|
190
|
-
default_emoji_key="default",
|
191
|
-
),
|
192
|
-
]
|
193
|
-
DB_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
|
194
|
-
FieldToEmojiMapping(
|
195
|
-
log_key="db.system",
|
196
|
-
description="Type of database system (e.g., postgres, mysql)",
|
197
|
-
value_type="string",
|
198
|
-
emoji_set_name="db_system",
|
199
|
-
),
|
200
|
-
FieldToEmojiMapping(
|
201
|
-
log_key="db.operation",
|
202
|
-
description="Database operation performed (e.g., query, insert)",
|
203
|
-
value_type="string",
|
204
|
-
emoji_set_name="db_operation",
|
205
|
-
),
|
206
|
-
FieldToEmojiMapping(
|
207
|
-
log_key="db.statement",
|
208
|
-
description="The database statement executed (potentially truncated/sanitized)",
|
209
|
-
value_type="string",
|
210
|
-
),
|
211
|
-
FieldToEmojiMapping(
|
212
|
-
log_key="db.table",
|
213
|
-
description="Name of the database table involved",
|
214
|
-
value_type="string",
|
215
|
-
emoji_set_name="db_system",
|
216
|
-
default_emoji_override_key="default",
|
217
|
-
), # Use default DB emoji
|
218
|
-
FieldToEmojiMapping(
|
219
|
-
log_key="db.rows_affected",
|
220
|
-
description="Number of rows affected by the operation",
|
221
|
-
value_type="integer",
|
222
|
-
),
|
223
|
-
FieldToEmojiMapping(
|
224
|
-
log_key="db.outcome",
|
225
|
-
description="Outcome of the database operation",
|
226
|
-
value_type="string",
|
227
|
-
emoji_set_name="db_outcome",
|
228
|
-
),
|
229
|
-
FieldToEmojiMapping(
|
230
|
-
log_key="duration_ms",
|
231
|
-
description="Duration of the database operation in milliseconds",
|
232
|
-
value_type="integer",
|
233
|
-
),
|
234
|
-
FieldToEmojiMapping(
|
235
|
-
log_key="trace_id",
|
236
|
-
description="Distributed trace ID for the operation",
|
237
|
-
value_type="string",
|
238
|
-
),
|
239
|
-
]
|
240
|
-
DATABASE_EMOJI_SET = EmojiSetConfig(
|
241
|
-
name="database",
|
242
|
-
description="Emoji mappings for logging database interactions.",
|
243
|
-
emoji_sets=DB_EMOJI_SETS,
|
244
|
-
field_definitions=DB_FIELD_DEFINITIONS,
|
245
|
-
priority=90,
|
246
|
-
)
|
247
|
-
|
248
|
-
# --- HTTP Layer (Client/Server) ---
|
249
|
-
HTTP_EMOJI_SETS: list[EmojiSet] = [
|
250
|
-
EmojiSet(
|
251
|
-
name="http_method",
|
252
|
-
emojis={
|
253
|
-
"get": "📥",
|
254
|
-
"post": "📤",
|
255
|
-
"put": "📝⬆️",
|
256
|
-
"delete": "🗑️",
|
257
|
-
"patch": "🩹",
|
258
|
-
"head": "👤❔",
|
259
|
-
"options": "⚙️❔",
|
260
|
-
"default": "🌐",
|
261
|
-
},
|
262
|
-
default_emoji_key="default",
|
263
|
-
),
|
264
|
-
EmojiSet(
|
265
|
-
name="http_status_class", # For 2xx, 3xx etc.
|
266
|
-
emojis={
|
267
|
-
"1xx": "ℹ️",
|
268
|
-
"2xx": "✅",
|
269
|
-
"3xx": "↪️",
|
270
|
-
"4xx": "⚠️CLIENT",
|
271
|
-
"5xx": "🔥SERVER",
|
272
|
-
"default": "❓",
|
273
|
-
},
|
274
|
-
default_emoji_key="default",
|
275
|
-
),
|
276
|
-
EmojiSet(
|
277
|
-
name="http_target_type", # For path, query, fragment
|
278
|
-
emojis={"path": "🛣️", "query": "❓", "fragment": "#️⃣", "default": "🎯"},
|
279
|
-
default_emoji_key="default",
|
280
|
-
),
|
281
|
-
]
|
282
|
-
HTTP_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
|
283
|
-
FieldToEmojiMapping(
|
284
|
-
log_key="http.method",
|
285
|
-
description="HTTP request method (e.g., GET, POST)",
|
286
|
-
value_type="string",
|
287
|
-
emoji_set_name="http_method",
|
288
|
-
),
|
289
|
-
FieldToEmojiMapping(
|
290
|
-
log_key="http.url",
|
291
|
-
description="Full HTTP URL of the request",
|
292
|
-
value_type="string",
|
293
|
-
),
|
294
|
-
FieldToEmojiMapping(
|
295
|
-
log_key="http.target",
|
296
|
-
description="Request target (path and query string)",
|
297
|
-
value_type="string",
|
298
|
-
emoji_set_name="http_target_type",
|
299
|
-
default_emoji_override_key="path",
|
300
|
-
),
|
301
|
-
FieldToEmojiMapping(
|
302
|
-
log_key="http.scheme",
|
303
|
-
description="URL scheme (e.g., http, https)",
|
304
|
-
value_type="string",
|
305
|
-
),
|
306
|
-
FieldToEmojiMapping(
|
307
|
-
log_key="http.host", description="Hostname of the request", value_type="string"
|
308
|
-
),
|
309
|
-
FieldToEmojiMapping(
|
310
|
-
log_key="http.status_code",
|
311
|
-
description="HTTP response status code",
|
312
|
-
value_type="integer",
|
313
|
-
),
|
314
|
-
FieldToEmojiMapping(
|
315
|
-
log_key="http.status_class",
|
316
|
-
description="HTTP status code class (e.g., 2xx, 4xx)",
|
317
|
-
value_type="string",
|
318
|
-
emoji_set_name="http_status_class",
|
319
|
-
),
|
320
|
-
FieldToEmojiMapping(
|
321
|
-
log_key="http.request.body.size",
|
322
|
-
description="Size of HTTP request body in bytes",
|
323
|
-
value_type="integer",
|
324
|
-
),
|
325
|
-
FieldToEmojiMapping(
|
326
|
-
log_key="http.response.body.size",
|
327
|
-
description="Size of HTTP response body in bytes",
|
328
|
-
value_type="integer",
|
329
|
-
),
|
330
|
-
FieldToEmojiMapping(
|
331
|
-
log_key="client.address", description="Client IP address", value_type="string"
|
332
|
-
),
|
333
|
-
FieldToEmojiMapping(
|
334
|
-
log_key="server.address",
|
335
|
-
description="Server IP address or hostname",
|
336
|
-
value_type="string",
|
337
|
-
),
|
338
|
-
FieldToEmojiMapping(
|
339
|
-
log_key="duration_ms",
|
340
|
-
description="Duration of the HTTP request/response cycle in milliseconds",
|
341
|
-
value_type="integer",
|
342
|
-
),
|
343
|
-
FieldToEmojiMapping(
|
344
|
-
log_key="trace_id",
|
345
|
-
description="Distributed trace ID for the operation",
|
346
|
-
value_type="string",
|
347
|
-
),
|
348
|
-
FieldToEmojiMapping(
|
349
|
-
log_key="span_id", description="Span ID for the operation", value_type="string"
|
350
|
-
),
|
351
|
-
FieldToEmojiMapping(
|
352
|
-
log_key="error.message",
|
353
|
-
description="Error message if request failed",
|
354
|
-
value_type="string",
|
355
|
-
),
|
356
|
-
FieldToEmojiMapping(
|
357
|
-
log_key="error.type",
|
358
|
-
description="Type of error if request failed",
|
359
|
-
value_type="string",
|
360
|
-
),
|
361
|
-
]
|
362
|
-
HTTP_EMOJI_SET = EmojiSetConfig(
|
363
|
-
name="http",
|
364
|
-
description="Emoji mappings for logging HTTP client and server interactions.",
|
365
|
-
emoji_sets=HTTP_EMOJI_SETS,
|
366
|
-
field_definitions=HTTP_FIELD_DEFINITIONS,
|
367
|
-
priority=80,
|
368
|
-
)
|
369
|
-
|
370
|
-
# --- Task Queue Layer ---
|
371
|
-
TASK_QUEUE_EMOJI_SETS: list[EmojiSet] = [
|
372
|
-
EmojiSet(
|
373
|
-
name="task_system",
|
374
|
-
emojis={
|
375
|
-
"celery": "🥕",
|
376
|
-
"rq": "🟥🇶",
|
377
|
-
"dramatiq": "🎭",
|
378
|
-
"kafka": "🌊",
|
379
|
-
"rabbitmq": "🐇",
|
380
|
-
"default": "📨",
|
381
|
-
},
|
382
|
-
default_emoji_key="default",
|
383
|
-
),
|
384
|
-
EmojiSet(
|
385
|
-
name="task_status",
|
386
|
-
emojis={
|
387
|
-
"submitted": "➡️📨",
|
388
|
-
"received": "📥",
|
389
|
-
"started": "▶️",
|
390
|
-
"progress": "🔄",
|
391
|
-
"retrying": "🔁",
|
392
|
-
"success": "✅🏁",
|
393
|
-
"failure": "❌🔥",
|
394
|
-
"revoked": "🚫",
|
395
|
-
"default": "❓",
|
396
|
-
},
|
397
|
-
default_emoji_key="default",
|
398
|
-
),
|
399
|
-
]
|
400
|
-
TASK_QUEUE_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
|
401
|
-
FieldToEmojiMapping(
|
402
|
-
log_key="task.system",
|
403
|
-
description="Task queue system used (e.g., celery, rq)",
|
404
|
-
value_type="string",
|
405
|
-
emoji_set_name="task_system",
|
406
|
-
),
|
407
|
-
FieldToEmojiMapping(
|
408
|
-
log_key="task.id",
|
409
|
-
description="Unique identifier for the task instance",
|
410
|
-
value_type="string",
|
411
|
-
),
|
412
|
-
FieldToEmojiMapping(
|
413
|
-
log_key="task.name", description="Name of the task or job", value_type="string"
|
414
|
-
),
|
415
|
-
FieldToEmojiMapping(
|
416
|
-
log_key="task.queue_name",
|
417
|
-
description="Name of the queue the task was processed on",
|
418
|
-
value_type="string",
|
419
|
-
),
|
420
|
-
FieldToEmojiMapping(
|
421
|
-
log_key="task.status",
|
422
|
-
description="Current status of the task",
|
423
|
-
value_type="string",
|
424
|
-
emoji_set_name="task_status",
|
425
|
-
),
|
426
|
-
FieldToEmojiMapping(
|
427
|
-
log_key="task.retries",
|
428
|
-
description="Number of retries for the task",
|
429
|
-
value_type="integer",
|
430
|
-
),
|
431
|
-
FieldToEmojiMapping(
|
432
|
-
log_key="duration_ms",
|
433
|
-
description="Execution duration of the task in milliseconds",
|
434
|
-
value_type="integer",
|
435
|
-
),
|
436
|
-
FieldToEmojiMapping(
|
437
|
-
log_key="trace_id",
|
438
|
-
description="Distributed trace ID associated with the task",
|
439
|
-
value_type="string",
|
440
|
-
),
|
441
|
-
]
|
442
|
-
TASK_QUEUE_EMOJI_SET = EmojiSetConfig(
|
443
|
-
name="task_queue",
|
444
|
-
description="Emoji mappings for logging asynchronous task queue operations.",
|
445
|
-
emoji_sets=TASK_QUEUE_EMOJI_SETS,
|
446
|
-
field_definitions=TASK_QUEUE_FIELD_DEFINITIONS,
|
447
|
-
priority=70,
|
448
|
-
)
|
449
|
-
|
450
|
-
|
451
|
-
# Registry of all built-in emoji sets
|
452
|
-
BUILTIN_EMOJI_SETS: dict[str, EmojiSetConfig] = {
|
453
|
-
LLM_EMOJI_SET.name: LLM_EMOJI_SET,
|
454
|
-
DATABASE_EMOJI_SET.name: DATABASE_EMOJI_SET,
|
455
|
-
HTTP_EMOJI_SET.name: HTTP_EMOJI_SET,
|
456
|
-
TASK_QUEUE_EMOJI_SET.name: TASK_QUEUE_EMOJI_SET,
|
457
|
-
# Add more emoji sets here (e.g., FILE_IO_EMOJI_SET, RPC_EMOJI_SET)
|
458
|
-
}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Emoji-related type definitions for the Foundation logger.
|
3
|
-
|
4
|
-
This module contains data structures for emoji mapping configurations
|
5
|
-
used in structured logging visual enhancement.
|
6
|
-
"""
|
7
|
-
|
8
|
-
from attrs import define, field
|
9
|
-
|
10
|
-
|
11
|
-
@define(frozen=True, slots=True)
|
12
|
-
class EmojiSet:
|
13
|
-
"""
|
14
|
-
Emoji set for registry-based component management.
|
15
|
-
|
16
|
-
This replaces EmojiSet and is used by the new component registry system.
|
17
|
-
"""
|
18
|
-
|
19
|
-
name: str = field()
|
20
|
-
emojis: dict[str, str] = field(factory=lambda: {})
|
21
|
-
default_emoji_key: str = field(default="default")
|
22
|
-
|
23
|
-
|
24
|
-
@define(frozen=True, slots=True)
|
25
|
-
class FieldToEmojiMapping:
|
26
|
-
"""
|
27
|
-
Defines a single log field key and its optional emoji mapping.
|
28
|
-
"""
|
29
|
-
|
30
|
-
log_key: str = field() # e.g., "http.method", "llm.request.model"
|
31
|
-
description: str | None = field(default=None)
|
32
|
-
value_type: str | None = field(
|
33
|
-
default=None
|
34
|
-
) # e.g., "string", "integer", "iso_timestamp"
|
35
|
-
emoji_set_name: str | None = field(
|
36
|
-
default=None
|
37
|
-
) # Optional: references an EmojiSet.name
|
38
|
-
default_emoji_override_key: str | None = field(
|
39
|
-
default=None
|
40
|
-
) # Optional: key within the emoji_set for this field's default
|
41
|
-
|
42
|
-
|
43
|
-
@define(frozen=True, slots=True)
|
44
|
-
class EmojiSetConfig:
|
45
|
-
"""
|
46
|
-
Defines an emoji set configuration with emoji mappings for specific fields.
|
47
|
-
Provides visual enhancement for structured logging in specific domains.
|
48
|
-
"""
|
49
|
-
|
50
|
-
name: str = field() # e.g., "llm", "database", "http_client"
|
51
|
-
description: str | None = field(default=None)
|
52
|
-
emoji_sets: list[EmojiSet] = field(factory=lambda: [])
|
53
|
-
field_definitions: list[FieldToEmojiMapping] = field(factory=lambda: [])
|
54
|
-
priority: int = field(
|
55
|
-
default=0, converter=int
|
56
|
-
) # Higher priority layers take precedence in case of conflicts
|
@@ -1,64 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# emoji_resolver.py
|
3
|
-
#
|
4
|
-
"""
|
5
|
-
Emoji configuration resolution for Foundation Telemetry.
|
6
|
-
Handles the merging and resolution of emoji set configurations from multiple sources.
|
7
|
-
"""
|
8
|
-
|
9
|
-
from provide.foundation.logger.config import LoggingConfig
|
10
|
-
from provide.foundation.logger.emoji.sets import LEGACY_DAS_EMOJI_SETS
|
11
|
-
from provide.foundation.logger.emoji.types import (
|
12
|
-
EmojiSet,
|
13
|
-
EmojiSetConfig,
|
14
|
-
FieldToEmojiMapping,
|
15
|
-
)
|
16
|
-
|
17
|
-
ResolvedEmojiConfig = tuple[list[FieldToEmojiMapping], dict[str, EmojiSet]]
|
18
|
-
|
19
|
-
|
20
|
-
def resolve_active_emoji_config(
|
21
|
-
logging_config: LoggingConfig, builtin_emoji_registry: dict[str, EmojiSetConfig]
|
22
|
-
) -> ResolvedEmojiConfig:
|
23
|
-
"""
|
24
|
-
Resolve the active emoji configuration from multiple sources.
|
25
|
-
|
26
|
-
Args:
|
27
|
-
logging_config: The logging configuration
|
28
|
-
builtin_emoji_registry: Registry of built-in emoji sets
|
29
|
-
|
30
|
-
Returns:
|
31
|
-
Tuple of (field_definitions, emoji_sets_dict)
|
32
|
-
"""
|
33
|
-
resolved_fields_dict: dict[str, FieldToEmojiMapping] = {}
|
34
|
-
resolved_emoji_sets_dict: dict[str, EmojiSet] = {
|
35
|
-
s.name: s for s in LEGACY_DAS_EMOJI_SETS
|
36
|
-
}
|
37
|
-
|
38
|
-
emoji_sets_to_process: list[EmojiSetConfig] = [
|
39
|
-
builtin_emoji_registry[name]
|
40
|
-
for name in logging_config.enabled_emoji_sets
|
41
|
-
if name in builtin_emoji_registry
|
42
|
-
]
|
43
|
-
emoji_sets_to_process.extend(logging_config.custom_emoji_sets)
|
44
|
-
emoji_sets_to_process.sort(key=lambda emoji_set: emoji_set.priority)
|
45
|
-
|
46
|
-
ordered_log_keys: list[str] = []
|
47
|
-
seen_log_keys: set[str] = set()
|
48
|
-
|
49
|
-
for emoji_set_config in emoji_sets_to_process:
|
50
|
-
for emoji_set in emoji_set_config.emoji_sets:
|
51
|
-
resolved_emoji_sets_dict[emoji_set.name] = emoji_set
|
52
|
-
for field_def in emoji_set_config.field_definitions:
|
53
|
-
resolved_fields_dict[field_def.log_key] = field_def
|
54
|
-
if field_def.log_key not in seen_log_keys:
|
55
|
-
ordered_log_keys.append(field_def.log_key)
|
56
|
-
seen_log_keys.add(field_def.log_key)
|
57
|
-
|
58
|
-
for user_emoji_set in logging_config.user_defined_emoji_sets:
|
59
|
-
resolved_emoji_sets_dict[user_emoji_set.name] = user_emoji_set
|
60
|
-
|
61
|
-
final_ordered_field_definitions = [
|
62
|
-
resolved_fields_dict[log_key] for log_key in ordered_log_keys
|
63
|
-
]
|
64
|
-
return final_ordered_field_definitions, resolved_emoji_sets_dict
|