= MetricsService
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Hooks into the transaction nechanism to provide a counters relating to numbers of object loaded, dirtied etc.

Only entities with _DomainObject#entityChangePublishing()_ enabled (in other words, auditing) are counted.

== API

[source,java]
.MetricsService.java
----
interface MetricsService {
  int numberEntitiesLoaded()     // <.>
  Set<Bookmark> entitiesLoaded()     // <.>
  int numberEntitiesDirtied()     // <.>
  Set<Bookmark> entitiesDirtied()     // <.>
}
----

<.> xref:#numberEntitiesLoaded_[numberEntitiesLoaded()]
+
--
The number of entities that were loaded (but not necessarily modified) from the database.
--
<.> xref:#entitiesLoaded_[entitiesLoaded()]
+
--
Returns the bookmarks of the entities loaded within the transaction.
--
<.> xref:#numberEntitiesDirtied_[numberEntitiesDirtied()]
+
--
The number of entities that were modified within the transaction.
--
<.> xref:#entitiesDirtied_[entitiesDirtied()]
+
--
Returns the bookmarks of the entities that were modified within the transaction.
--

== Members

[#numberEntitiesLoaded_]
=== numberEntitiesLoaded()

The number of entities that were loaded (but not necessarily modified) from the database.

Is captured within _MemberExecutionDto#getMetrics()_ (accessible from _InteractionProvider#currentInteraction()_ ).

[#entitiesLoaded_]
=== entitiesLoaded()

Returns the bookmarks of the entities loaded within the transaction.

Requires detailed metrics to be enabled using config param.

[#numberEntitiesDirtied_]
=== numberEntitiesDirtied()

The number of entities that were modified within the transaction.

Is captured within _MemberExecutionDto#getMetrics()_ (accessible from _InteractionProvider#currentInteraction()_ .

[#entitiesDirtied_]
=== entitiesDirtied()

Returns the bookmarks of the entities that were modified within the transaction.

Requires detailed metrics to be enabled using config param.

include::hooks/MetricsService_010-implementation.adoc[]

include::hooks/MetricsService_020-examples-and-usage.adoc[]
