otel-utils 0.1.17__py3-none-any.whl → 0.1.18__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.

Potentially problematic release.


This version of otel-utils might be problematic. Click here for more details.

otel_utils/logging.py CHANGED
@@ -15,18 +15,13 @@ class JsonFormatter(logging.Formatter):
15
15
  if hasattr(record, 'structured') and record.structured:
16
16
  for key, value in record.__dict__.items():
17
17
  if key not in (
18
- 'args', 'exc_info', 'exc_text', 'msg', 'message', 'levelname', 'levelno', 'pathname',
19
- 'filename',
20
- 'module', 'stack_info', 'lineno', 'funcName', 'created', 'msecs', 'relativeCreated', 'name',
21
- 'thread',
22
- 'threadName', 'processName', 'process'):
18
+ 'args', 'exc_info', 'exc_text', 'msg', 'message', 'levelname',
19
+ 'levelno', 'pathname', 'filename', 'module', 'stack_info',
20
+ 'lineno', 'funcName', 'created', 'msecs', 'relativeCreated',
21
+ 'name', 'thread', 'threadName', 'processName', 'process'
22
+ ):
23
23
  log_data[key] = value
24
24
 
25
- if 'attributes' in log_data:
26
- for key, value in log_data['attributes'].items():
27
- log_data[key] = value
28
- del log_data['attributes']
29
-
30
25
  log_data['message'] = record.getMessage()
31
26
 
32
27
  return json.dumps(log_data)
@@ -78,14 +73,25 @@ class StructuredLogger:
78
73
 
79
74
  log_attributes = {
80
75
  **self.default_attributes,
81
- **trace_context,
82
76
  "timestamp": datetime.utcnow().isoformat(),
83
77
  "severity": logging.getLevelName(level),
84
78
  "logger.name": self.logger.name
85
79
  }
86
80
 
87
- for key, value in kwargs.items():
88
- log_attributes[key] = value
81
+ if trace_context:
82
+ log_attributes["trace_id"] = trace_context.get("trace_id")
83
+ log_attributes["span_id"] = trace_context.get("span_id")
84
+
85
+ operation = kwargs.pop("operation", None)
86
+ if operation:
87
+ log_attributes["operation"] = operation
88
+
89
+ status = kwargs.pop("status", None)
90
+ if status:
91
+ log_attributes["status"] = status
92
+
93
+ if kwargs:
94
+ log_attributes["context"] = kwargs
89
95
 
90
96
  self.logger.log(
91
97
  level,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: otel-utils
3
- Version: 0.1.17
3
+ Version: 0.1.18
4
4
  Summary: Utilidades simplificadas para instrumentación con OpenTelemetry
5
5
  License: Proprietary
6
6
  Author: Harold Portocarrero
@@ -1,8 +1,8 @@
1
1
  otel_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  otel_utils/configurator.py,sha256=uUrBbAYA0FHyJNy4ap50223ZPj0nhQh3EaGULuGCphQ,6572
3
- otel_utils/logging.py,sha256=-F80xi301GmGBG2UlHuGfoqncbs88WNJnJI8Bh5B4dA,4271
3
+ otel_utils/logging.py,sha256=W4ewXa17r9YQf4wk-8njgfWxyOn03uSVipbBCufcTU8,4428
4
4
  otel_utils/metrics.py,sha256=XD-t9V3peZJs97hN2hR2rwJKrcCJHqx2cldNOTCpzoA,3664
5
5
  otel_utils/tracing.py,sha256=PtowQ7MvYld_xJlVAV4pBQuDBQIqPeP1FQPrzgZx9_Q,2625
6
- otel_utils-0.1.17.dist-info/METADATA,sha256=FttkFUeg3nFRZ-w4g3BUXNRtpX4gZ0wbk84NzNyjWPk,5279
7
- otel_utils-0.1.17.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
8
- otel_utils-0.1.17.dist-info/RECORD,,
6
+ otel_utils-0.1.18.dist-info/METADATA,sha256=eCopGSP3E0iHmn4GibMCZ7ZzbNdRiNphKrPbIJYrMUw,5279
7
+ otel_utils-0.1.18.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
8
+ otel_utils-0.1.18.dist-info/RECORD,,