Skip to content

Commit f7bd4da

Browse files
committed
fix: CDS-2533 - blob-to-otel fix stroage account name
1 parent 55cad0c commit f7bd4da

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

BlobToOtel/BlobToOtel/index.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,23 @@ const eventHubTrigger = async function (context: InvocationContext, eventHubMess
120120
if (!line || !line.trim()) continue; // Skip empty lines
121121

122122
try {
123+
const storageAccountName = event.topic ? event.topic.split('/').pop() : urlParts.hostname.split('.')[0];
124+
const attributes: any = {
125+
'log.type': 'BlobLogRecord',
126+
'blob.container': containerName,
127+
'blob.path': blobPath,
128+
'blob.storage.account': storageAccountName
129+
};
130+
131+
if (event.data?.contentLength) {
132+
attributes['blob.size'] = event.data.contentLength;
133+
}
134+
123135
logger.emit({
124136
severityNumber: logsAPI.SeverityNumber.INFO,
125137
severityText: 'INFO',
126138
body: line,
127-
attributes: {
128-
'log.type': 'BlobLogRecord',
129-
'blob.container': containerName,
130-
'blob.path': blobPath,
131-
'blob.storage.account': event.topic.split('/').pop(),
132-
'blob.size': event.data.contentLength
133-
}
139+
attributes
134140
});
135141
processedLines++;
136142
} catch (lineError) {

0 commit comments

Comments
 (0)