private static void BuildAnnotationsContainer(IHerculesTagsBuilder builder, ISpan span, IFormatProvider formatProvider)
        {
            foreach (var pair in span.Annotations)
            {
                if (builder.TryAddObject(pair.Key, pair.Value))
                {
                    continue;
                }

                builder.AddValue(pair.Key, ObjectValueFormatter.Format(pair.Value, formatProvider: formatProvider));
            }
        }
Beispiel #2
0
        public static IHerculesTagsBuilder AddProperties(
            this IHerculesTagsBuilder builder,
            LogEvent @event,
            IReadOnlyCollection <string> filteredProperties,
            IFormatProvider formatProvider)
        {
            foreach (var keyValuePair in @event.Properties !)
            {
                var key = keyValuePair.Key;
                if (IsPositionalName(key))
                {
                    continue;
                }
                if (filteredProperties?.Contains(key) == true)
                {
                    continue;
                }

                var value = keyValuePair.Value;

                if (key == WellKnownProperties.OperationContext && value is OperationContextValue operationContextValue)
                {
                    value = operationContextValue.Select(t => OperationContextValueFormatter.Format(@event, t, null, formatProvider)).ToArray();
                }

                if (builder.TryAddObject(key, value))
                {
                    continue;
                }

                var format = value is DateTime || value is DateTimeOffset ? "O" : null;

                builder.AddValue(key, ObjectValueFormatter.Format(value, format));
            }

            return(builder);
        }