Skip to content

logicmonitor/lm-telemetry-sdk-java

Repository files navigation

LM Telemetry SDK Java

Java CI with Gradle codecov

LM Telemetry SDK java is a wrapper around OpenTelemetry SDK. If you are using LM Telemetry SDK in the application then no need to add OpenTelemetry SDK dependency as it is fetched transitively. This SDK currently detects Resources on the platforms like

  • AWS Elastic Compute Cloud
  • AWS Lambda
  • Azure VM
  • Google Cloud Compute Engine (GCE)

Getting Started

Auto Instrumentation

Check latest agent version

For java Auto instrumentation Logicmonitor provides lm-agent which have all Opentelemetry provided instrumentation support.

Auto Instrument your app

java -javaagent:/path/lm-telemetry-agent-<version>-alpha.jar \
-Dotel.exporter=otlp \
-Dotel.resource.attributes=service.namespace=<service-namespace>,service.name=<service-name> \
-Dotel.exporter.otlp.endpoint=http://localhost:4317 \
-Dotel.exporter.otlp.insecure=true \
-jar <your-app-jar>

By default, the lm-telemetry Java agent uses OTLP exporter configured to send data to lm-otel collector at http://localhost:4317.

Manual Instrumentation

Check Github Package

Gradle

dependencies {
    implementation ('com.logicmonitor:lm-telemetry-sdk:0.0.1-alpha')
}

Maven

<dependency>
        <groupId>com.logicmonitor</groupId>
        <artifactId>lm-telemetry-sdk</artifactId>
        <version>0.0.1-alpha</version>
</dependency>
Using LMResourceDetector to detect resource
Resource serviceResource = LMResourceDetector.detect();

//Create Span Exporter
OtlpGrpcSpanExporter spanExporter = OtlpGrpcSpanExporter.builder()
.setEndpoint("http://localhost:4317")
.build();

//Create SdkTracerProvider
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(spanExporter)
.setScheduleDelay(100, TimeUnit.MILLISECONDS).build())
.setResource(serviceResource)
.build();

You can also use environment variable or system properties listed on OpenTelemetry Document to provide resource information.

System property Environment variable Description
otel.resource.attributes OTEL_RESOURCE_ATTRIBUTES Specify resource attributes in the following format: key1=val1,key2=val2,key3=val3
otel.service.name OTEL_SERVICE_NAME Specify logical service name. Takes precedence over service.name defined with otel.resource.attributes

For Manual Instrumentation refer Example

OpenTelemetry Component Dependency

List of OpenTelemetry Component Dependencies

Component Version
Trace API v1.20.1
Trace SDK v1.20.1
OpenTelemetry SDK Autoconfigure v1.20.1-alpha
OpenTelemetry AWS Utils v1.20.1
OpenTelemetry Semantic Conventions v1.20.1
OpenTelemetry Resource Providers v1.20.1