Пример #1
0
        public async Task GetTraceDetailsWithPojo()
        {
            Sdk <StateExample> sdk     = GetSdk <StateExample>();
            string             traceId = "5ef3faed-9445-434e-acd5-a20cfa0284b1";

            GetTraceDetailsInput input = new GetTraceDetailsInput(traceId, 5, null, null, null);

            TraceDetails <HeadLinkData> details = await sdk.GetTraceDetailsAsync <HeadLinkData>(input);

            Console.WriteLine(JsonHelper.ToJson(details));
        }
Пример #2
0
        public async Task GetTraceDetailsWithPojo()
        {
            Sdk <StateExample> sdk = GetSdk <StateExample>();

            GetTraceDetailsInput input = new GetTraceDetailsInput(config.TRACE_ID, 5, null, null, null);

            TraceDetails <StateExample> details = await sdk.GetTraceDetailsAsync <StateExample>(input);

            Debug.WriteLine(JsonHelper.ToJson(details));
            Assert.NotNull(details);
        }
Пример #3
0
        public async Task GetTraceDetails()
        {
            var    sdk     = GetSdk();
            string traceId = "a41257f9-2d9d-4d42-ab2a-fd0c83ea31df";

            GetTraceDetailsInput input = new GetTraceDetailsInput(traceId, 5, null, null, null);

            TraceDetails <object> details = await sdk.GetTraceDetailsAsync <object>(input);

            Console.WriteLine(JsonHelper.ToJson(details));
        }
Пример #4
0
        public async Task GetTraceDetails()
        {
            var    sdk     = GetSdk();
            string traceId = config.TRACE_ID;

            GetTraceDetailsInput input = new GetTraceDetailsInput(traceId, 5, null, null, null);

            TraceDetails <object> details = await sdk.GetTraceDetailsAsync <object>(input);

            Debug.WriteLine(JsonHelper.ToJson(details));
            Assert.NotNull(details);
        }
        protected override void WriteTrace(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message, Guid?relatedActivityId, object[] data)
        {
            lock (_eventsLock)
            {
                var activityId = Trace.CorrelationManager.ActivityId;
                var traceTime  = (eventCache == null) ? DateTimeOffset.UtcNow : eventCache.DateTime;

                // Want to clone/copy all mutable objects (specifically LogicalOperationStack and data) to preserve their value at the time of the trace.
                // This is done by converting the values to string format, similar to how output to a stream, database or the Windows Event Log would occur.

                var currentStack = (eventCache == null)
                                ? Trace.CorrelationManager.LogicalOperationStack
                                : eventCache.LogicalOperationStack;
                // Want to copy the stack as the original object will change.
                // Also, don't need stack behaviour (push, pop) for the copy -- just want a record of the contents at the time.
                var recordedStack = new List <string>(currentStack.Count);
                lock (currentStack.SyncRoot)
                {
                    foreach (var stackItem in currentStack)
                    {
                        recordedStack.Add(stackItem.ToString());
                    }
                }

                List <string> recordedData = new List <string>();
                if (data != null)
                {
                    lock (data.SyncRoot)
                    {
                        foreach (var dataItem in data)
                        {
                            recordedData.Add(dataItem.ToString());
                        }
                    }
                }

                var trace = new TraceDetails(traceTime, source, activityId, eventType, id, message, relatedActivityId, recordedStack.ToArray(), recordedData.ToArray());

                _events[_current] = trace;
                _current++;
                if (_current >= _events.Length)
                {
                    _current = 0;
                }
            }
        }
        protected override void WriteTrace(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message, Guid? relatedActivityId, object[] data)
        {
            lock (_eventsLock)
            {
                var activityId = Trace.CorrelationManager.ActivityId;
                var traceTime = (eventCache == null) ? DateTimeOffset.UtcNow : eventCache.DateTime;

                // Want to clone/copy all mutable objects (specifically LogicalOperationStack and data) to preserve their value at the time of the trace.
                // This is done by converting the values to string format, similar to how output to a stream, database or the Windows Event Log would occur.

                var currentStack = (eventCache == null)
                                ? Trace.CorrelationManager.LogicalOperationStack
                                : eventCache.LogicalOperationStack;
                // Want to copy the stack as the original object will change.
                // Also, don't need stack behaviour (push, pop) for the copy -- just want a record of the contents at the time.
                var recordedStack = new List<string>(currentStack.Count);
                lock (currentStack.SyncRoot)
                {
                    foreach (var stackItem in currentStack)
                    {
                        recordedStack.Add(stackItem.ToString());
                    }
                }

                List<string> recordedData = new List<string>();
                if (data != null)
                {
                    lock (data.SyncRoot)
                    {
                        foreach (var dataItem in data)
                        {
                            recordedData.Add(dataItem.ToString());
                        }
                    }
                }

                var trace = new TraceDetails(traceTime, source, activityId, eventType, id, message, relatedActivityId, recordedStack.ToArray(), recordedData.ToArray());

                _events[_current] = trace;
                _current++;
                if (_current >= _events.Length)
                {
                    _current = 0;
                }
            }
        }