MyObservability

Library / code based Instrumentation

Mixed mode (Automatic & Manual Instrumentation)

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: Through Annotation method for Java Application

  1. Add dependency

Ex:

io.opentelemetry.instrumentation opentelemetry-instrumentation-annotations 2.4.0
  1. Import OpenTelemetry annotation libraries
import io.opentelemetry.instrumentation.annotations.SpanAttribute;
import io.opentelemetry.instrumentation.annotations.WithSpan;
  1. Add @WithSpan annotation on the top oif method

  2. If you want to collect attributes from the method.

(Optional)

@WithSpan String

method(@SpanAttribute String name)
  1. Download the agent JAR file

  2. Export Environment variable & run the newly built JAR including the agent.

Ex: java -javaagent:opentelemetry-javaagent.jar -jar myapp.jar


Main Page: Click Here