Exemplo n.º 1
0
 /// <summary>
 /// Record an operation stop.
 /// </summary>
 /// <param name="operation">The operation.</param>
 public void ProcessOperationStop(OperationTelemetry operation)
 {
     if (this.EventSourceInternal.IsEnabled(EventLevel.Informational, Keywords.Operations))
     {
         this.WriteEvent(operation, EventOpcode.Stop);
     }
 }
        private static void VerifyOperationEvent(OperationTelemetry expectedOperation, string expectedName, EventOpcode expectedOpCode, EventWrittenEventArgs actualEvent)
        {
            Assert.AreEqual(expectedOpCode, actualEvent.Opcode);
#if !NET45
            Assert.AreEqual(expectedName, actualEvent.EventName);
#endif
            VerifyOperationPayload(expectedOperation, actualEvent.Payload);
        }
 private static void VerifyOperationPayload(OperationTelemetry expected, ReadOnlyCollection <object> actualPayload)
 {
     Assert.IsNotNull(actualPayload);
     Assert.AreEqual(4, actualPayload.Count);
     Assert.AreEqual(expected.Context.InstrumentationKey, actualPayload[0]);
     Assert.AreEqual(expected.Id, actualPayload[1]);
     Assert.AreEqual(expected.Name, actualPayload[2]);
     Assert.AreEqual(expected.Context.Operation.Id, actualPayload[3]);
 }
        /// <summary>
        /// Record an operation stop.
        /// </summary>
        /// <param name="operation">The operation which has just stopped.</param>
        public void ProcessOperationStop(OperationTelemetry operation)
        {
            if (this.EventSourceInternal == null)
            {
                return;
            }

            if (this.EventSourceInternal.IsEnabled(EventLevel.Informational, Keywords.Operations))
            {
                this.operationStartStopHandler(operation, EventOpcode.Stop);
            }
        }
Exemplo n.º 5
0
        private void WriteEvent(OperationTelemetry item, EventOpcode eventOpCode)
        {
            var payload = new { IKey = item.Context.InstrumentationKey, Id = item.Id, Name = item.Name, RootId = item.Context.Operation.Id };

            if (item is RequestTelemetry)
            {
                this.EventSourceInternal.Write(
                    RequestTelemetry.TelemetryName,
                    new EventSourceOptions {
                    Keywords = Keywords.Operations, Opcode = eventOpCode, Level = EventLevel.Informational
                },
                    payload);
            }
            else
            {
                this.EventSourceInternal.Write(
                    OperationTelemetry.TelemetryName,
                    new EventSourceOptions {
                    ActivityOptions = EventActivityOptions.Recursive, Keywords = Keywords.Operations, Opcode = eventOpCode, Level = EventLevel.Informational
                },
                    payload);
            }
        }