Skip to content

Commit d0fa710

Browse files
committed
added type safety
1 parent 45d6406 commit d0fa710

File tree

1 file changed

+8
-3
lines changed
  • sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/logs

1 file changed

+8
-3
lines changed

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/logs/_exporter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,14 @@ def _convert_log_to_envelope(log_data: LogData) -> TelemetryItem:
128128
envelope.tags[ContextTagKeys.AI_OPERATION_PARENT_ID] = "{:016x}".format( # type: ignore
129129
log_record.span_id or _DEFAULT_SPAN_ID
130130
)
131-
envelope.tags[ContextTagKeys.AI_OPERATION_NAME] = log_record.attributes.get( # type: ignore
132-
ContextTagKeys.AI_OPERATION_NAME
133-
)
131+
if (
132+
log_record.attributes
133+
and ContextTagKeys.AI_OPERATION_NAME in log_record.attributes
134+
and log_record.attributes[ContextTagKeys.AI_OPERATION_NAME] is not None
135+
):
136+
envelope.tags[ContextTagKeys.AI_OPERATION_NAME] = log_record.attributes.get( # type: ignore
137+
ContextTagKeys.AI_OPERATION_NAME
138+
)
134139
if _utils._is_any_synthetic_source(log_record.attributes):
135140
envelope.tags[ContextTagKeys.AI_OPERATION_SYNTHETIC_SOURCE] = "True" # type: ignore
136141
# Special use case: Customers want to be able to set location ip on log records

0 commit comments

Comments
 (0)