LogMetrics Framework

Last updated: Nov 23th, 2019

General

LogMetrics Framework is used to collect and log the API metrics data and capture the request and response payload.

Java

LogMetrics provides simplified configuration to log payload for spring java projects

Repository
 maven { url "https://dl.bintray.com/m2/release"}
Dependency- Gradle
compile ("io.devxchange:logmetrics:0.0.2")
properties
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
AppConfig
@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));
	}
}                                        
SpringApplication
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);
	}
}
Logmetrics Schema

{
  "$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"
    }
  }
}
Release
0.0.2
adding request and response payload obfuscation (masking sensitive information)
0.0.1
logging rest verb & payload to console.
feature to enable/disable payload logging
Git Demo Example
$ git clone https://github.com/devxchange-blog/logmetrics-demo.git 

Python

LogMetrics provides simplified configuration to log payload for python flask projects

Pypi Module
pip install logmetrics-sdk
properties
enable_logmetrics= True
enable_frontend_request= True
enable_frontend_response= True
enable_backend= True
enable_backend_request= True
enable_backend_response= True 
Usage
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)
Logmetrics Schema
{
  "$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"
    }
  }
}
Release
1.0.3
logging rest verb & payload to console.
feature to enable/disable payload logging
Git Demo Example
$ git clone https://github.com/devxchange-blog/logmetrics-python-demo.git 

Go

Development In Progress - LogMetrics provides simplified configuration to log payload for Go projects