azpaddypy 0.5.7__py3-none-any.whl → 0.5.9__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
@@ -11,6 +11,7 @@ from opentelemetry import trace
11
11
  from opentelemetry.trace import Status, StatusCode, Span
12
12
  from opentelemetry import baggage
13
13
  from opentelemetry.context import Context
14
+ from opentelemetry.sdk.resources import Resource
14
15
 
15
16
 
16
17
  class AzureLogger:
@@ -81,12 +82,12 @@ class AzureLogger:
81
82
  effective_cloud_role_name = cloud_role_name or service_name
82
83
  self.cloud_role_name = effective_cloud_role_name
83
84
 
84
- # Configure resource attributes
85
- # NOTE: service.name automatically maps to cloud role name in Application Insights
85
+ # Configure resource attributes according to Azure Monitor OpenTelemetry best practices
86
+ # NOTE: Azure Monitor cloud role name uses service.namespace + service.name,
87
+ # or falls back to service.name if service.namespace isn't set
86
88
  resource_attributes = {
87
89
  "service.name": effective_cloud_role_name,
88
90
  "service.version": service_version,
89
- "service.instance.id": os.getenv("WEBSITE_INSTANCE_ID", "local"),
90
91
  }
91
92
 
92
93
  if custom_resource_attributes:
@@ -95,9 +96,13 @@ class AzureLogger:
95
96
  # Configure Azure Monitor if connection string available
96
97
  if self.connection_string:
97
98
  try:
99
+ # Create a Resource with the attributes to ensure they're properly applied
100
+ # This ensures Azure Monitor correctly maps service.name to cloud role name
101
+ resource = Resource.create(resource_attributes)
102
+
98
103
  configure_azure_monitor(
99
104
  connection_string=self.connection_string,
100
- resource_attributes=resource_attributes,
105
+ resource=resource,
101
106
  enable_live_metrics=True,
102
107
  instrumentation_options=instrumentation_options,
103
108
  )
@@ -122,6 +127,7 @@ class AzureLogger:
122
127
  # Initialize OpenTelemetry tracer and correlation context
123
128
  self.tracer = trace.get_tracer(__name__)
124
129
  self._correlation_id = None
130
+
125
131
 
126
132
  self.info(
127
133
  f"Azure Logger initialized for service '{service_name}' v{service_version} "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azpaddypy
3
- Version: 0.5.7
3
+ Version: 0.5.9
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
@@ -2,11 +2,11 @@ azpaddypy/__init__.py,sha256=hrWNAh4OHZOvm3Pbhq5eUjO-pSRYn0h0W0J87tc-lNI,45
2
2
  azpaddypy/mgmt/__init__.py,sha256=waW9EAnTFDh2530ieQX1Z0r0Z-ZKHRwabVDfapjfN58,441
3
3
  azpaddypy/mgmt/identity.py,sha256=mA_krQslMsK_sDob-z-QA0B9khK_JUO2way7xwPopR8,12001
4
4
  azpaddypy/mgmt/local_env_manager.py,sha256=WHXJXHQFGwkgr96YkEtqpgFUxmCjBa5pArbNxZUSKQk,7762
5
- azpaddypy/mgmt/logging.py,sha256=56OR4Q1YEHoGcPJLt2wFslQh8jaZQ-ptCpvQwWPellc,36618
5
+ azpaddypy/mgmt/logging.py,sha256=iuoYxwliBFmHKEZh30FYlGBFwlhic_yFmOi18gFjTEE,36962
6
6
  azpaddypy/resources/__init__.py,sha256=Bvt3VK4RqwoxYpoh6EbLXIR18RuFPKaLP6zLL-icyFk,314
7
7
  azpaddypy/resources/keyvault.py,sha256=4J08vLqoLFd1_UUDBji2oG2fatZaPkgnRyT_Z6wHAOc,20312
8
- azpaddypy-0.5.7.dist-info/licenses/LICENSE,sha256=hQ6t0g2QaewGCQICHqTckBFbMVakGmoyTAzDpmEYV4c,1089
9
- azpaddypy-0.5.7.dist-info/METADATA,sha256=RIImL-MZOxfvYvlhOVvQs5t5LMCHytI5dueXyxfvUyk,665
10
- azpaddypy-0.5.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- azpaddypy-0.5.7.dist-info/top_level.txt,sha256=hsDuboDhT61320ML8X479ezSTwT3rrlDWz1_Z45B2cs,10
12
- azpaddypy-0.5.7.dist-info/RECORD,,
8
+ azpaddypy-0.5.9.dist-info/licenses/LICENSE,sha256=hQ6t0g2QaewGCQICHqTckBFbMVakGmoyTAzDpmEYV4c,1089
9
+ azpaddypy-0.5.9.dist-info/METADATA,sha256=5PkaGLqbgBlFbaVjAt6hokzh1n6FtyGjnXhF5bsfx-I,665
10
+ azpaddypy-0.5.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ azpaddypy-0.5.9.dist-info/top_level.txt,sha256=hsDuboDhT61320ML8X479ezSTwT3rrlDWz1_Z45B2cs,10
12
+ azpaddypy-0.5.9.dist-info/RECORD,,