public void Apply(IInternalObjectContainer container)
        {
            My <LinqQueryMonitor> .Instance.Initialize();

            IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container);

            PerformanceCounter unoptimizedNativeQueriesPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.UnoptimizedNativeQueriesPerSec, false);
            PerformanceCounter nativeQueriesPerSec            = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.NativeQueriesPerSec, false);

            container.GetNativeQueryHandler().QueryExecution += delegate(object sender, QueryExecutionEventArgs args)
            {
                if (args.ExecutionKind == QueryExecutionKind.Unoptimized)
                {
                    unoptimizedNativeQueriesPerSec.Increment();
                }

                nativeQueriesPerSec.Increment();
            };

            eventRegistry.Closing += delegate
            {
                nativeQueriesPerSec.RemoveInstance();

                nativeQueriesPerSec.Dispose();
                unoptimizedNativeQueriesPerSec.Dispose();

                container.WithEnvironment(delegate
                {
                    My <LinqQueryMonitor> .Instance.Dispose();
                });
            };
        }
Esempio n. 2
0
 public FreespaceListener(IObjectContainer container)
 {
     _totalFreespaceCounter  = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.TotalFreespace, container, false);
     _averageSlotSizeCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceAverageSlotSize, container, false);
     _freespaceSlotsCounter  = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceSlotCount, container, false);
     _reusedSlotsCounter     = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceReusedSlotsPerSec, container, false);
 }
        public void Apply(IInternalObjectContainer container)
        {
            PerformanceCounter queriesPerSec         = null;
            PerformanceCounter classIndexScansPerSec = null;

            container.WithEnvironment(delegate
            {
                queriesPerSec         = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.QueriesPerSec, false);
                classIndexScansPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ClassIndexScansPerSec, false);
            });

            IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container);

            eventRegistry.QueryFinished += delegate
            {
                queriesPerSec.Increment();
            };

            container.Configure().Diagnostic().AddListener(new DiagnosticListener(classIndexScansPerSec));

            eventRegistry.Closing += delegate
            {
                queriesPerSec.RemoveInstance();
                classIndexScansPerSec.RemoveInstance();

                queriesPerSec.Dispose();
                classIndexScansPerSec.Dispose();
            };
        }
        public void Apply(IInternalObjectContainer container)
        {
            PerformanceCounter storedObjectsPerSec =
                Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsStoredPerSec, false);
            PerformanceCounter activatedObjectsPerSec =
                Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsActivatedPerSec, false);
            PerformanceCounter deactivatedObjectsPerSec =
                Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsDeactivatedPerSec, false);
            IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container);

            EventHandler <ObjectInfoEventArgs> eventHandler = delegate
            {
                storedObjectsPerSec.Increment();
            };

            eventRegistry.Created += eventHandler;
            eventRegistry.Updated += eventHandler;

            eventRegistry.Activated += delegate
            {
                activatedObjectsPerSec.Increment();
            };
            eventRegistry.Deactivated += delegate
            {
                deactivatedObjectsPerSec.Increment();
            };

            eventRegistry.Closing += delegate
            {
                storedObjectsPerSec.Dispose();
                activatedObjectsPerSec.Dispose();
                deactivatedObjectsPerSec.Dispose();

                storedObjectsPerSec.RemoveInstance();
            };
            if (container.IsClient)
            {
                return;
            }

            PerformanceCounter deletedObjectsPerSec =
                Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectsDeletedPerSec, false);

            eventRegistry.Deleted += delegate
            {
                deletedObjectsPerSec.Increment();
            };

            eventRegistry.Closing += delegate
            {
                deletedObjectsPerSec.Dispose();
            };
        }
            private PerformanceCounter ObjectsInReferenceSystemCounterFor(IObjectContainer container)
            {
                if (_objectsCounter == null)
                {
                    _objectsCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.ObjectReferenceCount, container, false);
                    IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container);
                    eventRegistry.Closing += delegate
                    {
                        _objectsCounter.RemoveInstance();
                        _objectsCounter.Dispose();
                    };
                }

                return(_objectsCounter);
            }
Esempio n. 6
0
 public MonitoredBin(IBin bin) : base(bin)
 {
     _bytesWrittenCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.BytesWrittenPerSec,
                                                               false);
     _bytesReadCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.BytesReadPerSec, false);
 }
 public void Initialize()
 {
     _queriesPerSec            = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.LinqQueriesPerSec, false);
     _unoptimizedQueriesPerSec = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.UnoptimizedLinqQueriesPerSec, false);
 }
Esempio n. 8
0
 public PerformanceCounter PerformanceCounter(IObjectContainer container)
 {
     return(Db4oPerformanceCounters.CounterFor(this, container, true));
 }