warpzone-sdk 15.0.0.dev4__py3-none-any.whl → 15.0.0.dev5__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.
@@ -28,7 +28,8 @@ SUBJECT_IDENTIFIER = "<Subject>"
28
28
  @contextmanager
29
29
  def run_in_trace_context(context: func.Context):
30
30
  trace_context = context.trace_context
31
- with traces.set_trace_context(trace_context.trace_parent):
31
+ span_name = context.function_name or "azure_function"
32
+ with traces.set_trace_context(trace_context.trace_parent, span_name=span_name):
32
33
  yield
33
34
 
34
35
 
@@ -63,36 +63,27 @@ class AzureSDKTraceFilter(SpanProcessor):
63
63
 
64
64
 
65
65
  @contextmanager
66
- def set_trace_context(trace_parent: str):
67
- """Context manager for setting the trace context.
66
+ def set_trace_context(trace_parent: str, span_name: str = "function_execution"):
67
+ """Context manager for setting the trace context with a recording span.
68
68
 
69
- Attaches the propagated trace context with a NonRecordingSpan so that
70
- logs emitted within this context are properly correlated with the trace
71
- created by Azure Functions.
72
-
73
- The NonRecordingSpan is necessary because the LoggingHandler needs an
74
- actual span (not just a SpanContext) to extract trace correlation IDs.
75
- Using NonRecordingSpan avoids creating duplicate spans while still
76
- providing the trace_id and span_id for log correlation.
69
+ Creates a child span of the propagated trace context. This is necessary
70
+ because the LoggingHandler requires a recording span to properly correlate
71
+ logs with the trace. A NonRecordingSpan (which is what TraceContextTextMapPropagator
72
+ creates) may not be correctly handled during log batching/export.
77
73
 
78
74
  Args:
79
75
  trace_parent (str): Trace parent ID from the incoming request
76
+ span_name (str): Name for the span. Defaults to "function_execution".
80
77
  """
81
78
  carrier = {"traceparent": trace_parent}
82
79
  ctx = TraceContextTextMapPropagator().extract(carrier=carrier)
83
80
 
84
- # Get the span from the extracted context - this is a NonRecordingSpan
85
- # created by the propagator with the correct trace_id and span_id
86
- span = trace.get_current_span(ctx)
87
-
88
- # Set this span as the current span in context
89
- ctx = trace.set_span_in_context(span)
90
-
91
- token = context.attach(ctx)
92
- try:
93
- yield
94
- finally:
95
- context.detach(token)
81
+ # Start a recording span as a child of the propagated context.
82
+ # This ensures logs are properly correlated with the trace.
83
+ tracer = trace.get_tracer(__name__)
84
+ with trace.use_span(trace.get_current_span(ctx), end_on_exit=False):
85
+ with tracer.start_as_current_span(span_name):
86
+ yield
96
87
 
97
88
 
98
89
  def get_tracer(name: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warpzone-sdk
3
- Version: 15.0.0.dev4
3
+ Version: 15.0.0.dev5
4
4
  Summary: The main objective of this package is to centralize logic used to interact with Azure Functions, Azure Service Bus and Azure Table Storage
5
5
  Author: Team Enigma
6
6
  Author-email: enigma@energinet.dk
@@ -17,7 +17,7 @@ warpzone/function/__init__.py,sha256=rJOZBpWsUgjMc7YtXMJ1rLGm45KB1AhDJ_Y2ISiSISc
17
17
  warpzone/function/checks.py,sha256=B9YqThymf16ac_fVAYKilv20ru5v9nwXgHlbxYIaG98,1018
18
18
  warpzone/function/functionize.py,sha256=bSV0QvwKbD9Vo3a_8cc1rgV2rzTdMMvidinyXItBfvs,2128
19
19
  warpzone/function/integrations.py,sha256=sDt2BTx6a4mVc-33wTITP9XQVPustwj7rkX4urTyOqo,4018
20
- warpzone/function/monitor.py,sha256=qBvnSTSX--6_6qccTZrGPO1iS5nz2tNZlHdhE1XBrbs,2214
20
+ warpzone/function/monitor.py,sha256=MsVMUQXn346pqY5l14NZdm4ELOTeHHQLX0_HxKTdx5Q,2293
21
21
  warpzone/function/process.py,sha256=nbUVywM8ChfUwuaqFisgaD98aNRgeZkK4g5sbtuBdRs,2339
22
22
  warpzone/function/processors/__init__.py,sha256=DhIdSWLBcIeSO8IJdxPqGIhgwwnkDN6_Xqwy93BCLeA,46
23
23
  warpzone/function/processors/dependencies.py,sha256=m17BwdKyQEvzCPxpQZpAW5l1uYRIHWmweDz3XJskmpA,1259
@@ -29,7 +29,7 @@ warpzone/healthchecks/__init__.py,sha256=9gc_Mt2szs8sDSwy0V4l3JZ6d9hX41xTpZCkDP2
29
29
  warpzone/healthchecks/model.py,sha256=mM7DnrirLbUpBPPfi82MUPP654D0eOR2_F65TmzsPD0,1187
30
30
  warpzone/monitor/__init__.py,sha256=ggI5fIUu-szgC44ICzuOmpYrIoVOKPbsMT3zza9ssD4,87
31
31
  warpzone/monitor/logs.py,sha256=fabjaB5SfHynvvfp2Js3IG-owqU5jZ3lTnnmTTjD6JM,1320
32
- warpzone/monitor/traces.py,sha256=B_1_fmUNUwHRKB-IYfhWSw5VRluVvn1NQqSYTqNV0wA,4158
32
+ warpzone/monitor/traces.py,sha256=wmpA_6P8Zbb0O07NUg_6MV-Q4Gp0ULRYSNOaWGcM0hw,4087
33
33
  warpzone/servicebus/data/__init__.py,sha256=lnc0uiaGLF0qMi_rWhCpRSFvaj0CJEiMCAl6Yqn1ZiA,21
34
34
  warpzone/servicebus/data/client.py,sha256=zECS3JwedhYnDk8PntYgIYpBF_uu9YN38KzpPFK7CKs,6511
35
35
  warpzone/servicebus/events/__init__.py,sha256=lnc0uiaGLF0qMi_rWhCpRSFvaj0CJEiMCAl6Yqn1ZiA,21
@@ -52,6 +52,6 @@ warpzone/tools/copy.py,sha256=5fddotMZkXZO8avzUbGOhvs0cp8mce95pNpy0oPVjnQ,2596
52
52
  warpzone/transform/__init__.py,sha256=ruGa7tl-v4ndlWpULE1jSGU_a4_iRc3V6eyNr5xKP9E,27
53
53
  warpzone/transform/data.py,sha256=Abb8PcrgMbbNCJkkIUdtrTHdlY0OfXid387qw1nDpFY,2362
54
54
  warpzone/transform/schema.py,sha256=nbSQtDMvXkyqGKuwhuFCF0WsEDsaNyoPYpMKvbsKlv8,2423
55
- warpzone_sdk-15.0.0.dev4.dist-info/METADATA,sha256=jxPQ1HTdmdO0ePXvZAFg58OmIGw38qssEwnc6o9eTAI,7398
56
- warpzone_sdk-15.0.0.dev4.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
57
- warpzone_sdk-15.0.0.dev4.dist-info/RECORD,,
55
+ warpzone_sdk-15.0.0.dev5.dist-info/METADATA,sha256=0AcIiN1etcw_7hPsWEDb4fsaHm5MkWtwEgPq0HYu7GM,7398
56
+ warpzone_sdk-15.0.0.dev5.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
57
+ warpzone_sdk-15.0.0.dev5.dist-info/RECORD,,