Esempio n. 1
0
        public ITracingState AcceptDistributedTracePayload(string serializedPayload, TransportType transportType, DateTime transactionStartTime)
        {
            var tracingState = TracingState.AcceptDistributedTracePayload(serializedPayload, transportType, _configurationService.Configuration.TrustedAccountKey, transactionStartTime);

            if (tracingState.IngestErrors != null)
            {
                ReportIncomingErrors(tracingState.IngestErrors);
            }
            else
            {
                if (_configurationService.Configuration.PayloadSuccessMetricsEnabled)
                {
                    _agentHealthReporter.ReportSupportabilityDistributedTraceAcceptPayloadSuccess();
                }
            }

            return(tracingState);
        }
Esempio n. 2
0
        public void AcceptDistributedTraceHeadersHydratesValidNewRelicPayload()
        {
            var encodedPayload = DistributedTracePayload.SerializeAndEncodeDistributedTracePayload(BuildSampleDistributedTracePayload());

            var headers = new Dictionary <string, string>()
            {
                { NewRelicPayloadHeaderName, encodedPayload }
            };

            var tracingState = TracingState.AcceptDistributedTraceHeaders(carrier: headers, getter: GetHeader, transportType: TransportType.AMQP, agentTrustKey: TrustKey, transactionStartTime: DateTime.UtcNow.Add(TimeSpan.FromMilliseconds(1)));

            Assert.IsNotNull(tracingState);
            Assert.AreEqual(Type, tracingState.Type);
            Assert.AreEqual(AccountId, tracingState.AccountId);
            Assert.AreEqual(AppId, tracingState.AppId);
            Assert.AreEqual(Guid, tracingState.Guid);
            Assert.AreEqual(TraceId, tracingState.TraceId);
            Assert.AreEqual(Priority, tracingState.Priority);
            Assert.AreEqual(Sampled, tracingState.Sampled);
            Assert.AreEqual(TransactionId, tracingState.TransactionId);
            Assert.IsTrue(tracingState.Timestamp != default, $"Timestamp should not be {(DateTime)default}");
Esempio n. 3
0
        public ITracingState AcceptDistributedTraceHeaders <T>(T carrier, Func <T, string, IEnumerable <string> > getter, TransportType transportType, DateTime transactionStartTime)
        {
            if (getter == null)
            {
                Log.Debug("getHeaders argument is null.");
                return(null);
            }

            try
            {
                var tracingState = TracingState.AcceptDistributedTraceHeaders(carrier, getter, transportType, _configurationService.Configuration.TrustedAccountKey, transactionStartTime);

                if (tracingState?.IngestErrors != null)
                {
                    ReportIncomingErrors(tracingState.IngestErrors);
                }

                if (_configurationService.Configuration.PayloadSuccessMetricsEnabled)
                {
                    if (tracingState?.NewRelicPayloadWasAccepted == true)
                    {
                        _agentHealthReporter.ReportSupportabilityDistributedTraceAcceptPayloadSuccess();
                    }

                    if (tracingState?.TraceContextWasAccepted == true)
                    {
                        _agentHealthReporter.ReportSupportabilityTraceContextAcceptSuccess();
                    }
                }

                return(tracingState);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(null);
            }
        }