private IDictionary <string, object> CreateUserAttributes(LambdaSpan span) { var attributes = new Dictionary <string, object>(); var errorKind = span.GetSpanLogEntry("error.kind"); if (errorKind != null) { attributes.Add("error.kind", errorKind.Value); } return(attributes); }
internal void RecordErrors(LambdaSpan span) { var errorEventLogEntry = span.GetSpanLogEntry("event"); if (errorEventLogEntry == null || !"error".Equals(errorEventLogEntry.Value)) { return; } var errorObjectLogEntry = span.GetSpanLogEntry("error.object"); if (errorObjectLogEntry == null) { return; } var errorMessageLogEntry = span.GetSpanLogEntry("message"); var errorObjectIsThrowable = errorObjectLogEntry.Value is Exception; if (errorMessageLogEntry == null && !errorObjectIsThrowable) { return; } var errorClass = errorObjectLogEntry.Value.GetType().Name; var errorMessage = GetErrorMessage(errorMessageLogEntry, errorObjectLogEntry); var userAttributes = CreateUserAttributes(span); var txnState = span.RootSpan.TransactionState; var errorEvent = new ErrorEventBuilder() .SetErrorClass(errorClass) .SetErrorMessage(errorMessage) .SetTransactionDuration(txnState.Duration) .SetTimestamp(errorObjectLogEntry.Timestamp) .SetUserAttributes(userAttributes) .SetTransactionName(txnState.TransactionName) .SetTransactionGuid(txnState.TransactionId) .SetDistributedTraceIntrinsics(span.Intrinsics) .CreateError(); _errorEvents.Add(errorEvent); LogEntry errorStack = span.GetSpanLogEntry("stack"); if (errorStack == null && !errorObjectIsThrowable) { return; } string stackTrace = GetStackTrace(errorStack, errorObjectLogEntry); var errorTrace = new ErrorTraceBuilder() .SetErrorMessage(errorMessage) .SetErrorType(errorClass) .SetTransactionGuid(txnState.TransactionId) .SetTransactionName(txnState.TransactionName) .SetDistributedTraceIntrinsics(span.Intrinsics) .SetUserAttributes(userAttributes) .SetTimestamp(errorObjectLogEntry.Timestamp) .SetStackTrace(stackTrace) .CreateErrorTrace(); _errorTraces.Add(errorTrace); }