private static Dictionary <string, string> BuildIndexRecord(AirlockEvent <LogEventData> @event, string service) { var indexRecord = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase) { ["Level"] = @event.Payload.Level.ToString(), ["@timestamp"] = @event.Payload.Timestamp.ToString("O"), ["@service"] = service, }; if (!string.IsNullOrEmpty(@event.Payload.Message)) { indexRecord.Add("Message", @event.Payload.Message); } if (@event.Payload.Exceptions != null && @event.Payload.Exceptions.Count > 0) { var exception = string.Join("\n ---\n", @event.Payload.Exceptions).Truncate(maxExceptionLength); indexRecord.Add("Exception", exception); } if (@event.Payload.Properties != null) { foreach (var kvp in @event.Payload.Properties) { if (!indexRecord.ContainsKey(kvp.Key)) { indexRecord.Add(kvp.Key, kvp.Value); } } } return(indexRecord); }
private void ProcessEvent(AirlockEvent <Span> @event, ProcessorMetrics processorMetrics) { try { contrailsClient.AddSpan(@event.Payload).GetAwaiter().GetResult(); processorMetrics.EventProcessedCounter.Add(); } catch (Exception e) { processorMetrics.EventFailedCounter.Add(); processorMetrics.SendingErrorCounter.Add(); log.Error(e); } }
private MetricEvent TryGetMetricEvent(AirlockEvent <byte[]> airlockEvent) { if (RoutingKey.LastSuffixMatches(airlockEvent.RoutingKey, RoutingKey.AppEventsSuffix)) { return(metricEventSerializer.Deserialize(new ByteBufferAirlockSource(airlockEvent.Payload))); } if (RoutingKey.LastSuffixMatches(airlockEvent.RoutingKey, RoutingKey.TracesSuffix)) { var span = spanAirlockSerializer.Deserialize(new ByteBufferAirlockSource(airlockEvent.Payload)); if (span.EndTimestamp.HasValue && span.Annotations.TryGetValue(TracingAnnotationNames.Kind, out var kind) && kind == "http-server") { return(span.ToMetricEvent()); } return(null); } throw new InvalidOperationException($"Payload type is not recognized for routingKey: {airlockEvent.RoutingKey}"); }