private void HandleStart(RabbitMqEvent <RabbitMqHandleParams> evt) { try { var prms = evt.Params; DistributedTracingData tracingData = null; if (prms.Properties != null && prms.Properties.Headers.TryGetValue(Constants.HeaderKey, out object tracingDataBlob) && tracingDataBlob is byte[]) { tracingData = DistributedTracingData.TryDeserializeFromString(Encoding.UTF8.GetString((byte[])tracingDataBlob)); } if (MatchesIgnoreMessageQueues(prms.RoutingKey)) { return; } var transaction = _ApmAgent.Tracer.StartTransaction(prms.RoutingKey, Constants.Type, tracingData); if (!_processingQueries.TryAdd(prms.Id, transaction)) { return; } transaction.SetLabel(nameof(prms.RoutingKey), prms.RoutingKey); transaction.SetLabel(nameof(prms.ConsumerTag), prms.ConsumerTag); transaction.SetLabel(nameof(prms.DeliveryTag), $"{prms.DeliveryTag}"); transaction.SetLabel(nameof(prms.Exchange), prms.Exchange); transaction.SetLabel(nameof(prms.Redelivered), $"{prms.ConsumerTag}"); transaction.SetLabel(nameof(prms.Body), prms.Body != null ? System.Text.Encoding.UTF8.GetString(prms.Body) : string.Empty); } catch { } }
private void HandleSpanStart(ApmSpanScopeParams prms) { if (RabbitMqLogger.IsEnabled(Constants.Events.SpanStart)) { RabbitMqLogger.Write(Constants.Events.SpanStart, RabbitMqEvent <ApmSpanScopeParams> .Success(prms)); } }
private void HandleStart(RabbitMqHandleParams prms) { if (RabbitMqLogger.IsEnabled(Constants.Events.ReceiveStart)) { RabbitMqLogger.Write(Constants.Events.ReceiveStart, RabbitMqEvent <RabbitMqHandleParams> .Success(prms)); } }
private void HandleTraceHeader(RabbitMqEvent <IBasicProperties> evt) { try { var transaction = _ApmAgent.Tracer.CurrentTransaction; if (transaction == null) { return; } evt.Params.Headers.Add(Constants.HeaderKey, Encoding.UTF8.GetBytes(transaction.OutgoingDistributedTracingData?.SerializeToString())); } catch { } }
private void HandleStartSpan(RabbitMqEvent <ApmSpanScopeParams> evt) { try { var transaction = _ApmAgent.Tracer.CurrentTransaction; var currentExecutionSegment = _ApmAgent.Tracer.CurrentSpan ?? (IExecutionSegment)transaction; if (currentExecutionSegment == null) { return; } var span = currentExecutionSegment.StartSpan( evt.Params.Command, Constants.Type); if (!_processingQueries.TryAdd(evt.Params.Id, span)) { return; } } catch { } }
private static void PublishTracingHeader(IBasicProperties basicProperties) { if (basicProperties != null) RabbitMqLogger.Write(Constants.Events.PublishTracingHeader, RabbitMqEvent<IBasicProperties>.Success(basicProperties)); }