<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cosmin Seceleanu on Medium]]></title>
        <description><![CDATA[Stories by Cosmin Seceleanu on Medium]]></description>
        <link>https://medium.com/@sece.cosmin?source=rss-75a2d79e8596------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*R1A1TJ1GEr9SD3S89RM8wg.jpeg</url>
            <title>Stories by Cosmin Seceleanu on Medium</title>
            <link>https://medium.com/@sece.cosmin?source=rss-75a2d79e8596------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:01:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sece.cosmin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Enhancing Code Readability with Java Pattern Matching]]></title>
            <link>https://medium.com/@sece.cosmin/enhancing-code-readability-with-java-pattern-matching-1a71251498b?source=rss-75a2d79e8596------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a71251498b</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[pattern-matching]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Cosmin Seceleanu]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 12:19:16 GMT</pubDate>
            <atom:updated>2023-03-03T14:57:17.925Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Java 14 introduced a new feature called pattern matching, which aims to simplify the process of matching patterns in code and make it more readable. This feature allows developers to match against different types of data, such as objects, primitives, and instance of classes using the <em>instanceof</em> operator in a more concise and readable way.</p><p>Additionally, pattern matching also provides a way to extract data from matched patterns and assign them to variables, making it easier to work with matched data. In this article, we will explore the basics of pattern matching and how it can be used to improve the readability and maintainability of your code.</p><h3>Definition</h3><p>In the context of programming languages, pattern matching is a technique used to match a specific pattern within a given input. It can be used to simplify the process of identifying and extracting relevant information from structured data, such as objects, lists, and other complex data types.</p><p>In functional languages, pattern matching can be used as an alternative to traditional control flow statements such as if-else or switch-case.</p><h3>Benefits</h3><ul><li>Simplicity and readability: Pattern matching provides a more concise and readable syntax compared to traditional control flow statements</li><li>Improved type safety: Pattern matching allows developers to match against different types of data, such as objects, primitives, and instances of classes using the <em>instanceof</em> operator. This can lead to better type safety, as it reduces the risk of type errors and makes it easier to handle exceptions and errors.</li><li>Extracting values from matched patterns: With pattern matching, it is possible to extract values from matched patterns and assign them to variables, making it easier to work with matched data.</li></ul><h3>Pattern matching in action</h3><p>Throughout this article, we will utilize the following classes to demonstrate the advantages of pattern matching in Java.</p><pre>  public interface Shape {<br>    Double area();<br>  }<br><br>  public final static class Circle implements Shape {<br>    public final double radius;<br><br>    Circle(double radius) {<br>      this.radius = radius;<br>    }<br><br>    @Override<br>    public Double area() {<br>      return Math.PI * radius * radius;<br>    }<br>  }<br><br>  public final static class Square implements Shape {<br>    public final double side;<br><br>    Square(double side) {<br>      this.side = side;<br>    }<br><br>    @Override<br>    public Double area() {<br>      return side * side;<br>    }<br>  }</pre><h4>Type matching</h4><p><em>instanceof</em> is a traditional approach to type matching. It checks if an object is an instance of a particular type and returns a boolean value. It is often used in conditional statements to determine the type of an object and take action accordingly.</p><p>On the other hand, the switch statement with pattern matching, introduced in Java 17, is a more concise and expressive way to perform type matching. It allows you to match against the type of an object and extract its fields, reducing the risk of type errors.</p><pre>  //using instance of<br>  public static void printLength(Shape shape) {<br>    if (shape instanceof Circle) {<br>      Circle circle = (Circle) shape;<br>      System.out.println(&quot;Circle radius=&quot; + circle.radius);<br>    } else if (shape instanceof Square) {<br>      Square square = (Square) shape;<br>      System.out.println(&quot;Square side=&quot; + square.side);<br>    } else {<br>      System.out.println(&quot;Unknown shape&quot;);<br>    }<br>  }<br><br>  // using pattern matching<br>  public static void printLengthPM(Shape shape) {<br>    switch (shape) {<br>      case Circle c -&gt; System.out.println(&quot;Circle radius=&quot; + c.radius);<br>      case Square s -&gt; System.out.println(&quot;Square side=&quot; + s.side);<br>      default -&gt; System.out.println(&quot;Unknown shape&quot;);<br>    }<br>  }</pre><p>As we can see, the use of pattern matching makes the code more concise and readable, and eliminates the need to cast the matched objects to the correct type ❤️.</p><h4>Null matching</h4><p>Handling `<em>null</em>` values is a common task in programming, and pattern matching provides an elegant way to handle it. <br>In the example bellow `<em>printLengthPM(Shape shape)</em>`, the switch statement includes a case for `null` to handle missing shapes.</p><p>In comparison to the traditional method of checking for `<em>null</em>` values through `<em>if</em>` statements, pattern matching simplifies the code and eliminates the need for separate null checks. This makes the code more readable and reduces the potential for maintenance issues as the code grows larger.</p><pre>public static void printLength(Shape shape) {<br>    if (shape == null) {<br>      System.out.println(&quot;missing shape&quot;);<br>      return;<br>    }<br>    ----------<br>}</pre><pre>public static void printLengthPM(Shape shape) {<br>    switch (shape) {<br>      case null -&gt; System.out.println(&quot;missing shape&quot;);<br>      case Circle c -&gt; System.out.println(&quot;Circle radius=&quot; + c.radius);<br>      case Square s -&gt; System.out.println(&quot;Square side=&quot; + s.side);<br>      default -&gt; System.out.println(&quot;Unknown shape&quot;);<br>    }<br>  }</pre><h4>Dominance</h4><p>In Java pattern matching, dominance plays a crucial role in ensuring code correctness and avoiding ambiguity. Dominance refers to the idea that if a certain case matches the input value, all other cases that are more specific or subtypes of the first match should not be executed.</p><p>Consider the following example:</p><pre>public static void processNumber(Object input) {<br>  switch (input) {<br>    case Number n -&gt; System.out.println(&quot;got a number=&quot; + n);<br>    case Integer n -&gt; System.out.println(&quot;got an integer=&quot; + n);<br>    default -&gt; System.out.println(&quot;Unknown number&quot;);<br>  }<br>}</pre><p>In this example, the case for Integer n will never be executed because it is dominated by the preceding case for Number n. This leads to a compile-time error, “this case label is dominated by a preceding case label”.<br>To fix this error, the order of cases should be changed so that the more specific cases come first.</p><h4>Completeness</h4><p>Completeness refers to ensuring that all possible cases are handled within a pattern matching expression. In pattern matching, it’s important to have a complete switch expression to avoid unexpected behavior or errors in the code.<br>In this section, we will delve into ensuring completeness in Java pattern matching.<br>It is important to consider completeness because, as demonstrated in our first example of the `<em>printLengthPM</em>` method, failing to include a default case in a `<em>switch</em>` statement will result in a compile error indicating that the `<em>switch</em>` statement does not cover all possible input values.</p><p>To avoid the need for a default case, the `<em>Shape</em>` interface can be made sealed. This can be done by simply adding the keyword `<em>sealed</em>` to the interface declaration, as follows:</p><pre>public sealed interface Shape {}</pre><p>Updated version of `<em>printLengthPM</em>` method:</p><pre>public static void printLengthPM(Shape shape) {<br>    switch (shape) {<br>      case null -&gt; System.out.println(&quot;missing shape&quot;);<br>      case Circle c -&gt; System.out.println(&quot;Circle radius=&quot; + c.radius);<br>      case Square s -&gt; System.out.println(&quot;Square side=&quot; + s.side);<br>    }<br>  }</pre><p>If a new implementation of<em> `Shape`</em> named <em>`Rectangle`</em> is added, the above method that uses the sealed interface will not compile until the switch statement is updated to handle the new type <em>`Rectangle`</em>.</p><p>It is recommended to not include a default case as it can lead to unexpected results if the switch statement does not cover all possible input values.<br>Instead, using a sealed interface for the switch expression is a better way to ensure completeness. By declaring the interface sealed, the compiler can verify that all possible subtypes of the switch expression are covered in the cases. This results in more robust and error-proof code.</p><h4>Guarded patterns</h4><p>Guarded patterns in Java pattern matching provide a way to match against a value only if a certain condition is met.<br>This allows for more fine-grained control over the matching process and adds an extra level of complexity to the switch statement.</p><p>Here’s an example:</p><pre>public static void printLengthPMWithGuard(Shape shape) {<br>    switch (shape) {<br>      case Circle c when c.radius &gt; 10 -&gt; System.out.println(&quot;Circle with large radius=&quot; + c.radius);<br>      case Circle c -&gt; System.out.println(&quot;Circle with small radius=&quot; + c.radius);<br>      case Square s when s.side &gt; 10 -&gt; System.out.println(&quot;Square with large side=&quot; + s.side);<br>      case Square s -&gt; System.out.println(&quot;Square with small side=&quot; + s.side);<br>    }<br>  }</pre><p>In this example, the<em> `printLengthPMWithGuard`</em> method uses <strong>guarded patterns</strong> to match against a <em>`Circle`</em> or <em>`Square`</em> only if a certain condition is met, such as the radius or side being greater than 10.</p><p>This allows for more specific handling of values, and makes the code more flexible and maintainable.</p><h3>Conclusion</h3><p>In conclusion, pattern matching is a valuable addition to the Java language that provides a more readable and concise way to perform type matching. Its use of sealed interfaces, pattern matching, and guarded patterns provide a new way to handle null values, ensure completeness, and simplify complex code. With its ease of use and improved readability, pattern matching is a great way to improve your Java code and make it easier to maintain.<br>Whether you are a beginner or an experienced Java developer, pattern matching is definitely worth exploring and adding to your coding arsenal.</p><p>You can find the full working code and documentation on this Git repository:<a href="https://github.com/cosminseceleanu/tutorials/tree/master/pattern-matching/src"> https://github.com/cosminseceleanu/tutorials</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a71251498b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Virtual Threads: The Next Step in Java’s Concurrency Evolution]]></title>
            <link>https://medium.com/@sece.cosmin/virtual-threads-the-next-step-in-javas-concurrency-evolution-51666ff3383c?source=rss-75a2d79e8596------2</link>
            <guid isPermaLink="false">https://medium.com/p/51666ff3383c</guid>
            <category><![CDATA[java19]]></category>
            <category><![CDATA[multi-threaded]]></category>
            <category><![CDATA[virtual-threads]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[scalability]]></category>
            <dc:creator><![CDATA[Cosmin Seceleanu]]></dc:creator>
            <pubDate>Sun, 22 Jan 2023 09:39:42 GMT</pubDate>
            <atom:updated>2023-01-22T09:39:42.231Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Java Virtual Threads is a new feature introduced in Java 19 that aims to improve the performance and scalability of multi-threaded applications.</p><p>Virtual threads provide a lightweight alternative to traditional operating system threads, allowing for a larger number of concurrent threads without the overhead of creating and managing a large number of native threads.<br>This can lead to increased performance and improved resource utilization, especially in situations where a large number of threads are needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*NGPiSz3VSapaI-ZHmidwzA.png" /></figure><p>Additionally, virtual threads provide a simplified programming model for developing concurrent applications, making it easier for developers to write and maintain high-performance multi-threaded code. Overall, Java Virtual Threads is a powerful tool for improving the performance and scalability of multi-threaded Java applications.</p><h3>OS threads</h3><p>Operating system (OS) threads are considered heavy and not scalable because they require a significant amount of memory and resources to create and manage. Each OS thread requires its own stack, which can consume a large amount of memory, especially when there are a large number of threads.<br>Additionally, creating and managing a large number of OS threads can also place a significant burden on the operating system, causing it to spend more time managing the threads and less time executing the actual application code.</p><p>In summary, OS threads are heavy and not scalable because they require a significant amount of memory and resources to create and manage, which can lead to decreased performance and scalability issues when there are a large number of threads.</p><h3>Virtual threads</h3><p>Java Virtual Threads address the bottlenecks associated with OS threads in several ways:</p><ul><li>Reduced memory footprint: Virtual threads use a shared stack, which reduces the memory footprint of each thread, allowing for a larger number of concurrent threads without the overhead of creating and managing a large number of native threads.</li><li>Reduced contention for resources: Virtual threads are scheduled by the Java Virtual Machine (JVM) rather than the operating system, which reduces contention for resources such as CPU and memory, resulting in improved performance and scalability.</li><li>Reduced context switching: Virtual threads do not require context switching between user and kernel space, which eliminates the overhead associated with switching between native and virtual threads, leading to improved performance.</li><li>Simplified programming model: Virtual threads provide a simplified programming model for developing concurrent applications, making it easier for developers to write and maintain high-performance multi-threaded code.</li></ul><h3>Programming model</h3><p>The programming model for Java Virtual Threads is simplified because it is based on the familiar Java Thread API, which developers are already familiar with.</p><pre>Thread.ofVirtual().start(() -&gt; System.out.println(&quot;Hello world!&quot;));</pre><p>Managing virtual threads is also similar to managing regular threads. Developers can use the familiar <em>join</em>, <em>interrupt</em>, and <em>isAlive</em> methods to control the execution of virtual threads.</p><p>One major advantage of the programming model is that developers don’t have to worry about managing the underlying operating system threads, which can be a complex and error-prone task. The JVM’s scheduler takes care of managing the execution of virtual threads, leaving developers free to focus on the logic of their applications.</p><h4>Still need thread pools and event loops?</h4><p>Event loops and thread pools are still useful in certain situations even with the introduction of virtual threads.</p><p>Event loops are often used in network programming, for example, in web servers and other types of servers that handle a large number of connections. An event loop allows a single thread to handle multiple connections simultaneously, reducing the overhead of creating and managing a separate thread for each connection. Virtual threads do not eliminate the need for event loops but rather provide an alternative approach to managing concurrency in situations where a large number of threads are needed.</p><p>Thread pools, on the other hand, are often used to manage a fixed number of worker threads that are used to execute tasks. Thread pools can be useful in situations where there is a large number of tasks that need to be executed concurrently, and where the number of tasks can vary over time. Virtual threads can also be used to execute tasks, but thread pools provide more control over the number of threads and can be useful when there is a need to limit the number of threads in use.</p><h3>Virtual Threads In Action</h3><p>To demonstrate the advantages of virtual threads more effectively, we can conduct a simple experiment involving the creation of 1000 threads, each performing a dummy task for a brief period of time (a few minutes). The test was carried out on a Macbook PRO 2021 with M1 max chip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x9ywBbqmkloQY_yxtHwtdw.png" /></figure><p>Runnable task:</p><pre>private static void looper(int count) {<br>    var tid = Thread.currentThread().threadId();<br>    if (count &gt; 50000) {<br>      return;<br>    }<br>    try {<br>      Thread.sleep(10);<br>      if (count % 100 == 0) {<br>        System.out.println(&quot;Thread id: &quot; + tid + &quot; : &quot; + count);<br>      }<br>    } catch (InterruptedException e) {<br>      e.printStackTrace();<br>    }<br>    looper(count + 1);<br>  }</pre><h4>OS threads</h4><p><strong>Java code</strong></p><pre>var threads = IntStream.range(0, 1_000)<br>    .mapToObj(i -&gt; {<br>      var t = makeThread(() -&gt; looper(1));<br>      t.start();<br>      System.out.println(i + &quot; thread started&quot;);<br>      return t;<br>    })<br>    .toList();<br>threads.forEach(t -&gt; {<br>  try {<br>    t.join();<br>  } catch (InterruptedException e) {<br>    e.printStackTrace();<br>  }<br>});<br>---------<br>public static Thread makeThread(Runnable task) {<br>   return new Thread(task);<br>}</pre><p><strong>Result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVHNinEhEwtzdN-fqIrccg.png" /></figure><h4>Virtual threads</h4><p><strong>Java code</strong></p><pre>var threads = IntStream.range(0, 1_000)<br>    .mapToObj(i -&gt; {<br>      var t = makeThread(() -&gt; looper(1));<br>      t.start();<br>      System.out.println(i + &quot; thread started&quot;);<br>      return t;<br>    })<br>    .toList();<br>threads.forEach(t -&gt; {<br>  try {<br>    t.join();<br>  } catch (InterruptedException e) {<br>    e.printStackTrace();<br>  }<br>});<br>---------<br>public static Thread makeThread(Runnable task) {<br>   return Thread.ofVirtual().unstarted(task);<br>}</pre><p><strong>Result</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFrdnOQx47NTQNcGLsmBhQ.png" /></figure><p>By raising the maximum number of threads to 100K, I was able to instantiate them on my local machine, which marked a significant enhancement as compared to the previous limit of 2.8k OS threads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxxMcxteOtLPxlstGqW48Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TFFun8uGpHOWJXUAqJZPig.png" /></figure><h3>Conclusion</h3><p>Virtual threads provide an alternative approach to managing concurrency, and developers should carefully evaluate their specific use case to determine if virtual threads are the best solution for their needs.</p><p>In summary, Java Virtual Threads is a powerful tool for improving the performance and scalability of multi-threaded Java applications, and it can be used alongside other concurrency mechanisms such as event loops and thread pools, depending on the specific use case.</p><p>You can find the full working code and documentation on this Git repository: <a href="https://github.com/cosminseceleanu/tutorials/tree/master/virtual-threads/src">https://github.com/cosminseceleanu/tutorials/tree/master/virtual-threads/src</a></p><h3>References</h3><p>- <a href="https://blogs.oracle.com/javamagazine/post/going-inside-javas-project-loom-and-virtual-threads">https://blogs.oracle.com/javamagazine/post/going-inside-javas-project-loom-and-virtual-threads</a> <br>- <a href="https://cr.openjdk.java.net/~rpressler/loom/Loom-Proposal.html">https://cr.openjdk.java.net/~rpressler/loom/Loom-Proposal.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51666ff3383c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitor Spring Boot Application Performance with Elastic APM, Elasticsearch and Kibana]]></title>
            <link>https://medium.com/@sece.cosmin/monitor-spring-boot-application-performance-with-elastic-apm-elasticsearch-and-kibana-8d4299cad2be?source=rss-75a2d79e8596------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d4299cad2be</guid>
            <category><![CDATA[apm]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Cosmin Seceleanu]]></dc:creator>
            <pubDate>Sun, 03 Feb 2019 17:32:33 GMT</pubDate>
            <atom:updated>2019-02-03T17:32:33.028Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>We know that applications deployed in a production state require large amount of data for performance and debugging purposes. In this article I will teach you how to monitor performance for a simple Spring Boot application.</p><p>But first we need to define what is application performance monitoring and why do we need it. Application performance monitoring, also known as APM, is used to check that application meet performance standards and provide a good quality user experience.</p><p>Most APM tools are collecting metrics about the response time for incoming requests, CPU utilisation, bandwidth used, memory consumption, data throughput, database commands, code executions and so on. We need APM to have an idea how application behaves over time and how it responds under different throughput’s. Also very often APM dashboards are used to quickly discover, isolate and solve problems when they appear.</p><p>In this tutorial we are going to:</p><ol><li>Develop a REST API and some background tasks using Spring Boot 2</li><li>Deploy application as docker container</li><li>Deploy Elastic APM, Elasticsearch and Kibana as docker containers</li><li>Use Kibana APM dashboard to monitor Spring Boot application</li></ol><p>To be able to complete this tutorial, I assume you have installed Maven, Docker and docker-compose. If you don’t have it already, follow the official instructions. This article assumes that the Docker runs natively and the containers are accessible through localhost.</p><h3>Architecture</h3><p>All services used in this tutorial will run as docker containers. Our purpose is to monitor performance for Java applications, so we will have some containers with a Spring Boot application. These applications will be profiled by a java agent provided by Elastic.</p><p>The java agent will collect and send metrics to the APM server and then the APM server will transform this metrics and in the end will send them to the Elasticsearch. Once metrics are stored in Elasticsearch, you can explore your application performance by using Kibana built-in APM dashboards which can be found under the “APM” tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTmt2dPFQf1OPVqQ9XRKMw.png" /><figcaption>System Arhitecture</figcaption></figure><h3>Elastic APM</h3><p>Elastic APM allows you to monitor applications in real time, collecting detailed performance metrics on response time for incoming requests, database queries, external HTTP requests, etc. Elastic APM has two components:</p><ul><li>APM Server</li><li>APM agents</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zka6U02sFAXhJv2yj5T5VA.png" /><figcaption>Elastic APM</figcaption></figure><p>APM server is an open source application written in GO. Its purpose is to receive data from APM agents, transform it into Elasticsearch documents and send them to Elasticsearch. This is performed using an JSON HTTP API.</p><p>APM Agents instrument your code and collect performance data and errors at runtime. The data is buffered for a short period of time after which it is sent to the APM Server. Agents are written in the same programming language as your application. Elastic provide agents for the following languages:</p><ol><li>Java</li><li>Node Js</li><li>Ruby</li><li>Python</li><li>Go</li></ol><p>The purpose of this article is to monitor Java application, so we will discuss more details about the Java agent. First, it can be used as any other java agent by using -javagent:path/to/agent.jar when you start your jar. Also, you need specify some mandatory parameters such as: apm server url, your service name and java packages to scan, for more details check the <a href="https://www.elastic.co/guide/en/apm/agent/java/current/configuration.html">official documentation</a>.</p><p>The Elastic APM Java agent automatically instruments various APIs, frameworks and application servers, you can check supported technologies <a href="https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html">here</a>. For our demo application, the agent will automatically collect performance data for Spring Web MVC and Spring Data JPA(MySQL).</p><p>If you have technologies that aren’t supported by the agent or you want to collect some custom metrics it can be done using <a href="https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html">agent API</a>. With this api you can programmatically generate performance metrics.</p><h3>Spring Boot Application</h3><p>The Java application which will be monitored is a Spring Boot 2 application. Using Spring Boot we’re going to create a simple REST api for users that are stored in a MYSQL database, the api will provide simple CRUD operations for users data.</p><p>Besides the REST api, the application will have some scheduled backgrounds tasks. These tasks do not have any functionalities, they are built only to show how we can monitor background tasks using APM agent pulbic API.</p><p>REST endpoints</p><ul><li>GET /api/v1/users/{userId} - Returns an user with a specific ID or 404 if no user was found</li><li>POST /api/v1/users - Creates a new user. Request body sample: {&quot;name&quot;:&quot;Cosmin Seceleanu&quot;,&quot;email&quot;:&quot;test@email.com&quot;}</li><li>DELETE /api/v1/users/{userId} - Deletes an user with a specific userid or returns 404 if user does not exists</li></ul><h3>Deploy services</h3><ol><li>git clone <a href="https://github.com/cosminseceleanu/tutorials.git">https://github.com/cosminseceleanu/tutorials.git</a></li><li>cd tutorials/elastic-apm-java</li><li>mvn package - build Spring Boot jar file</li><li>Build and start containers using docker-compose -f docker/docker-compose.yml up -d</li><li>Checking containers status using docker-compose -f docker/docker-compose.yml ps and you should have 5 containers: Elasticsearch, MySQL, Kibana, APM server and the java service</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mMb93XDcjXePQsHE.png" /><figcaption>Docker services</figcaption></figure><p>If APM Server service doesn’t start, it’s because it uses Elasticsearch and Elasticsearch take some time to start. To solve this, just restart some containers using this command: docker-compose -f docker/docker-compose.yml restart apm user-microservice .</p><h4>Spring Boot Service Dockerfile</h4><pre>FROM openjdk:8-jdk</pre><pre>EXPOSE 8080<br>RUN mkdir -p /opt/app<br>WORKDIR /opt/app</pre><pre>ARG JAR_PATH<br>COPY $JAR_PATH /opt/app<br>RUN wget -O apm-agent.jar <a href="https://search.maven.org/remotecontent?filepath=co/elastic/apm/elastic-apm-agent/1.2.0/elastic-apm-agent-1.2.0.jar">https://search.maven.org/remotecontent?filepath=co/elastic/apm/elastic-apm-agent/1.2.0/elastic-apm-agent-1.2.0.jar</a></pre><pre>CMD java -javaagent:/opt/app/apm-agent.jar $JVM_OPTIONS -jar $JAR_NAME</pre><h3>APM Server Dockerfile</h3><pre>FROM docker.elastic.co/apm/apm-server:6.5.4<br>COPY apm-server.yml /usr/share/apm-server/apm-server.yml<br>USER root<br>RUN chown root:apm-server /usr/share/apm-server/apm-server.yml<br>USER apm-server</pre><h3>APM Server Configuration</h3><p>In the APM Server configuration we need to configure the input and the output of the server. For the iniput, we need to specify the host and port where the HTTP API will run, and for the output we set Elasticsearch hosts.</p><p>Also, we will configure APM Server to automatically setup APM indices, dashboards and other things in Kibana, for this we just set Kibana uri and enable the following flag setup.dashboards.enabled.</p><pre>apm-server:<br>  host: &quot;0.0.0.0:8200&quot;<br>  concurrent_requests: 5<br>  rum:<br>    enabled: true</pre><pre>queue.mem.events: 4096<br>max_procs: 4</pre><pre>output.elasticsearch:<br>  hosts: [&quot;http://elasticsearch:9200&quot;]</pre><pre>setup.kibana.host: &quot;kibana:5601&quot;<br>setup.dashboards.enabled: true</pre><pre>logging.level: info<br>logging.to_files: false</pre><h3>Monitor Application</h3><p>What will we monitor?</p><ol><li>Time for incoming http requests</li><li>Throughput</li><li>Time for MySQL queries</li><li>Using APM agent public api we will monitor time for some custom code and a background task</li></ol><p>To have some metrics we need to call our REST service, we can do this using the curl command. If you want to execute a large number of request you can use this tools:</p><ul><li><a href="https://httpd.apache.org/docs/2.4/programs/ab.html">Apache Bench</a></li><li><a href="https://jmeter.apache.org/">Apache JMeter</a></li></ul><p>For the next metrics that I will show you I am going to execute the following curl commands:</p><ul><li>curl -X POST <a href="http://localhost:8080/api/v1/users">http://localhost:8080/api/v1/users</a> -H “Content-Type: application/json” -d ‘{“name”:”Cosmin Seceleanu”,”email”:”<a href="/service/mailto:cosmin.seceleanu@email.com">cosmin.seceleanu@email.com</a>”}’</li><li>curl -X POST <a href="http://localhost:8080/api/v1/users">http://localhost:8080/api/v1/users</a> -H “Content-Type: application/json” -d ‘{“name”:”Foo Bar”,”email”:”<a href="/service/mailto:foo@bar.com">foo@bar.com</a>”}’</li><li>curl -X GET <a href="http://localhost:8080/api/v1/users/1">http://localhost:8080/api/v1/users/1</a></li><li>curl -X GET <a href="http://localhost:8080/api/v1/users/2">http://localhost:8080/api/v1/users/2</a></li><li>curl -X DELETE <a href="http://localhost:8080/api/v1/users/2">http://localhost:8080/api/v1/users/2</a></li><li>curl -X GET <a href="http://localhost:8080/api/v1/users/1">http://localhost:8080/api/v1/users/1</a></li><li>curl -X GET <a href="http://localhost:8080/api/v1/users/1">http://localhost:8080/api/v1/users/1</a></li><li>curl -X GET <a href="http://localhost:8080/api/v1/users/2">http://localhost:8080/api/v1/users/2</a></li></ul><p>After you execute some HTTP requests, you can use Kibana by accessing <a href="http://localhost:5601/">http://localhost:5601</a> and under the APM tab, you should see a list of services(agents) with some summary performance metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*afiiS5rd_6WC-p-9.png" /><figcaption><strong><em>List of APM Agents/Services where every list item contains summary data, such as: average response time, transactions per minute, errors per minute</em></strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A8odSsNAorsMNiFi.png" /><figcaption><strong><em>Overview of transactions for all services</em></strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sUErhrgGdYlR-Yd0.png" /><figcaption><strong><em>Dashboard with metrics about incoming HTTP requests, here we can find transactions for all HTTP endpoints of our REST Api, and for each transaction we can see average response time, request per minute and other metrics.</em></strong></figcaption></figure><blockquote><em>If you want to see more details about a transaction you can click on any transaction, for example if you click on UserController#get transaction you will see details similar with the image below.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FnRydVKdw0ih6tAU.png" /><figcaption><strong>UserController#get Details</strong></figcaption></figure><p>In the above picture we can see that for a GET request, most of the time is spent with otherOperations, this represents a custom method called inside UserService. For this custom metric, I&#39;ve used agent API to measure this method call&#39;s performance, because by default, the APM agent will not measure it. This can be done by adding the annotation @CaptureSpan to the desired method.</p><pre>package com.cosmin.tutorials.apm.service;</pre><pre>import co.elastic.apm.api.CaptureSpan;<br>import com.cosmin.tutorials.apm.database.User;<br>import com.cosmin.tutorials.apm.database.UserRepository;<br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.stereotype.Service;</pre><pre>import java.util.Optional;<br>import java.util.Random;</pre><pre>@Service<br>public class UserService {<br>    private final static Logger logger = LoggerFactory.getLogger(UserService.class);<br>    private UserRepository userRepository;</pre><pre>    @Autowired<br>    public UserService(UserRepository userRepository) {<br>        this.userRepository = userRepository;<br>    }<br></pre><pre>    public User save(User user) {<br>        sleep();<br>        return userRepository.save(user);<br>    }</pre><pre>    public Optional&lt;User&gt; get(Integer id) {<br>        sleep();<br>        return userRepository.findById(id);<br>    }</pre><pre>    public void delete(Integer id) {<br>        sleep();<br>        userRepository.deleteById(id);<br>    }</pre><pre>    @CaptureSpan(&quot;otherOperations&quot;)<br>    private void sleep() {<br>        try {<br>            Random random = new Random();<br>            int milis = random.nextInt(100 - 20 + 1) + 20;<br>            logger.info(String.format(&quot;Sleep ---&gt; %s ms&quot;, milis));<br>            Thread.sleep(milis);<br>        } catch (Exception e) {<br>           logger.error(e.getMessage(), e);<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iB6_S4FtisW7NP3h.png" /><figcaption><strong><em>Details of the otherOperations from UserController#get transaction</em></strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G0K3XmhNv-DHaNOo.png" /><figcaption><strong><em>Details of the UserController#get transaction</em></strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mjjWxkJo2effOeoV.png" /><figcaption><strong><em>Details of the sql query executed during UserController#get transaction</em></strong></figcaption></figure><p>All pictures from above are about incoming HTTP requests, but we also need to monitor background tasks. These tasks are generating metrics that can be found under the Task tab in the top of the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U3RA_IIFSaWs7oYm.png" /><figcaption><strong><em>Dashboard with metrics about transactions with type Task, and for each transaction we can see average response time, request per minute.</em></strong></figcaption></figure><p>The performance metrics about tasks are generated using agent public Api, but this time we need to generate the transaction by using the annotation @CaptureTransaction as you can see in the bellow Java code:</p><pre>package com.cosmin.tutorials.apm.tasks;</pre><pre>import co.elastic.apm.api.CaptureSpan;<br>import co.elastic.apm.api.CaptureTransaction;<br>import com.cosmin.tutorials.apm.database.UserRepository;<br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.scheduling.annotation.Scheduled;<br>import org.springframework.stereotype.Service;</pre><pre>import java.util.Random;</pre><pre>@Service<br>public class PrintUsersTask {</pre><pre>    private final static Logger logger = LoggerFactory.getLogger(PrintUsersTask.class);<br>    private UserRepository userRepository;</pre><pre>    @Autowired<br>    public PrintUsersTask(UserRepository userRepository) {<br>        this.userRepository = userRepository;<br>    }</pre><pre>    @Scheduled(fixedDelayString = &quot;5000&quot;)<br>    public void execute() {<br>        logger.info(&quot;run scheduled test&quot;);<br>        doExecute();<br>    }</pre><pre>    @CaptureTransaction(type = &quot;Task&quot;, value = &quot;PrintUsers&quot;)<br>    private void doExecute() {<br>        userRepository.findAll().forEach(user-&gt; logger.debug(user.getEmail()));<br>        sleep();<br>    }</pre><pre>    @CaptureSpan(&quot;someCustomOperation&quot;)<br>    private void sleep() {<br>        try {<br>            Random random = new Random();<br>            int milis = random.nextInt(120 - 20 + 1) + 20;<br>            Thread.sleep(milis);<br>        } catch (Exception e) {<br>            logger.error(e.getMessage(), e);<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mdl674mAFKYeUINw.png" /><figcaption><strong><em>Details about PrintUser task transaction</em></strong></figcaption></figure><h3>Resources:</h3><ol><li><a href="https://docs.docker.com/">https://docs.docker.com/</a></li><li><a href="https://docs.docker.com/compose/">https://docs.docker.com/compose/</a></li><li><a href="https://www.elastic.co/guide/en/apm/server/current/running-on-docker.html">https://www.elastic.co/guide/en/apm/server/current/running-on-docker.html</a></li><li><a href="https://www.elastic.co/guide/en/apm/agent/java/current/index.html">https://www.elastic.co/guide/en/apm/agent/java/current/index.html</a></li><li><a href="https://www.elastic.co/guide/en/apm/server/current/index.html">https://www.elastic.co/guide/en/apm/server/current/index.html</a></li><li><a href="https://github.com/cosminseceleanu/tutorials">https://github.com/cosminseceleanu/tutorials</a></li><li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html</a></li><li><a href="https://www.elastic.co/guide/en/kibana/current/index.html">https://www.elastic.co/guide/en/kibana/current/index.html</a></li><li><a href="https://github.com/cosminseceleanu/tutorials/blob/master/elastic-apm-java/docs/index.md">https://github.com/cosminseceleanu/tutorials/blob/master/elastic-apm-java/docs/index.md</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d4299cad2be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker logs with Elastic Stack(ELK, Filebeat)]]></title>
            <link>https://medium.com/@sece.cosmin/docker-logs-with-elastic-stack-elk-filebeat-50e2b20a27c6?source=rss-75a2d79e8596------2</link>
            <guid isPermaLink="false">https://medium.com/p/50e2b20a27c6</guid>
            <category><![CDATA[elk]]></category>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kibana]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Cosmin Seceleanu]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 17:48:14 GMT</pubDate>
            <atom:updated>2019-01-07T17:57:59.002Z</atom:updated>
            <content:encoded><![CDATA[<h3>Collect and analyze Docker logs using Filebeat and Elastic Stack(ELK)</h3><p>Docker log messages are a very useful tool for a variety of IT tasks but simply using docker logs command is often not enough. Even with a few containers running is very difficult to find something useful in logs and even harder when you run docker over multiple machines. The best solution is to aggregate the logs from all machines and containers and then you can easily search through them, analyze them or do anything you want with them. One of the most used tool for this kind of problem is Elastic Stack, also known as ELK.</p><p>To complete of this tutorial, I assume you have installed Docker and docker-compose. If you don’t have it already, follow the official instructions. This article assumes that the Docker runs natively and the containers are accessible through localhost.</p><h3>About ELK</h3><p>What is ELK? ELK is an acronym for an amazing and powerful collection of three open source projects developed by Elastic.co: Elasticsearch, Logstash and Kibana.</p><p>ELK or also known as Elastic Stack is a complete end-to-end log analysis solution which helps in deep searching, analyzing and visualizing the log generated from different machines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*Tvmj3XsqH4hJLvXnfm6sZQ.png" /><figcaption>ELK Stack</figcaption></figure><p>Elasticsearch is a distributed search and analytics engine based on the Lucene library. It provides a powerful RESTful JSON-based api, easy to use, scalable and resilient and it stores schema free documents. Elasticsearch is the heart of the ELK stack, it centrally stores your logs.</p><p>Logstash is a server-side data processing pipeline that ingests data from a multitude of sources simultaneously, parse it, transforms it, and then sends it to the Elasticsearch. Logstash has a pluggable framework with a lot of plugins to transform different inputs, to enriched outputs. For example there are plugins for transforming inputs from jdbc, kafka, log4j and other logs.</p><p>Kibana is a flexible visualization tool that consumes data stored in Elasticsearch. Using Kibana you can create line graphs, pie charts, histograms and more. In latests versions of Kibana you can use Vega grammar to build your own visualisations. “A picture’s worth a thousand line of logs”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*MTiIcLGxdCvHjLC_FpLrFQ.jpeg" /><figcaption>Kibana Dashboard Sample</figcaption></figure><h3>Filebeat</h3><p>Filebeat is an open source lightweight shipper for logs written in Go and developed by Elastic.co, same company who developed ELK stack. Filebeat belongs to a bigger project called Beats and his purpose is to send data from hundreds or thousands of machines and systems to Logstash, Kafka, Redis or Elasticsearch. Beats family has shippers for all kind of data, for example:</p><ul><li>Filebeat — File logs</li><li>Metricbeat — Metrics</li><li>Auditbeat — Audit Data</li><li>Packetbat — Network Data</li><li>Heartbeat — Uptime Data</li><li>Winlogbeat — Windows Event Logs</li></ul><p>Filebeat helps you keep the simple things simple by offering a lightweight way to forward and transform log files using some internal modules(Nginx, MySQL, Docker, System).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bd5m-XINOHRKFOjCoCCUHw.png" /><figcaption>Filebeat with ELK</figcaption></figure><h3>Architecture</h3><p>By default standard output(stdout) off all docker containers is written into json files. These log files are stored on the host where the docker engine is running, and can be found under the following path /var/lib/docker/containers/{container-id}/{container-id}-json.log.</p><p>Filebeat will scan files that match the following path /var/lib/docker/containers/*/*-json.log, transform logs and then forwards them out to Logstash. Logstash will filter them, transform them and finally forwards them to the Elasticsearch. Once logs are stored in Elasticsearch, you can use Kibana to build dashboards, to search through logs and all other features supported by Kibana.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*e1Z8NubNOqXXevkdLN9MgA.png" /></figure><h3>ELK and Filebeat dockerfiles and configuration</h3><p>Elastic Stack services and Filebeat will run as docker containers. In this tutorial all containers except Filebeat container will be stateless. The strongest argument in favor of stateless container is that deployment is simple and it follows Java principle of “Build once run anywhere”. If you built a stateless image you don’t need to worry about where to save container state data, or how to make containers interact with persistent storage.</p><h3>Elasticsearch Dockerfile</h3><p>FROM docker.elastic.co/elasticsearch/elasticsearch:6.5.2</p><p>COPY --chown=elasticsearch:elasticsearch elasticsearch.yml /usr/share/elasticsearch/config/</p><p>CMD [&quot;elasticsearch&quot;, &quot;-Elogger.level=INFO&quot;]</p><h3>Logstash Dockerfile</h3><p>FROM docker.elastic.co/logstash/logstash:6.5.2</p><p>RUN rm -f /usr/share/logstash/pipeline/logstash.conf</p><p>COPY pipeline/ /usr/share/logstash/pipeline/</p><h3>Logstash conf</h3><p>input { beats { port =&gt; 5044 host =&gt; &quot;0.0.0.0&quot; } }</p><p>output { elasticsearch { hosts =&gt; elasticsearch manage_template =&gt; false index =&gt; &quot;%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}&quot; } stdout { codec =&gt; rubydebug } }</p><p>The above configuration file tells Logstash to accept input logs from beats on port 5044 and forwards them to the Elasticsearch cluster. Elasticsearch instances can be found in cluster with hosts named “elasticsearch”. In Elasticsearch logs are stored in indexes with the following name pattern beat-{beat version}-{YYYY.MM.dd}</p><h3>Filebeat Dockerfile</h3><p>FROM docker.elastic.co/beats/filebeat:6.5.2</p><p># Copy our custom configuration file COPY filebeat.yml /usr/share/filebeat/filebeat.yml</p><p>USER root</p><p># Create a directory to map volume with all docker log files RUN mkdir /usr/share/filebeat/dockerlogs</p><p>RUN chown -R root /usr/share/filebeat/</p><p>RUN chmod -R go-w /usr/share/filebeat/</p><p>The Filebeat configuration file, same as the Logstash configuration, needs an input and an output. This time, the input is a path where docker log files are stored and the output is Logstash.</p><p>Filebeat is also configured to transform files such that keys and nested keys from json logs are stored as fields in Elasticsearch. In this way we can query them, make dashboards and so on. Another interesting thing that Filebeat can do is adding some docker metadata to each log, this metadata can be: docker image, service name from docker compose, container id and more.</p><p>filebeat.inputs: - type: docker combine_partial: true containers: path: &quot;/usr/share/dockerlogs/data&quot; stream: &quot;stdout&quot; ids: - &quot;*&quot; exclude_files: [&#39;\.gz$\&#39;] ignore_older: 10m</p><p>processors: #decode the log field (sub JSON document) if JSON encoded, then maps it&#39;s fields to elasticsearch fields-decode_json_fields: fields: [&quot;log&quot;, &quot;message&quot;] target: &quot;&quot;#overwrite existing target elasticsearch fields while decoding json fields overwrite_keys: true- add_docker_metadata: host: &quot;unix:///var/run/docker.sock&quot;</p><p># setup filebeat to send output to logstash output.logstash: hosts: [&quot;logstash&quot;]</p><h3>Deploy containers</h3><ol><li>git clone <a href="https://github.com/cosminseceleanu/tutorials.git">https://github.com/cosminseceleanu/tutorials.git</a></li><li>cd tutorials/docker-logs-elk</li><li>Build and start containers using docker-compose -f docker-compose.yml up -d</li><li>Checking containers status using docker-compose -f docker-compose.yml ps and you should have 5 containers</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_vNVUWpayZSYoY2PAWTjw.png" /><figcaption>docker compose status</figcaption></figure><p>The container named ‘app’ is a simple bash script that prints the following json {“app”: “dummy”, “foo”: “bar”} message every two seconds. This message will be transformed so that in Elasticsearch, json keys “app” and “foo” will be fields in index and we can use them.</p><p>Using Kibana, which can be used accessed <a href="http://localhost:5601/">http://localhost:5601</a>, under Discover tab write in the search box “foo:bar” and then press enter. You should see messages printed from docker container like in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KsthJfPXBxvULm1e1PQ4g.png" /><figcaption>Log messages in Kibana</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JAq95UAcg1gWsqi4ISFjjw.png" /><figcaption>Docker and Filebeat metadata</figcaption></figure><p>Besides the log message printed from our dummy app, the log message is enriched with metadata from Filebeat like: beat.hostname, beat.name, bean.version and more. Same as Filebeat’s metadata the log will have some docker metadata. This metadata can be used to search logs. For example, you can search using docker compose service docker.container.labels.com.docker.compose.service: app or you can search by docker image name docker.container.image: dummy.</p><h3>Resources:</h3><ol><li><a href="https://docs.docker.com/">https://docs.docker.com/</a></li><li><a href="https://www.elastic.co/guide/en/beats/filebeat/current/index.html">https://www.elastic.co/guide/en/beats/filebeat/current/index.html</a></li><li><a href="https://www.elastic.co/guide/en/kibana/current/index.html">https://www.elastic.co/guide/en/kibana/current/index.html</a></li><li><a href="https://www.elastic.co/guide/en/logstash/current/index.html">https://www.elastic.co/guide/en/logstash/current/index.html</a></li><li><a href="https://docs.docker.com/compose/">https://docs.docker.com/compose/</a></li><li>Github: <a href="https://github.com/cosminseceleanu/tutorials/tree/master/docker-logs-elk">https://github.com/cosminseceleanu/tutorials/tree/master/docker-logs-elk</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50e2b20a27c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>