Document monitoring and boot

- Relates to #263
This commit is contained in:
Janne Valkealahti
2016-11-06 08:16:44 +00:00
parent 797279a53c
commit c48f671ee1
9 changed files with 224 additions and 0 deletions

View File

@@ -58,6 +58,9 @@ framework.
|spring-statemachine-uml
|Support module for UI uml modeling with Eclipse Papyrus.
|spring-statemachine-boot
|Support module for `Spring Boot`.
|===
== Using Gradle

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -38,6 +38,8 @@ normal build cycle. Samples in this chapter are:
<<statemachine-examples-datajpa>> JPA Config.
<<statemachine-examples-monitoring>> Monitoring.
[source,text]
----
@@ -1493,3 +1495,98 @@ Actual source for populator data is shown below.
include::samples/data.json[]
----
[[statemachine-examples-monitoring]]
== Monitoring
Monitoring is an example how state machine concepts can be used to
monitor machine transitions and actions.
[source,java,indent=0]
----
include::samples/demo/monitoring/StateMachineConfig.java[tags=snippetA]
----
Lets get into actual demo. Run the boot based sample application:
[source,text,subs="attributes"]
----
# java -jar spring-statemachine-samples-monitoring-{revnumber}.jar
----
image::images/sm-monitoring-1.png[width=1000]
Execute some transitions.
image::images/sm-monitoring-2.png[width=1000]
Metrics can be viewed from Boot.
[source,json]
----
# curl http://localhost:8080/metrics
{
"gauge.ssm.transition.INITIAL_S1.duration":0.0,
"gauge.ssm.transition.EXTERNAL_S2_S3.duration":0.0,
"gauge.ssm.action.demo.monitoring.StateMachineConfig$Config$$Lambda$8/12546741@a522d0.duration":0.0,
"gauge.ssm.transition.EXTERNAL_S1_S2.duration":1.0,
"gauge.ssm.action.demo.monitoring.StateMachineConfig$Config$$Lambda$7/25284245@1c21333.duration":0.0,
"gauge.ssm.action.demo.monitoring.StateMachineConfig$Config$$Lambda$9/28306193@10069f9.duration":0.0,
"counter.ssm.action.demo.monitoring.StateMachineConfig$Config$$Lambda$8/12546741@a522d0.execute":1,
"counter.ssm.action.demo.monitoring.StateMachineConfig$Config$$Lambda$9/28306193@10069f9.execute":1,
"counter.ssm.transition.EXTERNAL_S2_S3.transit":1,
"counter.ssm.action.demo.monitoring.StateMachineConfig$Config$$Lambda$7/25284245@1c21333.execute":1,
"counter.ssm.transition.EXTERNAL_S1_S2.transit":1,
"counter.ssm.transition.INITIAL_S1.transit":2,
}
----
Tracing can be viewed from Boot.
[source,json]
----
# curl http://localhost:8080/trace
[{
"timestamp":1478419121956,
"info":{
"duration":0,
"machine":null,
"transition":
"EXTERNAL_S2_S3"
}
},
{
"timestamp":1478419121956,
"info":{
"duration":0,
"machine":null,
"action":"demo.monitoring.StateMachineConfig$Config$$Lambda$9/28306193@10069f9"
}
},
{
"timestamp":1478419121956,
"info":{
"duration":0,
"machine":null,
"action":"demo.monitoring.StateMachineConfig$Config$$Lambda$8/12546741@a522d0"
}
},
{
"timestamp":1478419121956,
"info":{
"duration":1,
"machine":null,
"transition":"EXTERNAL_S1_S2"
}
},
{
"timestamp":1478419121955,
"info":{
"duration":0,
"machine":null,
"action":"demo.monitoring.StateMachineConfig$Config$$Lambda$7/25284245@1c21333"
}
}
]
----

View File

@@ -1722,6 +1722,41 @@ Check sample <<statemachine-examples-eventservice>> for detailed usage.
`RedisConnectionFactory` for it to work and we recommend a
`JedisConnectionFactory` for it as seeing from above example.
[[sm-boot]]
== Spring Boot Support
Currently support for Boot auto-configuration exists only for monitoring
and tracing. If _spring-statemachine-boot_ is in a classpath,
`BootStateMachineMonitor` is created automatically and associated with
a state machine. This `BootStateMachineMonitor` will hook into Boot's
`CounterService`, `GaugeService` and `TraceRepository` if available.
Optionally this auto-configuration can be disabled by setting key
`spring.statemachine.monitor.enabled` to `false`. Use of this
auto-config is shown in sample <<statemachine-examples-monitoring>>.
[[sm-monitoring]]
== Monitoring State Machine
`StateMachineMonitor` can be used to get more information about
durations of how long transitions and actions takes to execute. Below
you can see how this interface is implemented.
[source,java,indent=0]
----
include::samples/DocsConfigurationSampleTests9.java[tags=snippetB]
----
Once you have `StateMachineMonitor` implementation it can be added to
a state machine via configuration as shown below.
[source,java,indent=0]
----
include::samples/DocsConfigurationSampleTests9.java[tags=snippetA]
----
[TIP]
====
Check sample <<statemachine-examples-monitoring>> for detailed usage.
====
[[sm-distributed]]
== Using Distributed States
Distributed state is probably one of a most compicated concepts of a