@@ -1236,19 +1236,19 @@ Example:
1236
1236
1237
1237
[source,java,indent=0]
1238
1238
----
1239
- @Bean
1240
- @ExportMetricWriter
1241
- MetricWriter metricWriter(MetricExportProperties export) {
1242
- return new RedisMetricRepository(connectionFactory,
1243
- export.getRedis().getPrefix(), export.getRedis().getKey());
1244
- }
1239
+ @Bean
1240
+ @ExportMetricWriter
1241
+ MetricWriter metricWriter(MetricExportProperties export) {
1242
+ return new RedisMetricRepository(connectionFactory,
1243
+ export.getRedis().getPrefix(), export.getRedis().getKey());
1244
+ }
1245
1245
----
1246
1246
1247
1247
.application.properties
1248
- [source,properties]
1248
+ [source,properties,indent=0 ]
1249
1249
----
1250
- spring.metrics.export.redis.prefix: metrics.mysystem.${spring.application.name:application}.${random.value:0000}
1251
- spring.metrics.export.redis.key: keys.metrics.mysystem
1250
+ spring.metrics.export.redis.prefix: metrics.mysystem.${spring.application.name:application}.${random.value:0000}
1251
+ spring.metrics.export.redis.key: keys.metrics.mysystem
1252
1252
----
1253
1253
1254
1254
The prefix is constructed with the application name and id at the end, so it can easily be used
@@ -1287,21 +1287,21 @@ Example:
1287
1287
1288
1288
[source,indent=0]
1289
1289
----
1290
- curl localhost:4242/api/query?start=1h-ago&m=max:counter.status.200.root
1291
- [
1292
- {
1293
- "metric": "counter.status.200.root",
1294
- "tags": {
1295
- "domain": "org.springframework.metrics",
1296
- "process": "b968a76"
1297
- },
1298
- "aggregateTags": [],
1299
- "dps": {
1300
- "1430492872": 2,
1301
- "1430492875": 6
1290
+ curl localhost:4242/api/query?start=1h-ago&m=max:counter.status.200.root
1291
+ [
1292
+ {
1293
+ "metric": "counter.status.200.root",
1294
+ "tags": {
1295
+ "domain": "org.springframework.metrics",
1296
+ "process": "b968a76"
1297
+ },
1298
+ "aggregateTags": [],
1299
+ "dps": {
1300
+ "1430492872": 2,
1301
+ "1430492875": 6
1302
+ }
1302
1303
}
1303
- }
1304
- ]
1304
+ ]
1305
1305
----
1306
1306
1307
1307
@@ -1320,14 +1320,14 @@ Alternatively, you can provide a `@Bean` of type `StatsdMetricWriter` and mark i
1320
1320
1321
1321
[source,java,indent=0]
1322
1322
----
1323
- @Value("${spring.application.name:application}.${random.value:0000}")
1324
- private String prefix = "metrics";
1323
+ @Value("${spring.application.name:application}.${random.value:0000}")
1324
+ private String prefix = "metrics";
1325
1325
1326
- @Bean
1327
- @ExportMetricWriter
1328
- MetricWriter metricWriter() {
1329
- return new StatsdMetricWriter(prefix, "localhost", 8125);
1330
- }
1326
+ @Bean
1327
+ @ExportMetricWriter
1328
+ MetricWriter metricWriter() {
1329
+ return new StatsdMetricWriter(prefix, "localhost", 8125);
1330
+ }
1331
1331
----
1332
1332
1333
1333
@@ -1343,11 +1343,11 @@ Example:
1343
1343
1344
1344
[source,java,indent=0]
1345
1345
----
1346
- @Bean
1347
- @ExportMetricWriter
1348
- MetricWriter metricWriter(MBeanExporter exporter) {
1349
- return new JmxMetricWriter(exporter);
1350
- }
1346
+ @Bean
1347
+ @ExportMetricWriter
1348
+ MetricWriter metricWriter(MBeanExporter exporter) {
1349
+ return new JmxMetricWriter(exporter);
1350
+ }
1351
1351
----
1352
1352
1353
1353
Each metric is exported as an individual MBean. The format for the `ObjectNames` is given
@@ -1374,24 +1374,24 @@ Example:
1374
1374
1375
1375
[source,java,indent=0]
1376
1376
----
1377
- @Autowired
1378
- private MetricExportProperties export;
1377
+ @Autowired
1378
+ private MetricExportProperties export;
1379
1379
1380
- @Bean
1381
- public PublicMetrics metricsAggregate() {
1382
- return new MetricReaderPublicMetrics(aggregatesMetricReader());
1383
- }
1380
+ @Bean
1381
+ public PublicMetrics metricsAggregate() {
1382
+ return new MetricReaderPublicMetrics(aggregatesMetricReader());
1383
+ }
1384
1384
1385
- private MetricReader globalMetricsForAggregation() {
1386
- return new RedisMetricRepository(this.connectionFactory,
1387
- this.export.getRedis().getAggregatePrefix(), this.export.getRedis().getKey());
1388
- }
1385
+ private MetricReader globalMetricsForAggregation() {
1386
+ return new RedisMetricRepository(this.connectionFactory,
1387
+ this.export.getRedis().getAggregatePrefix(), this.export.getRedis().getKey());
1388
+ }
1389
1389
1390
- private MetricReader aggregatesMetricReader() {
1391
- AggregateMetricReader repository = new AggregateMetricReader(
1392
- globalMetricsForAggregation());
1393
- return repository;
1394
- }
1390
+ private MetricReader aggregatesMetricReader() {
1391
+ AggregateMetricReader repository = new AggregateMetricReader(
1392
+ globalMetricsForAggregation());
1393
+ return repository;
1394
+ }
1395
1395
----
1396
1396
1397
1397
NOTE: The example above uses `MetricExportProperties` to inject and extract the key and
@@ -1455,34 +1455,34 @@ and obtain basic information about the last 100 requests:
1455
1455
1456
1456
[source,json,indent=0]
1457
1457
----
1458
- [{
1459
- "timestamp": 1394343677415,
1460
- "info": {
1461
- "method": "GET",
1462
- "path": "/trace",
1463
- "headers": {
1464
- "request": {
1465
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
1466
- "Connection": "keep-alive",
1467
- "Accept-Encoding": "gzip, deflate",
1468
- "User-Agent": "Mozilla/5.0 Gecko/Firefox",
1469
- "Accept-Language": "en-US,en;q=0.5",
1470
- "Cookie": "_ga=GA1.1.827067509.1390890128; ..."
1471
- "Authorization": "Basic ...",
1472
- "Host": "localhost:8080"
1473
- },
1474
- "response": {
1475
- "Strict-Transport-Security": "max-age=31536000 ; includeSubDomains",
1476
- "X-Application-Context": "application:8080",
1477
- "Content-Type": "application/json;charset=UTF-8",
1478
- "status": "200"
1479
- }
1480
- }
1481
- }
1482
- },{
1483
- "timestamp": 1394343684465,
1484
- ...
1485
- }]
1458
+ [{
1459
+ "timestamp": 1394343677415,
1460
+ "info": {
1461
+ "method": "GET",
1462
+ "path": "/trace",
1463
+ "headers": {
1464
+ "request": {
1465
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
1466
+ "Connection": "keep-alive",
1467
+ "Accept-Encoding": "gzip, deflate",
1468
+ "User-Agent": "Mozilla/5.0 Gecko/Firefox",
1469
+ "Accept-Language": "en-US,en;q=0.5",
1470
+ "Cookie": "_ga=GA1.1.827067509.1390890128; ..."
1471
+ "Authorization": "Basic ...",
1472
+ "Host": "localhost:8080"
1473
+ },
1474
+ "response": {
1475
+ "Strict-Transport-Security": "max-age=31536000 ; includeSubDomains",
1476
+ "X-Application-Context": "application:8080",
1477
+ "Content-Type": "application/json;charset=UTF-8",
1478
+ "status": "200"
1479
+ }
1480
+ }
1481
+ }
1482
+ },{
1483
+ "timestamp": 1394343684465,
1484
+ ...
1485
+ }]
1486
1486
----
1487
1487
1488
1488
0 commit comments