Using generic set of instrumentation libraries helpful as there is no modification / rebuilding of the application is necessary.
Developers often encapsulate related logic in dedicated functions to improve code maintainability and organization. OpenTelemetry agent may lack awareness of these custom functions. It has no way of knowing whether they are important and what telemetry data to capture from them.
To apply a more granular configuration to the already existing agent you can use the opentelemetry-instrumentation-annotations library.
Or use the annotations library is by configuring it through environment variables.
Ex:
import io.opentelemetry.instrumentation.annotations.SpanAttribute;
import io.opentelemetry.instrumentation.annotations.WithSpan;
Add @WithSpan annotation on the top oif method
If you want to collect attributes from the method.
(Optional)
@WithSpan String
method(@SpanAttribute String name)
Download the agent JAR file
Export Environment variable & run the newly built JAR including the agent.
Ex: java -javaagent:opentelemetry-javaagent.jar -jar myapp.jar
Main Page: Click Here