Jump to content
We've recently updated our Privacy Statement, available here ×
  • Extending OpenTelemetry feature in JasperReports Server application by Adding Custom Annotations


    Henna Katy
    • Edited on:
    • Features: JasperReports Server Version: v9.0.0 Product: JasperReports® Server

    Annotations Overview

    The span names and properties can be modified for better visibility on Jaeger. You can create an annotation by adding @WithSpan to the method. This creates a span for a method for which it is annotated with. These annotated method names appear under the Operations field in Jaeger UI.
    The following figure shows the @WithSpan annotation for one of the methods involved in the process of Scheduling.

    image.thumb.png.3c73e162dc354886f532c181d11f5b5d.png

    Adding Annotations

    Use cases for Adding Annotation

    You can add annotations in the method of the code to investigate the performance issues of JasperReports Server application during execution of the report. The performance of an application can be slow due to various reasons, for example, if a report is taking longer than usual to execute, in such cases adding annotations helps to break down the request time by detecting slow queries and capturing the exact places (spans) and the time spent in each major code area. 

    For more information about various scenarios where adding annotations helped to improve the performance of JasperReports Server application, see  https://community.jaspersoft.com/knowledgebase/how-to/how-to-investigate-the-performance-issues-of-scheduler-and-input-controls-in-the-jasperreports-server-r4635/

    Adding @WithSpan and Creating Custom Spans

     Adding @WithSpan

    1. Add the OpenTelemetry library in the following pom.xml of the corresponding java module in which the class resides.

    <dependency>
       <groupId>io.opentelemetry</groupId>
       <artifactId>opentelemetry-extension-annotations</artifactId>
    </dependency>

    2. Import import io.opentelemetry.extension.annotations.WithSpan;

    3. After importing add @WithSpan to the required method.

    Creating Custom Spans

    1. Add the following dependency in the pom.xml for creating a span using the Span class:

    <dependency>
      <groupId>io.opentelemetry</groupId>
      <artifactId>opentelemetry-api</artifactId>
      <version>1.16.0</version>
    </dependency>

    2. Import import io.opentelemetry.api.trace.Span;

    Methods for Adding Annotations

    The following are the main methods for adding annotations in the code. You need to set the following span names and properties for instrumenting the code:

    • span = Span.current()
    • span.updateName()
    • span.setAttribute() 

    For more information, refer to OpenTelemetry javadoc https://javadoc.io/doc/io.opentelemetry/opentelemetry-api-trace/latest/io/opentelemetry/api/trace/Span.html.

    • Like 2

    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...