- Cloud-Native Applications in Java
- Ajay Mahajan Munish Kumar Gupta Shyam Sundar
- 183字
- 2021-06-24 19:07:17
Metering your services
Instrumentation is important for cloud applications. Your service should expose health check and metrics so that it can be monitored better. Spring Boot allows for easier instrumentation through the actuator module.
Include the following in your POM:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
Run the service. During startup, you will see a number of mappings being created.
You can access these URLs (such as http://localhost:8080/env) directly and see the information displayed:
{ "profiles": [], "server.ports": { "local.server.port": 8082 }, "commandLineArgs": { "env": "dev/" }, "servletContextInitParams": {}, "systemProperties": { "java.runtime.name": "Java(TM) SE Runtime Environment", "sun.boot.library.path": "C:\Program Files\Java\jdk1.8.0_73\jrebin", "java.vm.version": "25.73-b02", "java.vm.vendor": "Oracle Corporation", "java.vendor.url": "http://java.oracle.com/", "path.separator": ";", "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM", "file.encoding.pkg": "sun.io", "user.country": "IN", "user.script": "", "sun.java.launcher": "SUN_STANDARD", "sun.os.patch.level": "Service Pack 1", "PID": "9332", "java.vm.specification.name": "Java Virtual Machine Specification", "user.dir": "C:\Apps\wkneon\product",
The metrics are especially interesting (http://localhost:8080/metrics):
{ "mem": 353416, "mem.free": 216921, "processors": 4, "instance.uptime": 624968, "uptime": 642521, ... "gauge.servo.response.dev.product.id": 5, ... threads.peak": 38, "threads.daemon": 35, "threads.totalStarted": 45, "threads": 37, ...
The information includes the counters and gauges which store the number of times the service was accessed and the response times.
推薦閱讀
- 手機結(jié)構(gòu)設(shè)計完全自學(xué)與速查手冊
- 基于集成學(xué)習(xí)的角反射體目標(biāo)雷達(dá)識別理論與方法
- 加權(quán)分?jǐn)?shù)傅里葉變換及其在通信系統(tǒng)中的應(yīng)用
- 中壓電纜全壽命周期典型缺陷圖集
- iPhone玩家必備
- 短視頻制作實戰(zhàn) 策劃 拍攝 制作 運營(全彩慕課版)
- 液晶顯示器維修實踐技術(shù)
- 電子產(chǎn)品調(diào)試技能演練
- 5G NR無線網(wǎng)絡(luò)優(yōu)化實踐
- 電子元器件檢測與應(yīng)用
- Photoshop手機App界面設(shè)計實戰(zhàn)入門
- 光通信技術(shù)與應(yīng)用
- 未解之謎(上)
- 彩色電視機元器件檢測·選用·代換手冊
- LED照明技術(shù)與設(shè)計100問