Implement custom trace repository

- Upgrade to boot 2.0.0.RC1
- Copy original boot's tracing features to get used
  as a base impl for statemachine.
- Fix samples, tests.
- Fixes #491
This commit is contained in:
jvalkeal
2018-02-11 09:24:13 +02:00
parent c693e79f12
commit 328a2e9161
12 changed files with 378 additions and 80 deletions

View File

@@ -1605,21 +1605,57 @@ Metrics can be viewed from Boot.
[source,json]
----
# curl http://localhost:8080/application/metrics
# curl http://localhost:8080/actuator/metrics/ssm.transition.duration
{
"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,
"name":"ssm.transition.duration",
"measurements":[
{
"statistic":"COUNT",
"value":3.0
},
{
"statistic":"TOTAL_TIME",
"value":0.007
},
{
"statistic":"MAX",
"value":0.004
}
],
"availableTags":[
{
"tag":"transitionName",
"values":[
"INITIAL_S1",
"EXTERNAL_S1_S2"
]
}
]
}
----
[source,json]
----
# curl http://localhost:8080/actuator/metrics/ssm.transition.transit
{
"name":"ssm.transition.transit",
"measurements":[
{
"statistic":"COUNT",
"value":3.0
}
],
"availableTags":[
{
"tag":"transitionName",
"values":[
"EXTERNAL_S1_S2",
"INITIAL_S1"
]
}
]
}
----
@@ -1627,49 +1663,40 @@ Tracing can be viewed from Boot.
[source,json]
----
# curl http://localhost:8080/application/trace
# curl http://localhost:8080/actuator/statemachinetrace
[{
"timestamp":1478419121956,
"info":{
"duration":0,
"machine":null,
"transition":
"EXTERNAL_S2_S3"
[
{
"timestamp":"2018-02-11T06:44:12.723+0000",
"info":{
"duration":2,
"machine":null,
"transition":"EXTERNAL_S1_S2"
}
},
{
"timestamp":"2018-02-11T06:44:12.720+0000",
"info":{
"duration":0,
"machine":null,
"action":"demo.monitoring.StateMachineConfig$Config$$Lambda$576/1499688007@22b47b2f"
}
},
{
"timestamp":"2018-02-11T06:44:12.714+0000",
"info":{
"duration":1,
"machine":null,
"transition":"INITIAL_S1"
}
},
{
"timestamp":"2018-02-11T06:44:09.689+0000",
"info":{
"duration":4,
"machine":null,
"transition":"INITIAL_S1"
}
}
},
{
"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

@@ -1926,13 +1926,15 @@ integration logic with _Spring Boot_ providing functionality i.e. for
auto-config and actuators. All what is needed is to have _State
Machine_ as part of a boot application together with this library.
[[sm-boot-monitoring]]
=== Monitoring and Tracing
`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>>.
a state machine. `BootStateMachineMonitor` is a custom `StateMachineMonitor`
implementation which integrates with boot's `MeterRegistry` and endpoints
via a custom `StateMachineTraceRepository`. 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>>.
=== Repository Config
Spring Data Repositories and Entity class scanning is auto-configured

View File

@@ -47,3 +47,11 @@ _Spring Statemachine 1.3_.
* Transition conflict policy mentioned in
<<statemachine-config-commonsettings>>
== In 2.0
_Spring Statemachine 2.0_ is focusing on _Spring Boot 2.x_ support.
=== In 2.0.0
* Format of monitoring and trancing has beenn changed <<sm-boot-monitoring>>