All Products
Search
Document Center

Managed Service for OpenTelemetry:OpenTelemetry integration

Dernière mise à jour :Aug 27, 2026

can receive trace, metric, and log data from your applications. It supports two reporting methods: direct reporting, and forwarding through an OpenTelemetry Collector.

Choose a reporting method

You can report telemetry data directly to Managed Service for OpenTelemetry, or forward it through an OpenTelemetry Collector. Choose a method based on the type of telemetry data that you want to report.

Reporting methodSupported data types
Direct reportingTraces and metrics
OpenTelemetry Collector (Core)Traces and metrics
OpenTelemetry Collector (Contrib)Traces, metrics, and logs

Log data is forwarded through an OpenTelemetry Collector (Contrib) to Simple Log Service (SLS). If you want to report log data, use the Collector forwarding method with the Contrib edition.

If you forward data through an OpenTelemetry Collector, choose a deployment option. The OpenTelemetry Collector is available in two editions:

  • OpenTelemetry Collector (Core): supports reporting trace and metric data.

  • OpenTelemetry Collector (Contrib): supports reporting trace, metric, and log data.

    The following table compares the deployment options described in this topic.
Deployment optionSupported editionSupported data types
Deploy to an ACK cluster from the ACK MarketplaceOpenTelemetry Collector (Core)Traces and metrics
Deploy with DockerOpenTelemetry Collector (Core) and OpenTelemetry Collector (Contrib)Traces and metrics (Core). Traces, metrics, and logs (Contrib).
Other installation and deployment methodsSee Other installation and deployment methods.Varies by method

Before you begin

Use caseVariableDescriptionExample
Report trace and metric data over gRPC${GRPC_ENDPOINT}The gRPC endpoint of Managed Service for OpenTelemetry, which supports reporting trace and metric data. If your service runs on Alibaba Cloud in the same region as the endpoint region you select, use the Alibaba Cloud internal endpoint. Otherwise, use the public endpoint.
  • Internal endpoint: http://tracing-analysis-dc-hz-internal.aliyuncs.com:8090

  • Public endpoint: http://tracing-analysis-dc-hz.aliyuncs.com:8090

Report trace and metric data over gRPC${GRPC_AUTHENTICATION_TOKEN}The authentication token required to report data over gRPC to Managed Service for OpenTelemetry. For information about how to obtain the token, see Get started with Managed Service for OpenTelemetry.abcdef1234@abcdef****56789_abcdef1234@abcdef****56789
Report trace and metric data over HTTP${HTTP_TRACES_ENDPOINT}The HTTP endpoint of Managed Service for OpenTelemetry, which supports reporting trace data. If your service runs on Alibaba Cloud in the same region as the endpoint region you select, use the Alibaba Cloud internal endpoint. Otherwise, use the public endpoint.
  • Internal endpoint: http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/traces
    - Public endpoint: http://tracing-analysis-dc-hz.aliyuncs.com/adapt_***_***/api/otlp/traces

Report trace and metric data over HTTP${HTTP_METRICS_ENDPOINT}The HTTP endpoint of Managed Service for OpenTelemetry, which supports reporting metric data. If your service runs on Alibaba Cloud in the same region as the endpoint region you select, use the Alibaba Cloud internal endpoint. Otherwise, use the public endpoint.
  • Internal endpoint: http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/metrics
    - Public endpoint: http://tracing-analysis-dc-hz.aliyuncs.com/adapt_***_***/api/otlp/metrics

Report log data${SLS_ENDPOINT}The endpoint of the SLS Project. Required only when you report log data. For the steps to obtain the endpoint, see Endpoint.test-project.cn-hangzhou.log.aliyuncs.com
Report log data${SLS_PROJECT}The name of the SLS Project. Required only when you report log data.test-project
Report log data${SLS_LOGSTORE}The name of the SLS Logstore. Required only when you report log data.test-logstore
Report log data${ALIYUN_ACCESS_KEY_ID}The AccessKey ID of your Alibaba Cloud account. Required only when you report log data. We recommend that you use the AccessKey pair, which consists of an AccessKey ID and an AccessKey secret, of a Resource Access Management (RAM) user that has write permissions only on the SLS Project. For information about how to grant a RAM user permissions to write data to a specific Project, see RAM custom policy examples. For information about how to obtain an AccessKey pair, see AccessKey pair.N/A
Report log data${ALIYUN_ACCESS_KEY_SECRET}The AccessKey secret of your Alibaba Cloud account. Required only when you report log data. We recommend that you use the AccessKey pair of a RAM user that has write permissions only on the SLS Project.N/A

Direct reporting

Configure the reporting endpoint and the authentication information in the OpenTelemetry Agent or SDK to send the trace and metric data that OpenTelemetry collects directly to the Managed Service for OpenTelemetry server.

Option 1: Configure the reporting settings in code (Java example)

The following Java code examples show how to configure the endpoints of Managed Service for OpenTelemetry, which supports reporting over HTTP or gRPC. To view the complete integration code and demos, visit the Integration Center or see Report trace data from Java applications by using OpenTelemetry.

HTTP reporting

...

// Report trace data
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
        .addSpanProcessor(BatchSpanProcessor.builder(OtlpHttpSpanExporter.builder()
                .setEndpoint("${HTTP_TRACES_ENDPOINT}") // Set the HTTP traces endpoint to report trace data to Managed Service for OpenTelemetry.
                .build()).build())
        .build();

// Report metric data
SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder()
    .registerMetricReader(PeriodicMetricReader.builder(OtlpHttpMetricExporter.builder()
        .setEndpoint("${HTTP_METRICS_ENDPOINT}")  // Set the HTTP metrics endpoint to report metric data to Managed Service for OpenTelemetry.
        .build()).build())
    .build();

...

gRPC reporting

...

// Report trace data
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
        .addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder()
                .setEndpoint("${GRPC_ENDPOINT}") // Set the gRPC endpoint to report trace data to Managed Service for OpenTelemetry.
                .addHeader("Authentication","${GRPC_AUTHENTICATION_TOKEN}") // Set the authentication token of Managed Service for OpenTelemetry.
                .build()).build())
        .setResource(resource)
        .build();

// Report metric data
SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder()
    .registerMetricReader(PeriodicMetricReader.builder(OtlpGrpcMetricExporter.builder()
        .setEndpoint("${GRPC_ENDPOINT}")  // Set the gRPC endpoint to report metric data to Managed Service for OpenTelemetry.
        .addHeader("Authentication", "${GRPC_AUTHENTICATION_TOKEN}")  // Set the authentication token of Managed Service for OpenTelemetry.
        .build()).build())
    .setResource(resource)
    .build();

...

Option 2: Configure the reporting settings with environment variables

OpenTelemetry also supports configuring the data reporting endpoint with environment variables. The following table lists the environment variables required to report data to Managed Service for OpenTelemetry. For more OpenTelemetry OTLP environment variables, see OTLP Exporter Configuration.

Environment variableDescriptionExample
OTEL_SERVICE_NAMEThe application name.export OTEL_SERVICE_NAME=opentelemetry-demo-service
OTEL_EXPORTER_OTLP_PROTOCOLThe reporting protocol. Traces support grpc, http/protobuf, and http/json. Metrics support grpc and http/protobuf. If you select a gRPC endpoint, set this variable to grpc. Otherwise, use http/protobuf or http/json.export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTThe traces reporting endpoint. Both HTTP and gRPC endpoints are supported. Use the ${GRPC_ENDPOINT} or ${HTTP_TRACES_ENDPOINT} value that you obtained in .
  • Report over HTTP: export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/traces

  • Report over gRPC: export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com:8090

OTEL_EXPORTER_OTLP_METRICS_ENDPOINTThe metrics reporting endpoint. Both HTTP and gRPC endpoints are supported. Use the ${GRPC_ENDPOINT} or ${HTTP_METRICS_ENDPOINT} value that you obtained in .
  • Report over HTTP: export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/metrics

  • Report over gRPC: export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com:8090

OTEL_EXPORTER_OTLP_HEADERSThe request header for gRPC reporting, which is mainly used for authentication. Use the format Authentication=${GRPC_AUTHENTICATION_TOKEN}, where ${GRPC_AUTHENTICATION_TOKEN} is the authentication token that you obtained in .export OTEL_EXPORTER_OTLP_HEADERS=Authentication=abcdef1234@abcdef****56789_abcdef1234@abcdef****56789

Forwarding data through an OpenTelemetry Collector

An OpenTelemetry Collector receives trace, metric, and log data from your applications and forwards the data to Managed Service for OpenTelemetry based on its exporter configuration.

Option 1: Deploy to an ACK cluster from the ACK Marketplace

In this option, you deploy the collector to a Container Service for Kubernetes (ACK) cluster from the ACK Marketplace. The ACK Marketplace currently provides only the OpenTelemetry Collector (Core) edition, not the Contrib edition. To collect log data, use one of the other deployment methods.

Step 1: Deploy the collector

  1. Log on to the ACK console. In the left navigation pane, click Marketplace > Marketplace.

  2. In the Marketplace, search for and click opentelemetry-collector, and then click Deploy in the upper-right corner of the page.

  3. On the Create page, select the cluster and the namespace in which you want to deploy opentelemetry-collector. The default namespace is otel-collector. Then, click Next.

  4. On the Parameter Configurations page, set the mode parameter to deployment or daemonset, and then click OK.

Step 2: Configure the collector parameters

  1. On the Clusters page, click the target cluster.

  2. In the left-side navigation pane, choose Configuration Management > Configuration Item.

  3. Select the namespace in which opentelemetry-collector is deployed. The default namespace is otel-collector.

  4. On the Configuration Item page, find opentelemetry-collector, and then click YAML.

  5. Configure the exporters, processors, receivers, and service sections based on the following YAML content, and then click OK.

    opentelemetry-collector configuration item (gRPC reporting)

    exporters:
      otlp:
        endpoint: "${GRPC_ENDPOINT}"
        headers:
          Authentication: "${GRPC_AUTHENTICATION_TOKEN}"
        tls:
          insecure: true
    
    processors:
      batch: {}
      memory_limiter:
        check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
        limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
        spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.
    
    receivers:
      otlp:
        protocols:
          grpc:
            endpoint: ${env:MY_POD_IP}:4317
          http:
            endpoint: ${env:MY_POD_IP}:4318
    
    service:
      pipelines:
        traces:
          exporters: [otlp]
          processors: [memory_limiter, batch]
          receivers: [otlp]
        metrics:
          exporters: [otlp]
          processors: [memory_limiter, batch]
          receivers: [otlp]

    opentelemetry-collector configuration item (HTTP reporting)

    exporters:
      otlphttp:
        traces_endpoint: "${HTTP_TRACES_ENDPOINT}"
        metrics_endpoint: "${HTTP_METRICS_ENDPOINT}"
        tls:
          insecure: true
        timeout: 5s # The timeout period. The default value is 5s. Change the value as needed.
    
    processors:
      batch: {}
      memory_limiter:
        check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
        limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
        spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.
    
    receivers:
      otlp:
        protocols:
          grpc:
            endpoint: ${env:MY_POD_IP}:4317
          http:
            endpoint: ${env:MY_POD_IP}:4318
    
    service:
      pipelines:
        traces:
          exporters: [otlphttp]
          processors: [memory_limiter, batch]
          receivers: [otlp]
        metrics:
          exporters: [otlphttp]
          processors: [memory_limiter, batch]
          receivers: [otlp]
  6. After the configuration is complete, manually restart opentelemetry-collector.

Option 2: Deploy with Docker

In this option, you run the collector as a Docker container. Both the Core and Contrib editions are available.

Step 1: Pull the image

opentelemetry-collector

To specify an image version, visit https://hub.docker.com/r/otel/opentelemetry-collector/tags.

docker pull otel/opentelemetry-collector:latest

opentelemetry-collector-contrib

To specify an image version, visit https://hub.docker.com/r/otel/opentelemetry-collector-contrib/tags.

docker pull otel/opentelemetry-collector-contrib:latest

Step 2: Prepare the configuration file

Create a config.yaml file and configure the related parameters. In the following examples, placeholders in the ${VAR} format must be replaced with the values that you prepared in Before you begin. These placeholders are different from the Collector-native ${env:...} expansion syntax, such as ${env:MY_POD_IP}, which the Collector resolves from environment variables at runtime.

opentelemetry-collector configuration item (gRPC reporting)

# config.yaml
exporters:
  otlp:
    endpoint: "${GRPC_ENDPOINT}"
    headers:
      Authentication: "${GRPC_AUTHENTICATION_TOKEN}"
    tls:
      insecure: true

processors:
  batch: {}
  memory_limiter:
    check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
    limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
    spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
      http:
        endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.

service:
  pipelines:
    traces:
      exporters: [otlp]
      processors: [memory_limiter, batch]
      receivers: [otlp]
    metrics:
      exporters: [otlp]
      processors: [memory_limiter, batch]
      receivers: [otlp]

opentelemetry-collector configuration item (HTTP reporting)

# config.yaml
exporters:
  otlphttp:
    traces_endpoint: "${HTTP_TRACES_ENDPOINT}"
    metrics_endpoint: "${HTTP_METRICS_ENDPOINT}"
    tls:
      insecure: true
    timeout: 5s # The timeout period. The default value is 5s. Change the value as needed.

processors:
  batch: {}
  memory_limiter:
    check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
    limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
    spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
      http:
        endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.

service:
  pipelines:
    traces:
      exporters: [otlphttp]
      processors: [memory_limiter, batch]
      receivers: [otlp]
    metrics:
      exporters: [otlphttp]
      processors: [memory_limiter, batch]
      receivers: [otlp]

opentelemetry-collector-contrib configuration item (gRPC reporting)

# config.yaml
exporters:
  otlp:
    endpoint: "${GRPC_ENDPOINT}"
    headers:
      Authentication: "${GRPC_AUTHENTICATION_TOKEN}"
    tls:
      insecure: true
  # Log exporter configuration (optional)
  alibabacloud_logservice/logs:
    endpoint: "${SLS_ENDPOINT}"
    project: "${SLS_PROJECT}"
    logstore: "${SLS_LOGSTORE}"
    access_key_id: "${ALIYUN_ACCESS_KEY_ID}"
    access_key_secret: "${ALIYUN_ACCESS_KEY_SECRET}"

processors:
  batch: {}
  memory_limiter:
    check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
    limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
    spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
      http:
        endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.

service:
  pipelines:
    traces:
      exporters: [otlp]
      processors: [memory_limiter, batch]
      receivers: [otlp]
    metrics:
      exporters: [otlp]
      processors: [memory_limiter, batch]
      receivers: [otlp]
    # Log data processing pipeline (optional)
    logs:
      exporters: [alibabacloud_logservice/logs]
      processors: [memory_limiter, batch]
      receivers: [otlp]

opentelemetry-collector-contrib configuration item (HTTP reporting)

# config.yaml
exporters:
  otlphttp:
    traces_endpoint: "${HTTP_TRACES_ENDPOINT}"
    metrics_endpoint: "${HTTP_METRICS_ENDPOINT}"
    tls:
      insecure: true
    timeout: 5s # The timeout period. The default value is 5s. Change the value as needed.

  # Log exporter configuration (optional)
  alibabacloud_logservice/logs:
    endpoint: "${SLS_ENDPOINT}"
    project: "${SLS_PROJECT}"
    logstore: "${SLS_LOGSTORE}"
    access_key_id: "${ALIYUN_ACCESS_KEY_ID}"
    access_key_secret: "${ALIYUN_ACCESS_KEY_SECRET}"

processors:
  batch: {}
  memory_limiter:
    check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
    limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
    spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
      http:
        endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.

service:
  pipelines:
    traces:
      exporters: [otlphttp]
      processors: [memory_limiter, batch]
      receivers: [otlp]
    metrics:
      exporters: [otlphttp]
      processors: [memory_limiter, batch]
      receivers: [otlp]
    # Log data processing pipeline (optional)
    logs:
      exporters: [alibabacloud_logservice/logs]
      processors: [memory_limiter, batch]
      receivers: [otlp]

Step 3: Mount the custom configuration file and run the collector

The -p flags publish the receiver ports so that your applications can send data to the collector. Adjust the port mapping to match the receiver endpoints in your configuration file.

opentelemetry-collector

docker run -p 4317:4317 -p 4318:4318 -v $(pwd)/config.yaml:/etc/otelcol/config.yaml otel/opentelemetry-collector:latest

opentelemetry-collector-contrib

docker run -p 4317:4317 -p 4318:4318 -v $(pwd)/config.yaml:/etc/otelcol-contrib/config.yaml otel/opentelemetry-collector-contrib:latest

For other deployment methods, see Other installation and deployment methods.

References