azpaddypy 0.3.2__py3-none-any.whl → 0.3.3__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.
azpaddypy/mgmt/logging.py CHANGED
@@ -167,8 +167,16 @@ class AzureLogger:
167
167
 
168
168
  Returns:
169
169
  Enhanced dictionary with service context, correlation ID, trace
170
- context, and baggage items
170
+ context, and baggage items, with built-in LogRecord attributes filtered out
171
171
  """
172
+ # Define built-in LogRecord attributes that should not be overwritten
173
+ reserved_attributes = {
174
+ 'name', 'msg', 'args', 'levelname', 'levelno', 'pathname', 'filename',
175
+ 'module', 'exc_info', 'exc_text', 'stack_info', 'lineno', 'funcName',
176
+ 'created', 'msecs', 'relativeCreated', 'thread', 'threadName',
177
+ 'processName', 'process', 'getMessage'
178
+ }
179
+
172
180
  enhanced_extra = {
173
181
  "service_name": self.service_name,
174
182
  "service_version": self.service_version,
@@ -185,13 +193,34 @@ class AzureLogger:
185
193
  enhanced_extra["trace_id"] = format(span_context.trace_id, "032x")
186
194
  enhanced_extra["span_id"] = format(span_context.span_id, "016x")
187
195
 
188
- # Add baggage items
196
+ # Add baggage items, filtering out any reserved attribute names
189
197
  baggage_items = self.get_all_baggage()
190
198
  if baggage_items:
191
- enhanced_extra["baggage"] = baggage_items
199
+ # Filter baggage items to avoid conflicts with LogRecord attributes
200
+ filtered_baggage = {k: v for k, v in baggage_items.items() if k not in reserved_attributes}
201
+ if filtered_baggage:
202
+ enhanced_extra["baggage"] = filtered_baggage
203
+
204
+ # Log warning if any baggage keys were filtered out
205
+ filtered_baggage_keys = set(baggage_items.keys()) - set(filtered_baggage.keys())
206
+ if filtered_baggage_keys:
207
+ # Use the base logger directly to avoid infinite recursion
208
+ self.logger.warning(
209
+ f"Filtered out reserved LogRecord attributes from baggage: {filtered_baggage_keys}"
210
+ )
192
211
 
193
212
  if isinstance(extra, dict):
194
- enhanced_extra.update(extra)
213
+ # Filter out any keys that would conflict with built-in LogRecord attributes
214
+ filtered_extra = {k: v for k, v in extra.items() if k not in reserved_attributes}
215
+ enhanced_extra.update(filtered_extra)
216
+
217
+ # Log warning if any keys were filtered out
218
+ filtered_keys = set(extra.keys()) - set(filtered_extra.keys())
219
+ if filtered_keys:
220
+ # Use the base logger directly to avoid infinite recursion
221
+ self.logger.warning(
222
+ f"Filtered out reserved LogRecord attributes from extra data: {filtered_keys}"
223
+ )
195
224
 
196
225
  return enhanced_extra
197
226
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azpaddypy
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Comprehensive Python logger for Azure, integrating OpenTelemetry for advanced, structured, and distributed tracing.
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Operating System :: OS Independent
@@ -1,10 +1,10 @@
1
1
  azpaddypy/mgmt/__init__.py,sha256=-jH8Ftx9C8qu4yF5dMVEapVZhNwG7m4QCUjyutesOoY,278
2
2
  azpaddypy/mgmt/identity.py,sha256=mA_krQslMsK_sDob-z-QA0B9khK_JUO2way7xwPopR8,12001
3
- azpaddypy/mgmt/logging.py,sha256=5sAqUWwjX6nZMgqK8BurMoWhId4JJ21RZ9H29gXWqA4,28835
3
+ azpaddypy/mgmt/logging.py,sha256=Cz_xPjFYfiNh2_S7jww8QR1EaGgQfXcFzEWZqCDp8ks,30638
4
4
  azpaddypy/test_function/__init__.py,sha256=0NjUl36wvUWV79GpRwBFkgkBaC6uDZsTdaSVOIHMFEU,3481
5
5
  azpaddypy/test_function/function_app.py,sha256=6nX54-iq0L1l_hZpD6E744-j79oLxdaldFyWDCpwH7c,3867
6
- azpaddypy-0.3.2.dist-info/licenses/LICENSE,sha256=hQ6t0g2QaewGCQICHqTckBFbMVakGmoyTAzDpmEYV4c,1089
7
- azpaddypy-0.3.2.dist-info/METADATA,sha256=rR7GtG1mvgOR0WWYGkGt-2ZTtdwcye-GO8ea2QXNhos,705
8
- azpaddypy-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- azpaddypy-0.3.2.dist-info/top_level.txt,sha256=hsDuboDhT61320ML8X479ezSTwT3rrlDWz1_Z45B2cs,10
10
- azpaddypy-0.3.2.dist-info/RECORD,,
6
+ azpaddypy-0.3.3.dist-info/licenses/LICENSE,sha256=hQ6t0g2QaewGCQICHqTckBFbMVakGmoyTAzDpmEYV4c,1089
7
+ azpaddypy-0.3.3.dist-info/METADATA,sha256=8Pnqt9ZOhDafwPlx2VeC_Zknadyb9kHBPv76Ss-OPLQ,705
8
+ azpaddypy-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ azpaddypy-0.3.3.dist-info/top_level.txt,sha256=hsDuboDhT61320ML8X479ezSTwT3rrlDWz1_Z45B2cs,10
10
+ azpaddypy-0.3.3.dist-info/RECORD,,