Assembly: mindtouch.core
Class: MindTouch.Dream.RedirectService
SID: http://services.mindtouch.com/dream/.../03/statistics

The Statistics service allows an application to record values and retrieve statistics about them. A new statistics record is created when a client submits a /stat/* PUT on a resource name that hasn't been encountered (or that was deleted previously).  The Stats service also provides the ability to listen to all submitted values.

Verb:Suffix Description
GET: Retrieves a list of all statistics records.
POST:listen Opens a stream of statistics requests.
GET:{name} Retrieves a specific aggregated statistics record.
PUT:{name} Adds a new value to a statistics record.  If the record does not exist, it gets created.
DELETE:{name} Retrieves a specific aggregated statistics record and removes it from the collection.

NOTE: PUT:{name} requests are ignored when the submitted value is not a number (NaN) or cannot be parsed into a number.

DESIGN COMMENT: it would have been possible to return the most up-to-date StatRecord for each 'PUT:{name}'.  This would have alleviated the client from issuing immediately a 'GET:{name}' to read it.  However, the purpose of the Stats service is to collect many samples before requesting a StatRecord.  Thus, it seemed unlikely that a client would want to do this.  Hence, returning a StatRecord on 'PUT:{name}' PUT would have created consistent overhead in serialization and bandwidth with little added value.

StatisticsRecord

Field Type Description
Name String Name of the statistic
SourceUri URI Location from which the statistics record was retrieved from
ServiceUri URI Location of the statistics service
Min Double Lowest collected value
Max Double Highest collected value
Average Double Average of all collected values
Variance Double Variance of all collected values
Sum Double Summed total of all collected values
Count Integer Total number of collectd values
TimeSpan Double Time elapsed in seconds between first and last collected value
FirstTime DateTime UTC timestamp of first collected value
LastTime DateTime UTC timestamp of last collected value
Rate Double Average time in seconds between collected values
RateVariance Double Variance in seconds between collected values

Features

GET:

Retrieves a list of all statistics records.

Response
Status Response Body Description
OK (200) List<StatisticsRecord> operation completed successfully

POST:listen

Opens a stream of statistics requests.

Response
Status Response Body Description
OK (200) Open stream operation completed successfully

GET:{name}

Retrieves a specific aggregated statistics record.

Response
Status Response Body Description
OK (200) StatisticsRecord operation completed successfully

PUT:{name}

Adds a new value to a statistics record.  If the record does not exist, it gets created.

Request body

Double value

Response
Status Response Body Description
OK (200) --- operation completed successfully

DELETE:{name}

Retrieves a specific aggregated statistics record and removes it from the collection.

Response
Status Response Body Description
OK (200) StatisticsRecord operation completed successfully

Examples

Example 1: Querying for statistics tokens

GET http://myserver/mystats
=>
<list>
	<stat>
        	<name>RESPONSE_TIME</name>
		<source>http://myserver/mystats/stat/RESPONSE_TIME</source>
		<service>http://myserver/mystats</service>
    		<min>123.45</min>
    		<max>123.45</max>
    		<avg>123.45</avg>
    		<var>123.45</var>
        	<sum>555</sum>
    		<count>15</count>
        	<span>123.45</span>
    		<first>2006-05-22T01:16:03.0716064Z</first>
    		<last>2006-05-22T01:16:03.4020816Z</last>
    		<rate>123.45</rate>
    		<ratevar>123.45</ratevar>
	</stat>
	<stat>
        	<name>PROCESSING_TIME</name>
		<source>http://myserver/mystats/stat/RESPONSE_TIME</source>
		<service>http://myserver/mystats</service>
    		<min>123.45</min>
    		<max>123.45</max>
    		<avg>123.45</avg>
    		<var>123.45</var>
        	<sum>555</sum>
    		<count>15</count>
        	<span>123.45</span>
    		<first>2006-05-22T01:16:03.0716064Z</first>
    		<last>2006-05-22T01:16:03.4020816Z</last>
    		<rate>123.45</rate>
    		<ratevar>123.45</ratevar>
	</stat>
</list>

Example 2: Creating a new statistics record

PUT http://myserver/mystats/RESPONSE_TIME "123.45"
=> ""

Example 3: Reading a statistics record

GET http://myserver/mystats/RESPONSE_TIME
=>
<stat>
        <name>RESPONSE_TIME</name>
	<source>http://myserver/mystats/RESPONSE_TIME</source>
	<service>http://myserver/mystats</service> <min>123.45</min>
	<max>123.45</max>
	<avg>123.45</avg>
	<var>123.45</var> <sum>555</sum>
	<count>15</count>
	<span>123.45</span>
	<first>2006-05-22T01:16:03.0716064Z</first>
	<last>2006-05-22T01:16:03.4020816Z</last>
	<rate>123.45</rate>
	<ratevar>123.45</ratevar>
</stat>

Example 4: Listening to incoming values

POST http://myserver/mystats/listen
=>
<xmlstream>
	<record>
		<name>RESPONSE_TIME</name>
		<date>2006-05-22T01:16:03.0716064Z</date>
		<value>123.45</value>
	</record>
	<record>
		<name>RESPONSE_TIME</name>
		<date>2006-05-22T01:16:03.1716064Z</date>
		<value>234.56</value>
	</record>
	<record>
		<name>PAGE_PROCESSING</name>
		<date>2006-05-22T01:16:03.2716064Z</date>
		<value>123.45</value>
	</record>
	...
</xmlstream> 

Version History

Crimson: shortened feature signatures

Acqua: service added

Tag page
You must login to post a comment.
Powered by MindTouch Deki v.8.08.1a