public static IHerculesTagsBuilder AddLogEventData( this IHerculesEventBuilder builder, LogEvent @event, IReadOnlyCollection <string> filteredProperties, IFormatProvider formatProvider) { builder .SetTimestamp(@event.Timestamp) .AddValue(LogEventTagNames.UtcOffset, @event.Timestamp.Offset.Ticks) .AddValue(LogEventTagNames.Level, @event.Level.ToString()) .AddValue(LogEventTagNames.Message, LogMessageFormatter.Format(@event, formatProvider)); if (@event.MessageTemplate != null) { builder.AddValue(LogEventTagNames.MessageTemplate, @event.MessageTemplate); } if (@event.Exception != null) { builder.AddContainer( LogEventTagNames.Exception, tagsBuilder => tagsBuilder.AddExceptionData(@event.Exception)); if (@event.Exception.StackTrace != null) { builder.AddValue(LogEventTagNames.StackTrace, @event.Exception.ToString()); } } if (@event.Properties != null) { builder.AddContainer( LogEventTagNames.Properties, tagsBuilder => tagsBuilder.AddProperties(@event, filteredProperties, formatProvider)); } return(builder); }
public static void Build([NotNull] ISpan span, [NotNull] IHerculesEventBuilder builder, [CanBeNull] IFormatProvider formatProvider = null) { builder.SetTimestamp(span.EndTimestamp ?? span.BeginTimestamp); builder .AddValue(TagNames.TraceId, span.TraceId) .AddValue(TagNames.SpanId, span.SpanId) .AddValue(TagNames.BeginTimestampUtc, EpochHelper.ToUnixTimeUtcTicks(span.BeginTimestamp.UtcDateTime)) .AddValue(TagNames.BeginTimestampUtcOffset, span.BeginTimestamp.Offset.Ticks); if (span.ParentSpanId.HasValue) { builder.AddValue(TagNames.ParentSpanId, span.ParentSpanId.Value); } if (span.EndTimestamp.HasValue) { builder.AddValue(TagNames.EndTimestampUtc, EpochHelper.ToUnixTimeUtcTicks(span.EndTimestamp.Value.UtcDateTime)); builder.AddValue(TagNames.EndTimestampUtcOffset, span.EndTimestamp.Value.Offset.Ticks); } builder.AddContainer(TagNames.Annotations, tagBuilder => BuildAnnotationsContainer(tagBuilder, span, formatProvider)); }