Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use Object.fromEntries instead of reduce
  • Loading branch information
Lms24 committed Dec 18, 2025
commit 75bff04ff8581d718c62df7c204f4de11478a19e
29 changes: 12 additions & 17 deletions packages/core/src/logs/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,25 @@ export function _INTERNAL_captureLog(

const { level, message, attributes: logAttributes = {}, severityNumber } = log;

const serializedScopeAttributes = Object.fromEntries(
Object.entries(scopeAttributes)
.map(([key, value]) => [key, attributeValueToTypedAttributeValue(value)])
.filter(([_, value]) => value != null),
);
Comment thread
Lms24 marked this conversation as resolved.
Outdated

const serializedLogAttributes = Object.fromEntries(
Object.entries(logAttributes).map(([key, value]) => [key, attributeValueToTypedAttributeValue(value, true)]),
);

const serializedLog: SerializedLog = {
timestamp: timestampInSeconds(),
level,
body: message,
trace_id: traceContext?.trace_id,
severity_number: severityNumber ?? SEVERITY_TEXT_TO_SEVERITY_NUMBER[level],
attributes: {
...Object.keys(scopeAttributes).reduce(
(acc, key) => {
const attributeValue = attributeValueToTypedAttributeValue(scopeAttributes[key]);
if (attributeValue) {
acc[key] = attributeValue;
}
return acc;
},
{} as Record<string, TypedAttributeValue>,
),
...Object.keys(logAttributes).reduce(
(acc, key) => {
acc[key] = attributeValueToTypedAttributeValue(logAttributes[key], true);
return acc;
},
{} as Record<string, TypedAttributeValue>,
),
...serializedScopeAttributes,
...serializedLogAttributes,
},
Comment thread
Lms24 marked this conversation as resolved.
Comment thread
Lms24 marked this conversation as resolved.
};

Expand Down