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

C# ITelemetry类代码示例

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

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



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

示例1: OnInitializeTelemetry

        /// <summary>
        /// Implements initialization logic.
        /// </summary>
        /// <param name="platformContext">Http context.</param>
        /// <param name="requestTelemetry">Request telemetry object associated with the current request.</param>
        /// <param name="telemetry">Telemetry item to initialize.</param>
        protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry)
        {
            if (string.IsNullOrEmpty(telemetry.Context.Operation.SyntheticSource))
            {
                if (platformContext != null)
                {
                    var request = platformContext.GetRequest();

                    if (request != null && !string.IsNullOrEmpty(request.UserAgent))
                    {
                        // We expect customers to configure telemetry initializer before they add it to active configuration
                        // So we will not protect fiterPatterns array with locks (to improve perf)
                        foreach (string pattern in this.filterPatterns)
                        {
                            if (!string.IsNullOrWhiteSpace(pattern) &&
                                request.UserAgent.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) != -1)
                            {
                                telemetry.Context.Operation.SyntheticSource = "Bot";
                                return;
                            }
                        }
                    }
                }
            }
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:31,代码来源:SyntheticUserAgentTelemetryInitializer.cs


示例2: Initialize

 /// <summary>
 /// Initializes the given <see cref="Microsoft.ApplicationInsights.Channel.ITelemetry"/>.
 /// </summary>
 public void Initialize(ITelemetry telemetry)
 {
     if (String.IsNullOrWhiteSpace(telemetry.Context.Component.Version))
     {
         telemetry.Context.Component.Version = _applicationVersion.Value;
     }
 }
开发者ID:fidmor89,项目名称:SLAB_AppInsights,代码行数:10,代码来源:ApplicationVersionContextInitializer.cs


示例3: Initialize

 /// <summary>
 /// Sets <see cref="ITelemetry.Timestamp"/> to <see cref="DateTimeOffset.Now"/>.
 /// </summary>
 public void Initialize(ITelemetry telemetry)
 {
     if (telemetry.Timestamp == default(DateTimeOffset))
     {
         telemetry.Timestamp = Clock.Instance.Time;
     }
 }
开发者ID:bitstadium,项目名称:HockeySDK-Windows,代码行数:10,代码来源:TimestampPropertyInitializer.cs


示例4: Initialize

        /// <summary>
        /// Initializes/Adds operation id to the existing telemetry item.
        /// </summary>
        /// <param name="telemetryItem">Target telemetry item to add operation id.</param>
        public void Initialize(ITelemetry telemetryItem)
        {
            var itemContext = telemetryItem.Context.Operation;

            if (string.IsNullOrEmpty(itemContext.ParentId) || string.IsNullOrEmpty(itemContext.Id) || string.IsNullOrEmpty(itemContext.Name))
            {
                var parentContext = AsyncLocalHelpers.GetCurrentOperationContext();
                if (parentContext != null)
                {
                    if (string.IsNullOrEmpty(itemContext.ParentId)
                        && !string.IsNullOrEmpty(parentContext.ParentOperationId))
                    {
                        itemContext.ParentId = parentContext.ParentOperationId;
                    }

                    if (string.IsNullOrEmpty(itemContext.Id)
                        && !string.IsNullOrEmpty(parentContext.RootOperationId))
                    {
                        itemContext.Id = parentContext.RootOperationId;
                    }

                    if (string.IsNullOrEmpty(itemContext.Name)
                        && !string.IsNullOrEmpty(parentContext.RootOperationName))
                    {
                        itemContext.Name = parentContext.RootOperationName;
                    }
                }
            }
        }
开发者ID:ZeoAlliance,项目名称:ApplicationInsights-dotnet,代码行数:33,代码来源:OperationCorrelationTelemetryInitializer.cs


示例5: Process

        /// <summary>
        /// Process a collected telemetry item.
        /// </summary>
        /// <param name="item">A collected Telemetry item.</param>
        public void Process(ITelemetry item)
        {
            if (this.SamplingPercentage < 100.0 - 1.0E-12)
            {
                // set sampling percentage on telemetry item, current codebase assumes it is the only one updating SamplingPercentage.
                var samplingSupportingTelemetry = item as ISupportSampling;

                if (samplingSupportingTelemetry != null)
                {
                    samplingSupportingTelemetry.SamplingPercentage = this.SamplingPercentage;
                }

                if (!this.IsSampledIn(item))
                {
                    if (TelemetryChannelEventSource.Log.IsVerboseEnabled)
                    {
                        TelemetryChannelEventSource.Log.ItemSampledOut(item.ToString());
                    }

                    return;
                }
            }

            this.Next.Process(item);
        }
开发者ID:jwChung,项目名称:ApplicationInsights-dotnet,代码行数:29,代码来源:SamplingTelemetryProcessor.cs


示例6: OnInitializeTelemetry

 protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry)
 {
     if (string.IsNullOrEmpty(telemetry.Context.Operation.Id))
     {
         telemetry.Context.Operation.Id = requestTelemetry.Id;
     }
 }
开发者ID:jango2015,项目名称:ApplicationInsights-aspnet5,代码行数:7,代码来源:OperationIdTelemetryInitializer.cs


示例7: Initialize

 public void Initialize(ITelemetry telemetry)
 {
     if (HttpContext.Current == null) return;
     var requestId = HttpContext.Current.Items[Constants.RequestIdKey];
     if (requestId == null || !string.IsNullOrEmpty(telemetry.Context.Operation.Id)) return;
     telemetry.Context.Operation.Id = requestId as string;
 }
开发者ID:dementeddevil,项目名称:Orchard-Azure-Application-Insights,代码行数:7,代码来源:WebOperationIdTelemetryInitializer.cs


示例8: Initialize

        public void Initialize(ITelemetry telemetry)
        {
            try
            {
                var context = this.httpContextAccessor.HttpContext;

                if (context == null)
                {
                    //TODO: Diagnostics!
                    return;
                }

                if (context.RequestServices == null)
                {
                    //TODO: Diagnostics!
                    return;
                }

                var request = context.RequestServices.GetService<RequestTelemetry>();

                if (request == null)
                {
                    //TODO: Diagnostics!
                    return;
                }

                this.OnInitializeTelemetry(context, request, telemetry);
            }
            catch (Exception exp)
            {
                //TODO: Diagnostics!
                Debug.WriteLine(exp);
            }
        }
开发者ID:hackathonvixion,项目名称:ApplicationInsights-aspnet5,代码行数:34,代码来源:TelemetryInitializerBase.cs


示例9: Initialize

        /// <summary>
        /// Base implementation of the initialization method.
        /// </summary>
        /// <param name="telemetry">Telemetry item to initialize.</param>
        public void Initialize(ITelemetry telemetry)
        {
            try
            {
                var platformContext = this.ResolvePlatformContext();

                if (platformContext == null)
                {
                    WebEventSource.Log.WebTelemetryInitializerNotExecutedOnNullHttpContext();
                    return;
                }

                if (platformContext.GetRequest() == null)
                {
                    return;
                }

                var requestTelemetry = platformContext.ReadOrCreateRequestTelemetryPrivate();
                this.OnInitializeTelemetry(platformContext, requestTelemetry, telemetry);
            }
            catch (Exception exc)
            {
                WebEventSource.Log.WebTelemetryInitializerFailure(
                    this.GetType().FullName,
                    exc.ToInvariantString());
            }
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:31,代码来源:WebTelemetryInitializerBase.cs


示例10: Initialize

 /// <summary>
 /// Populates <see cref="ITelemetry.Sequence"/> with unique ID and sequential number.
 /// </summary>
 public void Initialize(ITelemetry telemetry)
 {
     if (string.IsNullOrEmpty(telemetry.Sequence))
     {
         telemetry.Sequence = this.stablePrefix + Interlocked.Increment(ref this.currentNumber);
     }
 }
开发者ID:ZeoAlliance,项目名称:ApplicationInsights-dotnet,代码行数:10,代码来源:SequencePropertyInitializer.cs


示例11: Initialize

 /// <summary>
 /// Initializes the given <see cref="Microsoft.ApplicationInsights.Channel.ITelemetry"/>.
 /// </summary>
 /// <param name="telemetry"></param>
 public void Initialize(ITelemetry telemetry)
 {
     if (String.IsNullOrWhiteSpace(telemetry.Context.Session.Id))
     {
         telemetry.Context.Session.Id = _sessionId.Value;
     }
 }
开发者ID:fidmor89,项目名称:SLAB_AppInsights,代码行数:11,代码来源:SessionContextInitializer.cs


示例12: Send

 public void Send(ITelemetry item)
 {
     lock ( lockobj )
     {
         items.Add(item);
     }
 }
开发者ID:xornand,项目名称:ApplicationInsights-SDK-Labs,代码行数:7,代码来源:TestTelemetryChannel.cs


示例13: Initialize

 /// <summary>
 /// Initializes the given <see cref="Microsoft.ApplicationInsights.Channel.ITelemetry"/>.
 /// </summary>
 public void Initialize(ITelemetry telemetry)
 {
     if (String.IsNullOrWhiteSpace(telemetry.Context.Device.OperatingSystem))
     {
         telemetry.Context.Device.OperatingSystem = _osVersion.Value;
     }
 }
开发者ID:fidmor89,项目名称:SLAB_AppInsights,代码行数:10,代码来源:OsVersionContextInitializer.cs


示例14: Car

 public Car(ITelemetry telemetry, int carIdx)
 {
     this.telemetry = telemetry;
     this.carIdx = carIdx;
     this.driver = telemetry.SessionData.DriverInfo.CompetingDrivers[carIdx];
     this.Details = new CarDetails(telemetry, carIdx);
 }
开发者ID:RobRobertsCE,项目名称:iRacingCrewChief,代码行数:7,代码来源:Car.cs


示例15: Initialize

        public void Initialize(ITelemetry telemetry)
        {
            var telemetryWithProperties = telemetry as ISupportProperties;

            if (telemetryWithProperties == null) return;

            // If already set, nothing to do.
            if (telemetryWithProperties.Properties.ContainsKey(Constants.ShellNameKey)) return;

            // Below algorithm copied from OrchardLog4netLogger.
            var ctx = HttpContext.Current;
            if (ctx == null)
                return;

            var runningShellTable = HostContainer.Resolve<IRunningShellTable>();
            if (runningShellTable == null)
                return;

            var shellSettings = runningShellTable.Match(new HttpContextWrapper(ctx));
            if (shellSettings == null)
                return;

            var orchardHost = HostContainer.Resolve<IOrchardHost>();
            if (orchardHost == null)
                return;

            var shellContext = orchardHost.GetShellContext(shellSettings);
            if (shellContext == null || shellContext.Settings == null)
                return;

            telemetryWithProperties.Properties[Constants.ShellNameKey] = shellContext.Settings.Name;
        }
开发者ID:dementeddevil,项目名称:Orchard-Azure-Application-Insights,代码行数:32,代码来源:ShellNameTelemetryInitializer.cs


示例16: Initialize

 /// <summary>
 /// Initializes the telemetry.
 /// </summary>
 public void Initialize(ITelemetry telemetry)
 {
     if (telemetry.Context.Cloud.RoleInstance == null)
     {
         telemetry.Context.Cloud.RoleInstance = _hostName.Value;
     }
 }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:10,代码来源:HostnameTelemetryInitializer.cs


示例17: Initialize

 public void Initialize(ITelemetry telemetry)
 {
     if (!string.IsNullOrEmpty(this.appVersion))
     {
         telemetry.Context.Component.Version = this.appVersion;
     }
 }
开发者ID:SergeyKanzhelev,项目名称:BO,代码行数:7,代码来源:02-InitializeRequestTelemetry.cs


示例18: Initialize

        public void Initialize(ITelemetry telemetry)
        {
            try
            {
                var context = this.httpContextAccessor.HttpContext;

                if (context == null)
                {
                    AspNetCoreEventSource.Instance.LogTelemetryInitializerBaseInitializeContextNull();
                    return;
                }

                if (context.RequestServices == null)
                {
                    AspNetCoreEventSource.Instance.LogTelemetryInitializerBaseInitializeRequestServicesNull();
                    return;
                }

                var request = context.RequestServices.GetService<RequestTelemetry>();

                if (request == null)
                {
                    AspNetCoreEventSource.Instance.LogTelemetryInitializerBaseInitializeRequestNull();
                    return;
                }

                this.OnInitializeTelemetry(context, request, telemetry);
            }
            catch (Exception exp)
            {
                AspNetCoreEventSource.Instance.LogTelemetryInitializerBaseInitializeException(exp.ToString());
                Debug.WriteLine(exp);
            }
        }
开发者ID:RehanSaeed,项目名称:ApplicationInsights-aspnetcore,代码行数:34,代码来源:TelemetryInitializerBase.cs


示例19: OnInitializeTelemetry

        /// <summary>
        /// Implements initialization logic.
        /// </summary>
        /// <param name="platformContext">Http context.</param>
        /// <param name="requestTelemetry">Request telemetry object associated with the current request.</param>
        /// <param name="telemetry">Telemetry item to initialize.</param>
        protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry)
        {
            if (platformContext != null)
            {
                var request = platformContext.GetRequest();

                if (request != null)
                {
                    foreach (var pattern in this.filterPatterns)
                    {
                        if (pattern.RegularExpression != null && request.UserAgent != null)
                        {
                            var match = pattern.RegularExpression.Match(request.UserAgent);
                            if (match.Success)
                            {
                                if (string.IsNullOrEmpty(telemetry.Context.Operation.SyntheticSource))
                                {
                                    telemetry.Context.Operation.SyntheticSource = !string.IsNullOrWhiteSpace(pattern.SourceName) ? pattern.SourceName : match.Value;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:jawn,项目名称:ApplicationInsights-server-dotnet,代码行数:32,代码来源:SyntheticUserAgentTelemetryInitializer.cs


示例20: Send

        public void Send(ITelemetry item)
        {
            var timer = TimerStrategy();

            if (timer == null || MessageBroker == null)
            {
                return;
            }

            if (item is DependencyTelemetry)
            {
                var dependency = item as DependencyTelemetry;
                var timelineMessage = new DependencyTelemetryTimelineMessage(dependency);
                timelineMessage.Offset = timer.Point().Offset.Subtract(dependency.Duration);
                MessageBroker.Publish(timelineMessage);
            }

            if (item is TraceTelemetry)
            {
                TraceTelemetry t = new TraceTelemetry();

                var model = new TraceMessage
                {
                    Category = "Application Insights",
                    Message = t.SeverityLevel == null ? t.Message : t.SeverityLevel + ": " + t.Message,
                    FromFirst = timer.Point().Offset,
                    FromLast = CalculateFromLast(timer),
                    IndentLevel = 0
                };

                MessageBroker.Publish(model);
            }

            messageBroker.Publish(item);
        }
开发者ID:JoseCarlosMM,项目名称:Glimpse,代码行数:35,代码来源:GlimpseTelemetryChannel.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ITemplate类代码示例发布时间:2022-05-24
下一篇:
C# ITeacher类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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