From a307a3b903d528b44a93005a537788ecec5c9341 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sun, 15 Jan 2023 08:27:06 +0000 Subject: [PATCH] docs(README): update --- README.md | 130 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 110 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index efc3b05..bc86c32 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ # micronaut-trace -> A Java annotation library to trace and time your method executions, written using [Micronaut](https://micronaut.io/). +> Java annotation library to trace and time your method executions, written using [Micronaut](https://micronaut.io/). ## Installation @@ -17,9 +17,12 @@ Be sure to replace the **VERSION** key below with the version shown above! - me.goudham - micronaut-trace - VERSION + me.goudham + micronaut-trace + VERSION + ``` @@ -32,7 +35,10 @@ repositories { dependencies { // https://mvnrepository.com/artifact/me.goudham/micronaut-trace - implementation group: 'me.goudham', name: 'micronaut-trace', version: 'VERSION' + implementation 'me.goudham:micronaut-trace:VERSION' + + // If you want the .jar with all dependencies! WARNING: This might fix OR introduce various problems with Micronaut + implementation 'me.goudham:micronaut-trace:VERSION:shaded' } ``` @@ -43,34 +49,118 @@ single [release](https://github.com/sgoudham/micronaut-trace/releases). ## Usage -TODO +With the following example code: -## Contributing +`PrintService.java` -TODO +```java +package com.example; -### Development +import jakarta.inject.Singleton; +import me.goudham.micronaut.trace.annotation.Time; +import me.goudham.micronaut.trace.annotation.Trace; -This project uses the build tool [Maven](https://maven.apache.org/) from the java ecosystem. It is *highly* recommended -to develop using [Intellij IDEA](https://www.jetbrains.com/idea/) as it will allow you to take advantage of its -integration with maven tooling. +import static java.lang.Thread.sleep; -The project can be built using the command: +@Singleton +public class PrintService { + public PrintService() { + } -```shell -./mvnw clean package + @Trace + @Time + public void printHello() throws InterruptedException { + System.out.println("hello"); + printAfter5Seconds("hi"); + } + + @Trace + @Time + public void printAfter5Seconds(String message) throws InterruptedException { + sleep(5000); + System.out.println(message); + } +} +``` + +`Application.java` + +```java +package com.example; + +import io.micronaut.context.ApplicationContext; + +public class Application { + public static void main(String[] args) throws InterruptedException { + ApplicationContext applicationContext = ApplicationContext.run(); + PrintService printService = applicationContext.getBean(PrintService.class); + printService.printHello(); + } +} ``` -and running tests is as simple as: +The output would look like: ```shell -./mvnw test +08:09:04.577 [main] TRACE com.example.PrintService - [ENTERING]: printHello() +hello +08:09:04.577 [main] TRACE i.m.aop.chain.InterceptorChain - Intercepted method [void printHiAfter5Seconds(String message)] invocation on target: com.example.$PrintService$Definition$Intercepted@4ef74c30 +08:09:04.577 [main] TRACE i.m.aop.chain.InterceptorChain - Proceeded to next interceptor [me.goudham.micronaut.trace.shared.TimeInterpreter@2438dcd] in chain for method invocation: void printHiAfter5Seconds(String message) +08:09:04.577 [main] TRACE i.m.aop.chain.InterceptorChain - Proceeded to next interceptor [me.goudham.micronaut.trace.shared.TraceInterpreter@41f69e84] in chain for method invocation: void printHiAfter5Seconds(String message) +08:09:04.581 [main] TRACE com.example.PrintService - [ENTERING]: printHiAfter5Seconds(java.lang.String message) +hi +08:09:09.582 [main] TRACE com.example.PrintService - [EXITING]: printHiAfter5Seconds(java.lang.String message) +08:09:09.582 [main] TRACE com.example.PrintService - [EXECUTION_TIME]: Elapsed execution time for printHiAfter5Seconds(java.lang.String message) is 5004 milliseconds +08:09:09.582 [main] TRACE com.example.PrintService - [EXITING]: printHello() +08:09:09.582 [main] TRACE com.example.PrintService - [EXECUTION_TIME]: Elapsed execution time for printHello() is 5005 milliseconds ``` +## Contributing + +Thank you for your interest in Contributing! See the following text for more information on how to build and test the +project. + +### Development + +This project was not intended to be feature-rich but rather a project to play about with the Micronaut framework and +learn more about annotation processing, defining custom annotations and deploying a Micronaut library. + +It is highly recommended that you are familiar with the framework before trying to understand the code. You can find +the latest documentation [here](https://docs.micronaut.io/latest/guide/). + +#### Tooling + +This project uses the build tool [Maven](https://maven.apache.org/) from the java ecosystem. It is *highly* recommended +to develop using [Intellij IDEA](https://www.jetbrains.com/idea/) as it will allow you to take advantage of its +integration with maven tooling. + A great 5-minute introduction to Maven can be found [here](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html). -### CI / CD +#### Building + +The project can be built with the following series of commands: + +1. Clone Repository + + ```shell + git clone https://github.com/sgoudham/micronaut-trace.git + ``` + +2. [Enable Annotation Processing](https://docs.micronaut.io/latest/guide/#ideaSetup) + +3. Build & Package + + ```shell + ./mvnw clean package + ``` + +4. Run Tests + + ```shell + ./mvnw test + ``` + +## License -This project has a GitHub actions workflow to automatically build binaries and deploy to maven central. The workflows -are stored at [.github/workflows](.github/workflows) \ No newline at end of file +[MIT](LICENSE) \ No newline at end of file