azpaddypy 0.1.0__py3-none-any.whl → 0.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azpaddypy
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,7 @@
1
+ azpaddypy-0.1.1.dist-info/licenses/LICENSE,sha256=hQ6t0g2QaewGCQICHqTckBFbMVakGmoyTAzDpmEYV4c,1089
2
+ mgmt/__init__.py,sha256=5-0eZuJMZlCONZNJ5hEvWXfvLIM36mg7FsEVs32bY_A,183
3
+ mgmt/logging.py,sha256=jQ1jIkdSf7p44_oBJZD3rPodtwkhY5Y9rwRNafwXgcI,21061
4
+ azpaddypy-0.1.1.dist-info/METADATA,sha256=Zpx4YyLu-lUev_RmVmIjXERbXWzzIqIM-sgF02snlLI,256
5
+ azpaddypy-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ azpaddypy-0.1.1.dist-info/top_level.txt,sha256=Xqg3gg53XEnWtdRarYe2ubJO0NDuer-pkr8RN2y7G-c,5
7
+ azpaddypy-0.1.1.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ mgmt
@@ -10,6 +10,8 @@ from opentelemetry import trace
10
10
  from opentelemetry.trace import Status, StatusCode, Span
11
11
  from opentelemetry.sdk.trace import TracerProvider
12
12
  from opentelemetry.sdk.resources import Resource
13
+ from opentelemetry import baggage
14
+ from opentelemetry.context import Context
13
15
 
14
16
 
15
17
  class AzureLogger:
@@ -110,6 +112,40 @@ class AzureLogger:
110
112
  """Get current correlation ID"""
111
113
  return self._correlation_id
112
114
 
115
+ def set_baggage(self, key: str, value: str) -> Context:
116
+ """
117
+ Set a baggage item in the current context
118
+
119
+ Args:
120
+ key: Baggage key
121
+ value: Baggage value
122
+
123
+ Returns:
124
+ Updated context with the new baggage item
125
+ """
126
+ return baggage.set_baggage(key, value)
127
+
128
+ def get_baggage(self, key: str) -> Optional[str]:
129
+ """
130
+ Get a baggage item from the current context
131
+
132
+ Args:
133
+ key: Baggage key
134
+
135
+ Returns:
136
+ Baggage value if exists, None otherwise
137
+ """
138
+ return baggage.get_baggage(key)
139
+
140
+ def get_all_baggage(self) -> Dict[str, str]:
141
+ """
142
+ Get all baggage items from the current context
143
+
144
+ Returns:
145
+ Dictionary of all baggage items
146
+ """
147
+ return dict(baggage.get_all())
148
+
113
149
  def _enhance_extra(self, extra: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
114
150
  """Enhance log extra data with correlation and service info"""
115
151
  enhanced_extra = {
@@ -128,6 +164,11 @@ class AzureLogger:
128
164
  enhanced_extra["trace_id"] = format(span_context.trace_id, "032x")
129
165
  enhanced_extra["span_id"] = format(span_context.span_id, "016x")
130
166
 
167
+ # Add baggage items
168
+ baggage_items = self.get_all_baggage()
169
+ if baggage_items:
170
+ enhanced_extra["baggage"] = baggage_items
171
+
131
172
  if extra:
132
173
  enhanced_extra.update(extra)
133
174
 
@@ -1,7 +0,0 @@
1
- azpaddypy/mgmt/__init__.py,sha256=5-0eZuJMZlCONZNJ5hEvWXfvLIM36mg7FsEVs32bY_A,183
2
- azpaddypy/mgmt/logging.py,sha256=bpxGz674_1_Re5LzC1b6vslImeUQXSPTdBfHbt81jI0,19942
3
- azpaddypy-0.1.0.dist-info/licenses/LICENSE,sha256=hQ6t0g2QaewGCQICHqTckBFbMVakGmoyTAzDpmEYV4c,1089
4
- azpaddypy-0.1.0.dist-info/METADATA,sha256=IYtfH4emxwpYEuSY1vHij7D4ZeLpYlNPvzaOiS6hcaQ,256
5
- azpaddypy-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- azpaddypy-0.1.0.dist-info/top_level.txt,sha256=hsDuboDhT61320ML8X479ezSTwT3rrlDWz1_Z45B2cs,10
7
- azpaddypy-0.1.0.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- azpaddypy
File without changes