Skip to content

Commit

Permalink
Simplify global log attribute application code
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzybinary committed Mar 5, 2024
1 parent 736c82f commit 5fe9530
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal class LogsFeature(
@Suppress("UnsafeThirdPartyFunctionCall") // NPE cannot happen here
return attributes.toMap()
}

// endregion

// region Feature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ internal class DatadogLogHandler(
}

val resolvedTimeStamp = timestamp ?: System.currentTimeMillis()
var combinedAttributes = attributes
val combinedAttributes = mutableMapOf<String, Any?>()
val logsFeature = sdkCore.getFeature(Feature.LOGS_FEATURE_NAME)
if (logsFeature != null) {
combinedAttributes = logsFeature.unwrap<LogsFeature>().getAttributes().toMutableMap()
combinedAttributes.putAll(attributes)
combinedAttributes.putAll(logsFeature.unwrap<LogsFeature>().getAttributes().toMutableMap())
}
combinedAttributes.putAll(attributes)

if (sampler.sample()) {
if (logsFeature != null) {
val threadName = Thread.currentThread().name
Expand Down

0 comments on commit 5fe9530

Please sign in to comment.