tencent cloud

Feedback

Automatic Connecting Java Application for the TKE Environment (Recommended)

Last updated: 2024-06-19 16:31:30
    For Java Applications deployed on TKE, APM offers an automatic connection scheme, enabling agent automatic injection after the application is deployed to TKE, facilitating quick connecting.
    Java applications that are automatically connected in the TKE environment will be automatically injected with the Tencent Cloud OpenTelemetry Java Agent Enhanced Edition (TencentCloud-OTel Java Agent). The Tencent Cloud OpenTelemetry Java Agent Enhanced Edition is based on the secondary development of OpenTelemetry-java-instrumentation from the open-source community, adhering to the Apache License 2.0 protocol. The OpenTelemetry License is cited within the agent packet. Building upon the open-source agent, the Tencent Cloud OpenTelemetry Java Agent Enhanced Edition has improved significantly in Event Tracking density, advanced diagnosis, performance protection, and enterprise-level capabilities.

    Prerequisites

    See Supported Java Versions and Frameworks by the OTel Java Agent Enhanced Edition to ensure that the Java version and application server are within the supported range by the agent. For the dependency libraries and frameworks supported by automatic tracing, data reporting can be completed upon successful connection without modifying the code. In addition, the Tencent Cloud OpenTelemetry Java Agent Enhanced Edition adheres to the OpenTelemetry protocol standard. if automatic Event Tracking does not meet your scenario, or you need to add business layer Event Tracking, use OpenTelemetry API for Custom Metrics Definition.

    Step 1: Install Operator.

    Install Operator in the TKE cluster, it's recommended to install Operator with one click on the APM console, for details see installing tencent-opentelemetry-operator.

    Step 2: Add annotation to workload.

    1. Log in to TKE console.
    2. Click Cluster to enter the corresponding TKE cluster.
    3. In Workload, you can find the application that needs to connect APM, click More, then click Edit YAML.
    4. Apply the following content in the Pod annotation, then click Complete to finish the connection.
    cloud.tencent.com/inject-java: "true"
    cloud.tencent.com/otel-service-name: my-app # Application name. Processes of connecting with the same application name are displayed as multiple instances under the same application in APM.
    # The application name can be up to 63 characters and can only contain lowercase letters, digits, and the separator (-), and it must start with a lowercase letter and end with a digit or lowercase letter.
    Note that this content needs to be added to spec.template.metadata.annotations, affecting the Pod's annotation, not the workload's annotation. You can see the following code snippet:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    labels:
    k8s-app: my-app
    name: my-app
    namespace: default
    spec:
    selector:
    matchLabels:
    k8s-app: my-app
    template:
    metadata:
    labels:
    k8s-app: my-app
    annotations:
    cloud.tencent.com/inject-java: "true" # Add it here.
    cloud.tencent.com/otel-service-name: my-app
    spec:
    containers:
    image: my-app:0.1
    name: my-app

    Connection Verification

    After annotations are added to the workload, based on different publish policies, you can trigger a restart of the application pod. The newly launched pod will automatically inject the agent and connect to the APM server to report monitoring data, with the reported business system being the default business system of the Operator. In normal traffic cases, the connected application will displayed in APM > Application monitoring > Application list and the connected application instances will be displayed in APM > Application Monitoring > App details > Instance monitoring. Since there is a certain latency in the processing of observable data, if the application or instance does not appear in the console after connecting, wait for about 30 seconds.

    Custom Event Tracking

    When automatic instrumentation does not meet your scenario, or you need to add business layer instrumentation, see Custom Event Tracking and use the OpenTelemetry API to add custom instrumentation.

    More Connection Configuration Items (Optional)

    At the Workload level, you can add more annotations to adjust the connect behaviors:
    Configuration Item
    Description
    cloud.tencent.com/apm-token
    Specify the Token for the APM business system. If this configuration item is not added, the Operator's configuration is used (corresponding to the Operator's env.APM_TOKEN field).
    cloud.tencent.com/java-instr-version
    Specify the Java agent version. If this configuration item is not added, the configuration of the Operator is used (corresponding to the Operator's env.JAVA_INSTR_VERSION field). The value can be latest (default) or a specific version number. For a list of specific version numbers, see Agent Version Information. It is not recommended to fill in this field unless necessary.
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support