warpzone-sdk 15.0.0.dev1__py3-none-any.whl → 15.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.
@@ -1,15 +1,25 @@
1
- import asyncio
1
+ import inspect
2
2
  from contextlib import contextmanager
3
3
  from typing import Callable
4
4
 
5
5
  import azure.functions as func
6
6
  from azure.monitor.opentelemetry import configure_azure_monitor
7
+ from opentelemetry import trace
7
8
 
8
9
  from warpzone.function.types import SingleArgumentCallable
9
10
  from warpzone.monitor import logs, traces
10
11
 
12
+ # Configure Azure Monitor first
11
13
  configure_azure_monitor()
12
14
 
15
+ # Apply trace filtering to suppress all Azure SDK traces except Service Bus
16
+ tracer_provider = trace.get_tracer_provider()
17
+ if hasattr(tracer_provider, "_active_span_processor"):
18
+ # Wrap the existing span processor with our filter
19
+ original_processor = tracer_provider._active_span_processor
20
+ filtered_processor = traces.AzureSDKTraceFilter(original_processor)
21
+ tracer_provider._active_span_processor = filtered_processor
22
+
13
23
  SUBJECT_IDENTIFIER = "<Subject>"
14
24
 
15
25
  tracer = traces.get_tracer(__name__)
@@ -54,7 +64,7 @@ def monitor(main: SingleArgumentCallable) -> Callable:
54
64
  result = main(arg)
55
65
  return result
56
66
 
57
- if asyncio.iscoroutinefunction(main):
67
+ if inspect.iscoroutinefunction(main):
58
68
  return wrapper_async
59
69
  else:
60
70
  return wrapper
@@ -2,11 +2,59 @@ from contextlib import contextmanager
2
2
 
3
3
  from azure.core.settings import settings
4
4
  from opentelemetry import context, trace
5
+ from opentelemetry.sdk.trace import ReadableSpan, SpanProcessor
5
6
  from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
6
7
 
7
8
  settings.tracing_implementation = "opentelemetry"
8
9
 
9
10
 
11
+ class AzureSDKTraceFilter(SpanProcessor):
12
+ """Custom SpanProcessor to filter out Azure SDK traces except Service Bus.
13
+
14
+ It drops spans from Azure SDK libraries except Service Bus messages,
15
+ preventing them from being exported to Azure Monitor.
16
+ """
17
+
18
+ def __init__(self, wrapped_processor: SpanProcessor):
19
+ """Initialize with the actual processor to wrap.
20
+
21
+ Args:
22
+ wrapped_processor: The underlying processor (e.g., BatchSpanProcessor)
23
+ """
24
+ self.wrapped_processor = wrapped_processor
25
+
26
+ def on_start(
27
+ self, span: ReadableSpan, parent_context: context.Context = None
28
+ ) -> None:
29
+ """Called when a span is started."""
30
+ self.wrapped_processor.on_start(span, parent_context)
31
+
32
+ def on_end(self, span: ReadableSpan) -> None:
33
+ """Called when a span is ended. Filter based on span attributes."""
34
+ # Check if service bus span - always allow
35
+ if "servicebus.message" in span.name.lower():
36
+ self.wrapped_processor.on_end(span)
37
+ return
38
+
39
+ # Check if this is an Azure SDK span we want to suppress
40
+ instrumentation_scope = span.instrumentation_scope
41
+ if instrumentation_scope and instrumentation_scope.name:
42
+ # Suppress spans from Azure SDK libraries
43
+ if instrumentation_scope.name.startswith("azure."):
44
+ return # Drop this span
45
+
46
+ # Pass through all other spans
47
+ self.wrapped_processor.on_end(span)
48
+
49
+ def shutdown(self) -> None:
50
+ """Shutdown the wrapped processor."""
51
+ self.wrapped_processor.shutdown()
52
+
53
+ def force_flush(self, timeout_millis: int = 30000) -> bool:
54
+ """Force flush the wrapped processor."""
55
+ return self.wrapped_processor.force_flush(timeout_millis)
56
+
57
+
10
58
  @contextmanager
11
59
  def set_trace_context(trace_parent: str, trace_state: str = ""):
12
60
  """Context manager for setting the trace context
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warpzone-sdk
3
- Version: 15.0.0.dev1
3
+ Version: 15.0.0.dev2
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=-WnbllgphJs1JRn_UxkLDHALM2UlrtEwy4ORh8eJ-xI,1660
20
+ warpzone/function/monitor.py,sha256=F7_eRq0XjsAOvOHgURguFU0FozC8jXt_ev8CyhkOgms,2157
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=V1A2ImqbPo4c-hDr2qWAZlpr2muyVar30eI9mF2_rzE,986
32
- warpzone/monitor/traces.py,sha256=SQckLC4LCEbgg79ZBnmYcm26IaxJfHDQ9GV7Huh2Uls,1393
32
+ warpzone/monitor/traces.py,sha256=PhhYeZlPc7EOSq9KVsHdKOwEIivDHCV-RwZnDNVL7ic,3244
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.dev1.dist-info/METADATA,sha256=U7Mz9332k6VsVXQitNaurDeed-oD4QBFyEmPaMWJexM,7398
56
- warpzone_sdk-15.0.0.dev1.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
57
- warpzone_sdk-15.0.0.dev1.dist-info/RECORD,,
55
+ warpzone_sdk-15.0.0.dev2.dist-info/METADATA,sha256=bYOwFSbmKdxOJO06Uv7jlMskEFAxwRVsbiG8BeNNq0Y,7398
56
+ warpzone_sdk-15.0.0.dev2.dist-info/WHEEL,sha256=3ny-bZhpXrU6vSQ1UPG34FoxZBp3lVcvK0LkgUz6VLk,88
57
+ warpzone_sdk-15.0.0.dev2.dist-info/RECORD,,