Code Monkey home page Code Monkey logo

spring-metrik's Introduction

Spring Metrik

Build Status CodeCov Maintainability Dependency Status Quality Gate Maven Central

Metrik is lightweight Spring library to monitor your services execution.

Installation

@Metrik release is published on the Maven Central, so you can install it from your preferred dependency management tool : Gradle or Maven.

Maven

Include the following lines to your pom.xml dependencies :

<dependencies>
    <dependency>
      <groupId>io.github.tibus29</groupId>
      <artifactId>spring-metrik</artifactId>
      <version>1.2.0</version>
    </dependency>
</dependencies>

Gradle

Include the following line to your build.gradle dependencies :

compile 'io.github.tibus29:spring-metrik:1.2.0'

Usage

Using the library is very simple, you simply have to annotate the bean you want to monitor with@Metrik :

@Service
@Metrik(value = "MY_SERVICE", traceMode = TraceMode.AUTO) // custom metrik group, TraceMode.AUTO will output all params and result
public class MyService {
    
    public String sayHelloTo(String name) { 
        return "Hello, " + name + " !"; 
    }
    
    @Metrik(params = { "username" }) // prevent for logging clear password into logs !
    public boolean authenticate(String username, String password) {
        return true;
    }
    
    @Metrik(enabled = false)
    public void doSomething() {
        log.info("I do something...");   
    }
}

@RestController
@RequestMapping("/")
public class MyController {
    
    @Inject
    MyService myService;
    
    class MyBean {
        private String action = "Please clone me !";
    }
    
    @GetMapping
    @Metrik(resultFields = { "toto" }) // the annotation can be placed on a single method
    public MyBean index() {
        log.info(this.myService.sayHelloTo("Foo"));
        log.info("Authentication : {} !", this.myService.authenticate("[email protected]", "password") ? "success" : "failure");
        this.myService.doSomething();
        return new MyBean();
    }
}

Output :

MY_SERVICE|sayHelloTo|21|OK|[name='Foo']|['Hello, Foo !']
Hello, Foo !
MY_SERVICE|authenticate|125|OK|[username='[email protected]']|[true]
Authentication : success !
I do something...
MyController|index|163|OK|[]|[action='Please clone me !']

spring-metrik's People

Contributors

thibauult avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

spring-metrik's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.