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

C# EventProcessor.EventContext类代码示例

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

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



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

示例1: EventProcessing

        public override void EventProcessing(EventContext context)
        {
            if (!context.Event.IsError())
                return;

            Error error = context.Event.GetError();
            if (error == null)
                return;

            if (String.IsNullOrWhiteSpace(context.Event.Message))
                context.Event.Message = error.Message;

            string[] commonUserMethods = { "DataContext.SubmitChanges", "Entities.SaveChanges" };
            if (context.HasProperty("CommonMethods"))
                commonUserMethods = context.GetProperty<string>("CommonMethods").SplitAndTrim(',');

            string[] userNamespaces = null;
            if (context.HasProperty("UserNamespaces"))
                userNamespaces = context.GetProperty<string>("UserNamespaces").SplitAndTrim(',');

            var signature = new ErrorSignature(error, userCommonMethods: commonUserMethods, userNamespaces: userNamespaces);
            if (signature.SignatureInfo.Count <= 0)
                return;

            foreach (var key in signature.SignatureInfo.Keys)
                context.StackSignatureData.Add(key, signature.SignatureInfo[key]);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:27,代码来源:20_ErrorPlugin.cs


示例2: Process

        public override void Process(EventContext ctx)
        {
            // if they don't have premium features, then we don't need to queue notifications
            if (!ctx.Organization.HasPremiumFeatures)
                return;

            _notificationQueue.EnqueueAsync(new EventNotification {
                Event = ctx.Event,
                IsNew = ctx.IsNew,
                IsCritical = ctx.Event.IsCritical(),
                IsRegression = ctx.IsRegression,
                //TotalOccurrences = ctx.Stack.TotalOccurrences,
                ProjectName = ctx.Project.Name
            }).Wait();

            foreach (WebHook hook in _webHookRepository.GetByOrganizationIdOrProjectId(ctx.Event.OrganizationId, ctx.Event.ProjectId)) {
                bool shouldCall = hook.EventTypes.Contains(WebHookRepository.EventTypes.NewError) && ctx.IsNew
                                  || hook.EventTypes.Contains(WebHookRepository.EventTypes.ErrorRegression) && ctx.IsRegression
                                  || hook.EventTypes.Contains(WebHookRepository.EventTypes.CriticalError) && ctx.Event.Tags != null && ctx.Event.Tags.Contains("Critical");

                if (!shouldCall)
                    continue;

                Log.Trace().Project(ctx.Event.ProjectId).Message("Web hook queued: project={0} url={1}", ctx.Event.ProjectId, hook.Url).Write();

                // TODO: Should we be using the hook's project id and organization id?
                var context = new WebHookDataContext(hook.Version, ctx.Event, ctx.Organization, ctx.Project, ctx.Stack, ctx.IsNew, ctx.IsRegression);
                _webHookNotificationQueue.EnqueueAsync(new WebHookNotification {
                    OrganizationId = ctx.Event.OrganizationId,
                    ProjectId = ctx.Event.ProjectId,
                    Url = hook.Url,
                    Data = _webHookDataPluginManager.CreateFromEvent(context)
                }).Wait();
            }
        }
开发者ID:BookSwapSteve,项目名称:Exceptionless,代码行数:35,代码来源:070_QueueNotificationAction.cs


示例3: EventProcessingAsync

        public override Task EventProcessingAsync(EventContext context) {
            if (!context.Event.IsError())
                return Task.CompletedTask;

            Error error = context.Event.GetError();
            if (error == null)
                return Task.CompletedTask;

            if (String.IsNullOrWhiteSpace(context.Event.Message))
                context.Event.Message = error.Message;

            string[] commonUserMethods = { "DataContext.SubmitChanges", "Entities.SaveChanges" };
            if (context.HasProperty("CommonMethods"))
                commonUserMethods = context.GetProperty<string>("CommonMethods").SplitAndTrim(',');

            string[] userNamespaces = null;
            if (context.HasProperty("UserNamespaces"))
                userNamespaces = context.GetProperty<string>("UserNamespaces").SplitAndTrim(',');

            var signature = new ErrorSignature(error, userCommonMethods: commonUserMethods, userNamespaces: userNamespaces);
            if (signature.SignatureInfo.Count <= 0)
                return Task.CompletedTask;

            var targetInfo = new SettingsDictionary(signature.SignatureInfo);
            var stackingTarget = error.GetStackingTarget();
            if (stackingTarget?.Error?.StackTrace != null && stackingTarget.Error.StackTrace.Count > 0 && !targetInfo.ContainsKey("Message"))
                targetInfo["Message"] = stackingTarget.Error.Message;

            error.Data[Error.KnownDataKeys.TargetInfo] = targetInfo;

            foreach (var key in signature.SignatureInfo.Keys)
                context.StackSignatureData.Add(key, signature.SignatureInfo[key]);

            return Task.CompletedTask;
        }
开发者ID:Nangal,项目名称:Exceptionless,代码行数:35,代码来源:20_ErrorPlugin.cs


示例4: EventProcessing

        public override void EventProcessing(EventContext context)
        {
            if (Settings.Current.WebsiteMode == WebsiteMode.Dev)
                return;

            var project = _projectRepository.GetById(context.Event.ProjectId);
            if (project == null || !project.DeleteBotDataEnabled)
                return;

            // Throttle errors by client ip address to no more than X every 5 minutes.
            var ri = context.Event.GetRequestInfo();
            if (ri == null || String.IsNullOrEmpty(ri.ClientIpAddress))
                return;

            string throttleCacheKey = String.Concat("bot:", ri.ClientIpAddress, ":", DateTime.Now.Floor(_throttlingPeriod).Ticks);
            var requestCount = _cacheClient.Get<int?>(throttleCacheKey);
            if (requestCount != null) {
                _cacheClient.Increment(throttleCacheKey, 1);
                requestCount++;
            } else {
                _cacheClient.Set(throttleCacheKey, 1, _throttlingPeriod);
                requestCount = 1;
            }

            if (requestCount < Settings.Current.BotThrottleLimit)
                return;

            Log.Info().Message("Bot throttle triggered. IP: {0} Time: {1} Project: {2}", ri.ClientIpAddress, DateTime.Now.Floor(_throttlingPeriod), context.Event.ProjectId).Project(context.Event.ProjectId).Write();
            // the throttle was triggered, go and delete all the errors that triggered the throttle to reduce bot noise in the system
            Task.Run(() => _eventRepository.HideAllByClientIpAndDateAsync(context.Event.OrganizationId, ri.ClientIpAddress, DateTime.Now.Floor(_throttlingPeriod), DateTime.Now.Ceiling(_throttlingPeriod)));
            context.IsCancelled = true;
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:32,代码来源:0_ThrottleBotsPlugin.cs


示例5: EventProcessingAsync

        public override Task EventProcessingAsync(EventContext context) {
            var data = context.Event.Data;
            if (data.ContainsKey(Event.KnownDataKeys.ManualStackingKey) && data[Event.KnownDataKeys.ManualStackingKey] != null)
                context.StackSignatureData.AddItemIfNotEmpty(nameof(Event.KnownDataKeys.ManualStackingKey), data[Event.KnownDataKeys.ManualStackingKey].ToString());

            return Task.CompletedTask;
        }
开发者ID:adamzolotarev,项目名称:Exceptionless,代码行数:7,代码来源:03_ManualStackingPlugin.cs


示例6: ProcessAsync

        public override async Task ProcessAsync(EventContext ctx) {
            // if they don't have premium features, then we don't need to queue notifications
            if (!ctx.Organization.HasPremiumFeatures)
                return;

            if (ShouldQueueNotification(ctx))
                await _notificationQueue.EnqueueAsync(new EventNotificationWorkItem {
                    EventId = ctx.Event.Id,
                    IsNew = ctx.IsNew,
                    IsCritical = ctx.Event.IsCritical(),
                    IsRegression = ctx.IsRegression,
                    TotalOccurrences = ctx.Stack.TotalOccurrences,
                    ProjectName = ctx.Project.Name
                }).AnyContext();

            foreach (WebHook hook in (await _webHookRepository.GetByOrganizationIdOrProjectIdAsync(ctx.Event.OrganizationId, ctx.Event.ProjectId).AnyContext()).Documents) {
                if (!ShouldCallWebHook(hook, ctx))
                    continue;

                var context = new WebHookDataContext(hook.Version, ctx.Event, ctx.Organization, ctx.Project, ctx.Stack, ctx.IsNew, ctx.IsRegression);
                var notification = new WebHookNotification {
                    OrganizationId = ctx.Event.OrganizationId,
                    ProjectId = ctx.Event.ProjectId,
                    Url = hook.Url,
                    Data = await _webHookDataPluginManager.CreateFromEventAsync(context).AnyContext()
                };

                await _webHookNotificationQueue.EnqueueAsync(notification).AnyContext();
                Logger.Trace().Project(ctx.Event.ProjectId).Message("Web hook queued: project={0} url={1}", ctx.Event.ProjectId, hook.Url).Property("Web Hook Notification", notification).Write();
            }
        }
开发者ID:Nangal,项目名称:Exceptionless,代码行数:31,代码来源:070_QueueNotificationAction.cs


示例7: Process

        public override void Process(EventContext ctx) {
            if (ctx.StackInfo == null || !ctx.StackInfo.OccurrencesAreCritical)
                return;

            Log.Trace().Message("Marking error as critical.").Write();
            ctx.Event.MarkAsCritical();
        }
开发者ID:BookSwapSteve,项目名称:Exceptionless,代码行数:7,代码来源:020_MarkAsCriticalAction.cs


示例8: SetBrowserOsAndDeviceFromUserAgent

        private async Task SetBrowserOsAndDeviceFromUserAgent(RequestInfo request, EventContext context) {
            var info = await _parser.ParseAsync(request.UserAgent, context.Project.Id).AnyContext();
            if (info != null) {
                if (!String.Equals(info.UserAgent.Family, "Other")) {
                    request.Data[RequestInfo.KnownDataKeys.Browser] = info.UserAgent.Family;
                    if (!String.IsNullOrEmpty(info.UserAgent.Major)) {
                        request.Data[RequestInfo.KnownDataKeys.BrowserVersion] = String.Join(".", new[] { info.UserAgent.Major, info.UserAgent.Minor, info.UserAgent.Patch }.Where(v => !String.IsNullOrEmpty(v)));
                        request.Data[RequestInfo.KnownDataKeys.BrowserMajorVersion] = info.UserAgent.Major;
                    }
                }

                if (!String.Equals(info.Device.Family, "Other"))
                    request.Data[RequestInfo.KnownDataKeys.Device] = info.Device.Family;

                if (!String.Equals(info.OS.Family, "Other")) {
                    request.Data[RequestInfo.KnownDataKeys.OS] = info.OS.Family;
                    if (!String.IsNullOrEmpty(info.OS.Major)) {
                        request.Data[RequestInfo.KnownDataKeys.OSVersion] = String.Join(".", new[] { info.OS.Major, info.OS.Minor, info.OS.Patch }.Where(v => !String.IsNullOrEmpty(v)));
                        request.Data[RequestInfo.KnownDataKeys.OSMajorVersion] = info.OS.Major;
                    }
                }

                var botPatterns = context.Project.Configuration.Settings.GetStringCollection(SettingsDictionary.KnownKeys.UserAgentBotPatterns).ToList();
                request.Data[RequestInfo.KnownDataKeys.IsBot] = info.Device.IsSpider || request.UserAgent.AnyWildcardMatches(botPatterns);
            }
        }
开发者ID:Xamarui,项目名称:Exceptionless,代码行数:26,代码来源:40_RequestInfoPlugin.cs


示例9: ProcessAsync

        public override async Task ProcessAsync(EventContext ctx) {
            if (ctx.Stack == null || !ctx.Stack.OccurrencesAreCritical)
                return;

            Log.Trace().Message("Marking error as critical.").Write();
            ctx.Event.MarkAsCritical();
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:7,代码来源:020_MarkAsCriticalAction.cs


示例10: AddManualStackSignatureData

        public async Task AddManualStackSignatureData(string dataKey, string dataValue, bool willAddManualStackSignature) {
            var plugin = new ManualStackingPlugin();
            var data = new DataDictionary() { { dataKey, dataValue } };
            var context = new EventContext(new PersistentEvent { Data = data });

            await plugin.EventBatchProcessingAsync(new List<EventContext> { context });
            Assert.Equal(willAddManualStackSignature, context.StackSignatureData.Count > 0);
        }
开发者ID:adamzolotarev,项目名称:Exceptionless,代码行数:8,代码来源:ManualStackingTests.cs


示例11: EventProcessingAsync

        public override Task EventProcessingAsync(EventContext context) {
            var msi = context.Event.GetManualStackingInfo();
            if (msi?.SignatureData != null) {
                foreach (var kvp in msi.SignatureData)
                    context.StackSignatureData.AddItemIfNotEmpty(kvp.Key, kvp.Value);
            }

            return Task.CompletedTask;
        }
开发者ID:rpotalara,项目名称:Exceptionless,代码行数:9,代码来源:03_ManualStackingPlugin.cs


示例12: ProcessAsync

        public override Task ProcessAsync(EventContext ctx) {
            if (!ctx.Organization.HasPremiumFeatures)
                return Task.CompletedTask;

            // TODO: Do we need a pipeline action to trim keys and remove null values that may be sent by other native clients.
            ctx.Event.CopyDataToIndex();

            return Task.CompletedTask;
        }
开发者ID:rpotalara,项目名称:Exceptionless,代码行数:9,代码来源:035_CopySimpleDataToIdxAction.cs


示例13: Process

 public override void Process(EventContext ctx)
 {
     try {
         ctx.Event = _eventRepository.Add(ctx.Event);
     } catch (DuplicateDocumentException ex) {
         Log.Info().Project(ctx.Event.ProjectId).Message("Ignoring duplicate error submission: {0}", ctx.Event.Id).Write();
         ctx.IsCancelled = true;
     }
 }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:9,代码来源:040_SaveEventAction.cs


示例14: ProcessAsync

        public override Task ProcessAsync(EventContext ctx) {
            if (ctx.Stack == null || !ctx.Stack.OccurrencesAreCritical)
                return Task.CompletedTask;

            _logger.Trace("Marking error as critical.");
            ctx.Event.MarkAsCritical();

            return Task.CompletedTask;
        }
开发者ID:rpotalara,项目名称:Exceptionless,代码行数:9,代码来源:020_MarkAsCriticalAction.cs


示例15: AddManualStackSignatureData

        public async Task AddManualStackSignatureData(string stackingKey, bool willAddManualStackSignature) {
            var ev = new PersistentEvent();
            ev.SetManualStackingKey(stackingKey);

            var context = new EventContext(ev);
            var plugin = new ManualStackingPlugin();
            await plugin.EventBatchProcessingAsync(new List<EventContext> { context });
            Assert.Equal(willAddManualStackSignature, context.StackSignatureData.Count > 0);
        }
开发者ID:rpotalara,项目名称:Exceptionless,代码行数:9,代码来源:ManualStackingTests.cs


示例16: EventProcessingAsync

        public override async Task EventProcessingAsync(EventContext context) {
            if (String.IsNullOrEmpty(context.Event.ReferenceId))
                return;

            // TODO: Look into using a lock on reference id so we can ensure there is no race conditions with setting keys
            if (await _cacheClient.AddAsync(GetCacheKey(context), true, TimeSpan.FromMinutes(1)).AnyContext())
                return;

            context.IsCancelled = true;
        }
开发者ID:Nangal,项目名称:Exceptionless,代码行数:10,代码来源:05_CheckForDuplicateReferenceIdPlugin.cs


示例17: Process

        public override void Process(EventContext ctx)
        {
            // TODO: Implement batch incrementing to reduce pipeline cost.
            //_organizationCounters.AddOrUpdate(ctx.Event.OrganizationId, 1, (key, value) => value + 1);
            //_projectCounters.AddOrUpdate(ctx.Event.ProjectId, 1, (key, value) => value + 1);

            _organizationRepository.IncrementEventCounter(ctx.Event.OrganizationId);
            _projectRepository.IncrementEventCounter(ctx.Event.ProjectId);
            if (!ctx.IsNew)
                _stackRepository.IncrementEventCounter(ctx.Event.OrganizationId, ctx.Event.StackId, ctx.Event.Date.UtcDateTime);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:11,代码来源:060_UpdateStatsAction.cs


示例18: Process

        public override void Process(EventContext ctx)
        {
            if (ctx.Organization.RetentionDays <= 0)
                return;

            if (DateTimeOffset.Now.UtcDateTime.Subtract(ctx.Event.Date.UtcDateTime).Days <= ctx.Organization.RetentionDays)
                return;

            Log.Info().Project(ctx.Event.ProjectId).Message("Discarding event that occurred outside of your retention limit.").Write();
            ctx.IsCancelled = true;
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:11,代码来源:001_DiscardEventsOutsideOfRetentionAction.cs


示例19: EventProcessingAsync

        public override async Task EventProcessingAsync(EventContext context) {
            if (String.IsNullOrEmpty(context.Event.ReferenceId))
                return;

            // TODO: Look into using a lock on reference id so we can ensure there is no race conditions with setting keys
            if (await _cacheClient.AddAsync(GetCacheKey(context), true, TimeSpan.FromMinutes(1)).AnyContext())
                return;

            _logger.Warn().Project(context.Event.ProjectId).Message("Discarding event due to duplicate reference id: {0}", context.Event.ReferenceId).Write();
            context.IsCancelled = true;
        }
开发者ID:rpotalara,项目名称:Exceptionless,代码行数:11,代码来源:05_CheckForDuplicateReferenceIdPlugin.cs


示例20: Process

        public override void Process(EventContext ctx)
        {
            if (ctx.Event.Tags != null)
                ctx.Event.Tags.RemoveWhere(t => String.IsNullOrEmpty(t) || t.Length > 255);

            if (ctx.Event.Message != null && ctx.Event.Message.Length > 2000)
                ctx.Event.Message = ctx.Event.Message.Truncate(2000);

            if (ctx.Event.Source != null && ctx.Event.Source.Length > 2000)
                ctx.Event.Source = ctx.Event.Source.Truncate(2000);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:11,代码来源:006_TruncateFieldsAction.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Serialization.JsonProperty类代码示例发布时间:2022-05-24
下一篇:
C# Models.PersistentEvent类代码示例发布时间: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