Contact Us
×
How you can contact us:

Autoinstrumentation for Java


Maven Setup

Include the dependency in your pom.xml:

<properties>
<opentelemetry-javaagent.version>1.23.0</opentelemetry-javaagent.version>
<otel-agent-ext-java.version>1.3.1</otel-agent-ext-java.version>
</properties>
<dependencies>
<dependency>
<groupId>io.opentelemetry.javaagent</groupId>
<artifactId>opentelemetry-javaagent</artifactId>
<version>${opentelemetry-javaagent.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sap.xdsr</groupId>
<artifactId>otel-agent-ext-java</artifactId>
<version>${otel-agent-ext-java.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>


Add the following Java VM parameters via the mta.yaml:

mta.yaml

JBP_CONFIG_JAVA_OPTS: "[java_opts: '-javaagent:BOOT-INF/lib/opentelemetry-javaagent-1.23.0.jar -Dotel.javaagent.enabled=true -Dotel.resource.attributes=account=<subaccount name>,sap.calm.tenantId=<subaccount id>,calmTenantId=<subaccount id>,otel.poll.service.type=SAP_CP_CF,otel.poll.every.second=60 -Dotel.service.name=MyService -Dotel.propagators=sapuniversal -Dotel.traces.exporter=none -Dotel.metrics.exporter=none -Dotel.javaagent.extensions=BOOT-INF/lib/otel-agent-ext-java-1.3.1.jar']"

Where the parameters have to be replaced by:

  • <subaccount name>: Name of the subaccount, where the instrumented application is running.
  • <subaccount id>: Technical ID of the subaccount, where the instrumented application is running. The technical ID can be found in the SAP BTP cockpit and has the form of a guid: 12345678-1234-1234-1234-123456789abc
    and will be used by SAP Cloud ALM to map the data to the corresponding cloud service.
     

Destination Configuration

In order to export towards SAP Cloud ALM you have to setup the destination via OAuth based authentication.

  • Bind to Destination Service
  • Add the below lines to mta.yaml

mta.yaml

modules:
- name: <your application srv module>
requires:
- name: <destination-service-name>
resources:
- name: <destination-service-name>
parameters:
service-plan: lite
service: destination
type: org.cloudfoundry.managed-service

  • Create a destination configuration using Destination Service for persisting the baseUrl and retrieving it.
  • The Destination endpoint should be your SAP Cloud ALM endpoint API url. How to retrieve this, can be found here.
  • The Destination name should be in the format CALM_datacollector_<space-name>.
    • The <space-name> is the space where the microservice has to be deployed.
    • Example: If the application is in space "xyz", the destination configuration name can be CALM_datacollector_xyz
  • As Proxy Type use Internet
  • As Authentication Type use OAuth2ClientCredentials
  • Enter the client ID/secret and token URL. How to retrieve these can be found here.

The destination should look like this: