当前位置: 首页>>代码示例>>C#>>正文


C# DataContracts.EventTelemetry类代码示例

本文整理汇总了C#中Microsoft.ApplicationInsights.DataContracts.EventTelemetry的典型用法代码示例。如果您正苦于以下问题:C# EventTelemetry类的具体用法?C# EventTelemetry怎么用?C# EventTelemetry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventTelemetry类属于Microsoft.ApplicationInsights.DataContracts命名空间,在下文中一共展示了EventTelemetry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Dispose

        private bool disposedValue = false; // To detect redundant calls

        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    var eventTelemetry = new EventTelemetry(_eventName)
                    {
                        Timestamp = _startTime,
                    };

                    this.Properties.ToList().ForEach(p => eventTelemetry.Properties.Add(p));

                    this.Metrics.ToList().ForEach(m => eventTelemetry.Metrics.Add(m));
                    eventTelemetry.Metrics.Add(string.Concat(_eventName, "_Duration"),
                        (DateTime.UtcNow - _startTime).TotalMilliseconds);

                    _client.TrackEvent(eventTelemetry);
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
开发者ID:genesissupsup,项目名称:DesktopApplicationInsights,代码行数:32,代码来源:TimedTelemetryEvent.cs

示例2: button2_Click

 private void button2_Click(object sender, RoutedEventArgs e)
 {
     var ev = new EventTelemetry("button2");
     ev.Properties["click_time"] = DateTime.Now.ToString(CultureInfo.InvariantCulture.DateTimeFormat);
     tc.TrackEvent(ev);
     tc.Flush();
 }
开发者ID:daniel-kun,项目名称:AppInsightsTutorial,代码行数:7,代码来源:MainWindow.xaml.cs

示例3: Emit

        /// <summary>
        /// Emit the provided log event to the sink.
        /// </summary>
        /// <param name="logEvent">The log event to write.</param>
        public void Emit(LogEvent logEvent)
        {
            var renderedMessage = logEvent.RenderMessage(_formatProvider);
            
            // take logEvent and use it for the corresponding ITelemetry counterpart
            if (logEvent.Exception != null)
            {
                var exceptionTelemetry = new ExceptionTelemetry(logEvent.Exception)
                {
                    SeverityLevel = logEvent.Level.ToSeverityLevel(),
                    HandledAt = ExceptionHandledAt.UserCode,
                    Timestamp = logEvent.Timestamp
                };
                
                // write logEvent's .Properties to the AI one
                ForwardLogEventPropertiesToTelemetryProperties(exceptionTelemetry, logEvent, renderedMessage);

                _telemetryClient.TrackException(exceptionTelemetry);
            }
            else
            {
                var eventTelemetry = new EventTelemetry(logEvent.MessageTemplate.Text)
                {
                    Timestamp = logEvent.Timestamp
                };
                
                // write logEvent's .Properties to the AI one
                ForwardLogEventPropertiesToTelemetryProperties(eventTelemetry, logEvent, renderedMessage);
                
                _telemetryClient.TrackEvent(eventTelemetry);
            }
        }
开发者ID:alexvaluyskiy,项目名称:serilog-sinks-applicationinsights,代码行数:36,代码来源:ApplicationInsightsSink.cs

示例4: SetsClientIpFromWcfContextOnOtherEvent

        public void SetsClientIpFromWcfContextOnOtherEvent()
        {
            const String originalIp = "10.12.32.12";
            const String newIp = "172.34.12.45";
            var context = new MockOperationContext();
            context.IncomingProperties.Add(
                RemoteEndpointMessageProperty.Name,
                new RemoteEndpointMessageProperty(originalIp, 7656));

            var initializer = new ClientIpTelemetryInitializer();

            // initialize request with the original IP
            initializer.Initialize(context.Request, context);

            // replace IP so that we can tell
            // it is being picked up from the request
            // rather than the context
            context.IncomingProperties.Clear();
            context.IncomingProperties.Add(
                RemoteEndpointMessageProperty.Name,
                new RemoteEndpointMessageProperty(newIp, 7656));

            var telemetry = new EventTelemetry("myevent");
            initializer.Initialize(telemetry, context);

            Assert.AreEqual(originalIp, telemetry.Context.Location.Ip);
        }
开发者ID:xornand,项目名称:ApplicationInsights-SDK-Labs,代码行数:27,代码来源:ClientIpTelemetryInitializerTests.cs

示例5: InitializeSetsDateTime

        public void InitializeSetsDateTime()
        {
            EventTelemetry telemetry = new EventTelemetry("TestEvent");

            new TelemetryClient().Initialize(telemetry);

            Assert.True(telemetry.Timestamp != default(DateTimeOffset));
        }
开发者ID:ZeoAlliance,项目名称:ApplicationInsights-dotnet,代码行数:8,代码来源:TelemetryClientTest.cs

示例6: ReportEvent

 /// <summary>
 /// Reports an event with a string data to the telemetry system.
 /// </summary>
 /// <param name="eventName"></param>
 public void ReportEvent(object component, string eventName, string data)
 {
     TelemetryClient client = new TelemetryClient();
     EventTelemetry eventT = new EventTelemetry();
     eventT.Name = component.GetType().Name + ":" + eventName;
     eventT.Properties.Add("data", data);
     client.TrackEvent(eventName);
 }
开发者ID:Arthur-Lee,项目名称:Baconit,代码行数:12,代码来源:TelemetryManager.cs

示例7: SerializeWritesNullValuesAsExpectedByEndpoint

        public void SerializeWritesNullValuesAsExpectedByEndpoint()
        {
            EventTelemetry original = new EventTelemetry();
            original.Name = null;
            ((ITelemetry)original).Sanitize();
            var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<EventTelemetry, DataPlatformModel.EventData>(original);

            Assert.Equal(2, item.Data.BaseData.Ver);
        }
开发者ID:Assaf-Neufeld,项目名称:ApplicationInsights-dotnet,代码行数:9,代码来源:EventTelemetryTest.cs

示例8: EventTelemetryMessage

 public EventTelemetryMessage(EventTelemetry telemetry)
 {
     this.Time = telemetry.Timestamp.DateTime;
     this.Name = telemetry.Name;
     this.Details = null;
     this.Properties = telemetry.Properties.Count > 0 ? telemetry.Properties : null;
     this.Type = "Event";
     this.Context = telemetry.Context;
 }
开发者ID:Glimpse,项目名称:Glimpse.ApplicationInsights,代码行数:9,代码来源:EventTelemetryMessage.cs

示例9: InitializeSetsLocationIpToUserHostAddressIfNoHeadersInRequest

        public void InitializeSetsLocationIpToUserHostAddressIfNoHeadersInRequest()
        {
            var module = new TestableClientIpHeaderTelemetryInitializer();
            var telemetry = new EventTelemetry();

            module.Initialize(telemetry);

            Assert.AreEqual("127.0.0.1", telemetry.Context.Location.Ip);
        }
开发者ID:gregjhogan,项目名称:ApplicationInsights-server-dotnet,代码行数:9,代码来源:ClientIpHeaderTelemetryModuleTest.cs

示例10: EventTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization

        public void EventTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization()
        {
            var telemetry = new EventTelemetry("my event");
            ((ISupportSampling)telemetry).SamplingPercentage = 10;

            var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<EventTelemetry, DataPlatformModel.EventData>(telemetry);

            Assert.Equal(10, item.SampleRate);
        }
开发者ID:ZeoAlliance,项目名称:ApplicationInsights-dotnet,代码行数:9,代码来源:EventTelemetryTest.cs

示例11: HandleEvent

		public void HandleEvent(string eventName)
		{
			var interval = _random.Next(1, 10);
			var ev = new EventTelemetry(eventName) {Timestamp = DateTimeOffset.UtcNow};
			ev.Metrics.Add("ResponseTime", interval);
			_telemetryClient.TrackEvent(ev);

			Console.WriteLine("Event - {0}", eventName);
		}
开发者ID:toddmeinershagen,项目名称:Demo.ApplicationInsights,代码行数:9,代码来源:Program.cs

示例12: InitializeGetsFirstIpIfHeaderHasSeveralIps

        public void InitializeGetsFirstIpIfHeaderHasSeveralIps()
        {
            var dictionary = new Dictionary<string, string> { { "X-Forwarded-For", "1.2.3.4, 2.3.4.5,3.4.5.6" } };
            var module = new TestableClientIpHeaderTelemetryInitializer(dictionary);
            var telemetry = new EventTelemetry();

            module.Initialize(telemetry);

            Assert.AreEqual("1.2.3.4", telemetry.Context.Location.Ip);
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:10,代码来源:ClientIpHeaderTelemetryModuleTest.cs

示例13: SamplingScoreIsRandomIfUserIdAndOperationIdAreNotPresent

        public void SamplingScoreIsRandomIfUserIdAndOperationIdAreNotPresent()
        {
            var eventTelemetry = new EventTelemetry();
            var traceTelemetry = new TraceTelemetry();

            var eventTelemetrySamplingScore = SamplingScoreGenerator.GetSamplingScore(eventTelemetry);
            var traceTelemetrySamplingScore = SamplingScoreGenerator.GetSamplingScore(traceTelemetry);

            Assert.NotEqual(eventTelemetrySamplingScore, traceTelemetrySamplingScore);
        }
开发者ID:jwChung,项目名称:ApplicationInsights-dotnet,代码行数:10,代码来源:SamplingScoreGeneratorTest.cs

示例14: ContextInitializerDoesNotOverrideMachineName

        public void ContextInitializerDoesNotOverrideMachineName()
        {
            var telemetryItem = new EventTelemetry();
            var source = new DomainNameRoleInstanceTelemetryInitializer();
            telemetryItem.Context.Cloud.RoleInstance = "Test";

            source.Initialize(telemetryItem);

            Assert.Equal("Test", telemetryItem.Context.Cloud.RoleInstance);
        }
开发者ID:gregjhogan,项目名称:ApplicationInsights-server-dotnet,代码行数:10,代码来源:DomainNameRoleInstanceTelemetryInitializerTest.cs

示例15: InitializeSetsTelemetryOperationNameToMethodAndPath

        public void InitializeSetsTelemetryOperationNameToMethodAndPath()
        {
            var contextAccessor = HttpContextAccessorHelper.CreateHttpContextAccessor(new RequestTelemetry(), null);

            var initializer = new OperationNameTelemetryInitializer(contextAccessor, new DiagnosticListener(TestListenerName));

            var telemetry = new EventTelemetry();
            initializer.Initialize(telemetry);

            Assert.Equal("GET /Test", telemetry.Context.Operation.Name);
        }
开发者ID:jango2015,项目名称:ApplicationInsights-aspnet5,代码行数:11,代码来源:OperationNameTelemetryInitializerTests.cs


注:本文中的Microsoft.ApplicationInsights.DataContracts.EventTelemetry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。