Skip to content

Commit 3255510

Browse files
committed
fix(trace): Crash if no attribute mapping defined
Fix #14
1 parent 809484d commit 3255510

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/opentelemetry-node.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,13 @@ function endSpan (msg, error, nodeDefinition) {
284284
span.setStatus({ code: SpanStatusCode.ERROR, message: error })
285285
}
286286
const localAttributes = parseAttribute(true, msg, nodeDefinition.z, nodeDefinition.type)
287-
for (const [key, value] of Object.entries(localAttributes)) {
288-
span.setAttribute(key, value)
289-
}
290-
if (_isLogging) {
291-
console.log(`Local span attributes (end) for ${nodeDefinition.id}, ${nodeDefinition.type}: ${JSON.stringify(localAttributes)}`)
287+
if (localAttributes !== undefined) {
288+
for (const [key, value] of Object.entries(localAttributes)) {
289+
span.setAttribute(key, value)
290+
}
291+
if (_isLogging) {
292+
console.log(`Local span attributes (end) for ${nodeDefinition.id}, ${nodeDefinition.type}: ${JSON.stringify(localAttributes)}`)
293+
}
292294
}
293295
span.end()
294296
const currentSpanCreationTimestamp = span._creationTimestamp

0 commit comments

Comments
 (0)