Exemple #1
0
        public void Append(MonitorContext context)
        {
            Interlocked.Increment(ref Count);
            Interlocked.Add(ref Spans, context.Elapsed);

            foreach (var rep in context.Repositories)
            {
                repositories.AddOrUpdate(rep.RepositoryPath, (key) =>
                {
                    return(new RepositoryMonitorData()
                    {
                        Name = rep.RepositoryPath,
                        Count = 1,
                        CacheHits = rep.CacheHit ? 1 : 0,
                        Spans = rep.Elapsed
                    });
                }, (key, repData) =>
                {
                    Interlocked.Increment(ref repData.Count);
                    Interlocked.Add(ref repData.Spans, rep.Elapsed);
                    Interlocked.Add(ref repData.CacheHits, rep.CacheHit ? 1 : 0);
                    return(repData);
                });
            }
        }
Exemple #2
0
            public RepositoryScope(MonitorContext context, MethodInfo method, bool cacheHit = false)
            {
                this.context = context;

                if (method.Name != "CreateSpecification" && context.Enabled)
                {
                    var repository = context.CurrentRepositoryMonitor;
                    if (repository == null)
                    {
                        repository = new RepositoryMonitor(method, cacheHit);
                        context.CurrentRepositoryMonitor = repository;
                    }
                    repository.Push();
                }
            }