• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DataContracts.EventTelemetry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: SyntheticSourceIsNotSetIfContextIsNull

        public void SyntheticSourceIsNotSetIfContextIsNull()
        {
            var eventTelemetry = new EventTelemetry("name");
            var source = new SyntheticUserAgentTelemetryInitializer();

            source.Filters = this.botSubstrings;

            source.Initialize(eventTelemetry);

            Assert.IsNull(eventTelemetry.Context.Operation.SyntheticSource);
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:11,代码来源:SyntheticUserAgentTelemetryInitializerTest.cs


示例17: SanitizesTelemetryItem

        public void SanitizesTelemetryItem()
        {
            string name = new string('Z', 10000);
            EventTelemetry t = new EventTelemetry(name);

            string exceptionAsJson = JsonSerializer.SerializeAsString(t);

            JObject obj = JsonConvert.DeserializeObject<JObject>(exceptionAsJson);
            
            Assert.Equal(512, obj["data"]["baseData"]["name"].ToString().Length);
        }
开发者ID:jwChung,项目名称:ApplicationInsights-dotnet,代码行数:11,代码来源:JsonSerializerTest.cs


示例18: InitializeSetsTelemetryOperationIdToRequestId

        public void InitializeSetsTelemetryOperationIdToRequestId()
        {
            var telemetry = new EventTelemetry();
            var requestTelemetry = new RequestTelemetry();
            var contextAccessor = HttpContextAccessorHelper.CreateHttpContextAccessor(requestTelemetry);

            var initializer = new OperationIdTelemetryInitializer(contextAccessor);

            initializer.Initialize(telemetry);

            Assert.Equal(requestTelemetry.Id, telemetry.Context.Operation.Id);
        }
开发者ID:RehanSaeed,项目名称:ApplicationInsights-aspnetcore,代码行数:12,代码来源:OperationIdTelemetryInitializerTest.cs


示例19: InitializeDoesNotOverrideOperationNameProvidedInline

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

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

            var telemetry = new EventTelemetry();
            telemetry.Context.Operation.Name = "Name";
            initializer.Initialize(telemetry);

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


示例20: InitializeDoesNotSetIdIfTelemetryHasIt

        public void InitializeDoesNotSetIdIfTelemetryHasIt()
        {
            var eventTelemetry = new EventTelemetry("name");
            var source = new TestableUserTelemetryInitializer();
            var requestTelemetry = source.FakeContext.CreateRequestTelemetryPrivate();

            requestTelemetry.Context.User.Id = "1";
            eventTelemetry.Context.User.Id = "2";
            source.Initialize(eventTelemetry);

            Assert.AreEqual("2", eventTelemetry.Context.User.Id);
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:12,代码来源:UserTelemetryInitializerTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DataContracts.RequestTelemetry类代码示例发布时间:2022-05-26
下一篇:
C# ApplicationInsights.TelemetryClient类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap