StatsManager
Stay organized with collections
Save and categorize content based on your preferences.
Object used to manage operation execution statistics.
Logically structured to look like (in RESTful representation):
/ - list of components
/:component
/:component/:operation - long (counter)
/:component/:event
|success - long (counter)
|failure - long (counter)
|latency - map of <latency_range, counts>
/:operationWithVariants - map of <variant, counts>
Example:
/requests/SendFeeds - returns {CODE_OK: 155, CODE_404: 105}
Public Method Summary
static
StatsManager.OperationStats
|
|
static
List<String>
|
|
static
StatsManager
|
getInstance()
Returns a singleton reference to this object.
|
synchronized
boolean
|
isRunning()
Determines whether the statistic capture is active.
|
synchronized
void
|
|
String
|
printStats()
Builds human-readable statistics string to write in logs.
|
synchronized
void
|
resume()
Starts/resumes capturing statistics.
|
synchronized
void
|
|
synchronized
void
|
stop()
Stops capturing all statistics.
|
synchronized
Object
|
|
Inherited Method Summary
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Methods
Parameters
component |
- name of component that defines the name space of its statistics |
Returns
- OperationStats object for specified component (create instance if needed)
public
static
List<String>
getComponentNames
()
public
static
StatsManager
getInstance
()
Returns a singleton reference to this object.
public
synchronized
boolean
isRunning
()
Determines whether the statistic capture is active.
public
synchronized
void
mergeWithSnapshot
(Object snapshot)
public
String
printStats
()
Builds human-readable statistics string to write in logs.
public
synchronized
void
resume
()
Starts/resumes capturing statistics.
public
synchronized
void
startFromSnapshot
(Object snapshot)
public
synchronized
void
stop
()
Stops capturing all statistics.
public
synchronized
Object
takeSnapshot
()
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-18 UTC.
[null,null,["Last updated 2025-03-18 UTC."],[],[],null,["# StatsManager\n\npublic class **StatsManager** extends Object \nObject used to manage operation execution statistics.\n\nLogically structured to look like (in RESTful representation): \n\n```\n / - list of components\n /:component\n /:component/:operation - long (counter)\n /:component/:event\n |success - long (counter)\n |failure - long (counter)\n |latency - map of \u003clatency_range, counts\u003e\n /:operationWithVariants - map of \u003cvariant, counts\u003e\n \n```\nExample: \n\n```\n /requests/SendFeeds - returns {CODE_OK: 155, CODE_404: 105}\n \n```\n\n\u003cbr /\u003e\n\n### Nested Class Summary\n\n|-------|---|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| class | [StatsManager.OperationStats](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager.OperationStats) || Object used to log events, operations, and actions |\n| class | [StatsManager.ResetStatsRule](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager.ResetStatsRule) || [TestRule](/workspace/cloud-search/docs/reference/sdk/org/junit/rules/TestRule) to reset static [StatsManager](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager) object for unit tests. |\n\n### Public Method Summary\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [StatsManager.OperationStats](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager.OperationStats) | [getComponent](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#getComponent(java.lang.String))(String component) Retrieves the [StatsManager.OperationStats](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager.OperationStats) instance for the desired component. |\n| static List\\\u003cString\\\u003e | [getComponentNames](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#getComponentNames())() |\n| static [StatsManager](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager) | [getInstance](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#getInstance())() Returns a singleton reference to this object. |\n| synchronized boolean | [isRunning](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#isRunning())() Determines whether the statistic capture is active. |\n| synchronized void | [mergeWithSnapshot](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#mergeWithSnapshot(java.lang.Object))(Object snapshot) |\n| String | [printStats](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#printStats())() Builds human-readable statistics string to write in logs. |\n| synchronized void | [resume](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#resume())() Starts/resumes capturing statistics. |\n| synchronized void | [startFromSnapshot](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#startFromSnapshot(java.lang.Object))(Object snapshot) |\n| synchronized void | [stop](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#stop())() Stops capturing all statistics. |\n| synchronized Object | [takeSnapshot](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager#takeSnapshot())() |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static [StatsManager.OperationStats](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager.OperationStats)\n**getComponent**\n(String component)\n\nRetrieves the [StatsManager.OperationStats](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager.OperationStats) instance for the desired component. \n\n##### Parameters\n\n| component | - name of component that defines the name space of its statistics |\n|-----------|-------------------------------------------------------------------|\n\n##### Returns\n\n- OperationStats object for specified component (create instance if needed) \n\n#### public static List\\\u003cString\\\u003e\n**getComponentNames**\n()\n\n\u003cbr /\u003e\n\n#### public static [StatsManager](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/StatsManager)\n**getInstance**\n()\n\nReturns a singleton reference to this object. \n\n#### public synchronized boolean\n**isRunning**\n()\n\nDetermines whether the statistic capture is active. \n\n#### public synchronized void\n**mergeWithSnapshot**\n(Object snapshot)\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| snapshot | |\n|----------|---|\n\n#### public String\n**printStats**\n()\n\nBuilds human-readable statistics string to write in logs. \n\n#### public synchronized void\n**resume**\n()\n\nStarts/resumes capturing statistics. \n\n#### public synchronized void\n**startFromSnapshot**\n(Object snapshot)\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| snapshot | |\n|----------|---|\n\n#### public synchronized void\n**stop**\n()\n\nStops capturing all statistics. \n\n#### public synchronized Object\n**takeSnapshot**\n()\n\n\u003cbr /\u003e"]]