LogMetrics Framework is used to collect and log the API metrics data and capture the request and response payload.
LogMetrics provides simplified configuration to log payload for spring java projects
maven { url "https://dl.bintray.com/m2/release"}
compile ("io.devxchange:logmetrics:0.0.2")
logmetrics.logging.enabled=true
logmetrics.logging.request.enabled=true
logmetrics.logging.response.enabled=true
logmetrics.logging.obfuscate.enabled=false
logmetrics.logging.obfuscate.md5.fields= #comma seperated fields
logmetrics.logging.obfuscate.sha256.fields= #comma seperated fields
logmetrics.logging.obfuscate.fields= #comma seperated fields
@Configuration
@EnableWebMvc
public class AppConfig extends WebMvcConfigurerAdapter
{
@Autowired
@Qualifier("manager.logwriter")
private LogWriterManager logWriterManager;
@Override
public void addInterceptors(InterceptorRegistry registry)
{
registry.addInterceptor(new RestTransactionInterceptor(logWriterManager));
}
}
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {"io.devxchange.logmetrics"})
public class LoggingDemoApplication {
public static void main(String[] args) {
SpringApplication.run(LoggingDemoApplication.class, args);
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "LogMetrics",
"properties": {
"Node": {
"type": "string",
"description": "Application Host IP Address"
},
"message_type": {
"type": "string",
"description": "Logmetrics message type",
"value": "LOGMETRICS_MESSAGE"
},
"Duration": {
"type": "integer",
"description": "Response time of the API"
},
"Host": {
"type": "string",
"description": "Application Host Name"
},
"Fault": {
"type": "boolean",
"description": "API Success or Failed status "
},
"Method": {
"type": "string",
"description": "API Method name"
},
"ResponseBody": {
"type": "string",
"description": "API Response Body"
},
"StartDateTime": {
"type": "string",
"description": "API Start Time"
},
"EndDateTime": {
"type": "string",
"description": "API End time"
},
"HttpMethod": {
"type": "string",
"description": "Http Method Type"
},
"RequestBody": {
"type": "string",
"description": "API Request Body"
}
}
}
adding request and response payload obfuscation (masking sensitive information)
logging rest verb & payload to console.
feature to enable/disable payload logging
$ git clone https://github.com/devxchange-blog/logmetrics-demo.git
LogMetrics provides simplified configuration to log payload for python flask projects
pip install logmetrics-sdk
enable_logmetrics= True
enable_frontend_request= True
enable_frontend_response= True
enable_backend= True
enable_backend_request= True
enable_backend_response= True
from logmetrics_sdk.logmetrics import LogMetrics
@app.route('/todo/api/v1/tasks', methods=['GET'])
@LogMetrics(enable_logmetrics=True,
enable_frontend_request=True,
enable_frontend_response=True,
enable_backend=True,
enable_backend_request=True,
enable_backend_response=True)
def get_tasks():
return jsonify(tasks)
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "LogMetrics",
"properties": {
"Node": {
"type": "string",
"description": "Application Host IP Address"
},
"MessageType": {
"type": "string",
"description": "Logmetrics message type",
"value": "LOGMETRICS_MESSAGE"
},
"Duration": {
"type": "integer",
"description": "Response time of the API"
},
"Host": {
"type": "string",
"description": "Application Host Name"
},
"Fault": {
"type": "boolean",
"description": "API Success or Failed status "
},
"Method": {
"type": "string",
"description": "API Method name"
},
"ResponseBody": {
"type": "string",
"description": "API Response Body"
},
"StartDateTime": {
"type": "string",
"description": "API Start Time"
},
"EndDateTime": {
"type": "string",
"description": "API End time"
},
"HttpMethod": {
"type": "string",
"description": "Http Method Type"
},
"RequestBody": {
"type": "string",
"description": "API Request Body"
}
}
}
logging rest verb & payload to console.
feature to enable/disable payload logging
$ git clone https://github.com/devxchange-blog/logmetrics-python-demo.git
Development In Progress - LogMetrics provides simplified configuration to log payload for Go projects