OpenTelemetry related service mappings and infrastructure correlation

This topic provides guidance for customers who manually send OpenTelemetry data to Instana.

If you are using the Instana Distribution of OpenTelemetry Collector (IDOT), you do not need to follow the manual configuration because IDOT automatically handles service mappings and infrastructure correlation by default.

You can follow the information in this document to integrate OpenTelemetry with Instana and enable comprehensive service mappings and infrastructure correlation when you send telemetry data manually. This document explains how to use specific OpenTelemetry resource attributes for optimal data linking and visibility within Instana, particularly in Kubernetes environments and IBM middleware.

OpenTelemetry service mapping

Instana aligns with OpenTelemetry Semantic Conventions to map metrics, spans, and logs to services. These conventions establish standardized attribute names and usage patterns, promoting consistency and interoperability across observability tools. By aligning to these standards, Instana make sure the seamless integration of telemetry data into its monitoring and observability platform.

The following are the key attributes that are used in service mapping:

  • Resource attribute service.name
  • Trace span attribute peer.service

Resource attribute service.name

The service.name attribute uniquely identifies a service in OpenTelemetry. Each application, microservice, or component have a unique and logical service.name to enable effective filtering, analysis, and visualization of telemetry data. Instana maps service.name to its services, linking traces, metrics, and logs to the emitting application. Consistent and descriptive naming of service.name helps ensure accurate grouping and improved observability within Instana.

In OpenTelemetry, you can set the service.name attribute at different levels of your application, depending on the specific needs of your observability setup. In the following table, you can see the different ways in which service.name can be set:

Level Definition Method Example Use Case
Application Code Directly in the application during manual instrumentation service.name="orders-service" When the service.name is hardcoded or configured in the application itself
Environment Variable By using the OTEL_SERVICE_NAME environment variable OTEL_SERVICE_NAME=payments-service Common for environments that use auto-instrumentation across multiple services
Resource Attributes By using OTEL_RESOURCE_ATTRIBUTES with key-value pairs OTEL_RESOURCE_ATTRIBUTES=service.name=inventory-service Useful for combining service.name with other attributes like host.id
Collector Configuration In OpenTelemetry Collector by using the resource processor service.name: shipping-service Centralized control for telemetry data before it is sent to the backend

Trace span attribute peer.service

In OpenTelemetry, the peer.service attribute specifies the name of the remote service a span connects to, helping to identify external dependencies like databases, message brokers, or other microservices. Instana maps peer.service to an Instana service, enabling the visualization of service dependencies and interactions.

  • Instrumentation Libraries: Some libraries automatically set peer.service when they are properly configured. For example:
    • JDBC: The OpenTelemetry JDBC instrumentation can infer peer.service from database connection details.
    • HTTP Clients: HTTP libraries such as Apache HttpClient can derive peer.service based on the remote service’s hostname.

In the following table, you can see the different ways in which peer.service can be set or configured in OpenTelemetry:

Level Description Example Use Case
Application Code Directly set the peer.service attribute in your code by using the OpenTelemetry API span.setAttribute("peer.service", "backend-service") When you have specific knowledge about the target service and want to provide a custom name
Configuration Files (System Property) Define the peer.service value in system properties that are used by the OpenTelemetry agent or SDK otel.instrumentation.common.peer-service-mapping: "api.example.com=example-api-service,1.2.3.4=cats-service" When you want to map specific hostnames, IP addresses, or a combination of both to service names in a configuration file
Environment Variables Set the peer.service value as an environment variable accessible to your application OTEL_INSTRUMENTATION_COMMON_PEER_SERVICE_MAPPING="api.example.com=example-api-service,1.2.3.4=cats-service" When you need to dynamically set the peer.service value based on runtime conditions or deployment environment (similar to system properties but by using environment variables)
Instrumentation Library Automatically set by OpenTelemetry libraries peer.service="postgresql" Common for popular libraries such as database and HTTP clients which set peer.service automatically

Service mapping of well-known protocols

In addition to general attributes such as service.name and peer.service, OpenTelemetry defines a comprehensive set of semantic conventions for well-known protocols, including HTTP, RPC, databases, messaging systems, and more.

For a complete list of protocols, refer to the Trace Semantic Conventions.

HTTP span attributes

OpenTelemetry provides semantic conventions for HTTP spans to maintain consistency across tracing systems, including attributes that offer insights into HTTP requests and responses.

In the following table, you can see the different ways in which http span attributes can be set or configured in OpenTelemetry:

Attribute Description Example
http.method HTTP method (GET, POST) http.method="GET"
http.route Route or path of the HTTP request http.route="/webshop/articles/:id"
url.path Path component of the full URL url.path="/webshop/articles/4"
http.host Hostname of the server http.host="api.example.com"
http.target Target URL of the request http.target="/users"

While http.host and http.target can often infer the service, dynamic routing or service discovery might require additional information from configuration files or service registries for accurate mapping.

Remote procedure calls span attributes

OpenTelemetry provides semantic conventions for Remote Procedure Call (RPC) spans to maintain consistency across tracing systems, including attributes that offer insights. The key RPC span attributes used for service mapping in OpenTelemetry are:

  • rpc.method: Specifies the method or function which is invoked, providing detailed information about the operation.
  • rpc.service: Identifies the name of the service that is called, which is crucial for mapping RPC calls to specific services.
Attribute Description Example
rpc.service Name of the remote service rpc.service="user-service"
rpc.method A method or function that is invoked rpc.method="GetUserInfo"

By combining rpc.service and rpc.method with other attributes such as peer.service, RPC calls can be mapped to their corresponding services.

Database span attributes

OpenTelemetry provides semantic conventions for Database spans to maintain consistency across tracing systems, offering key attributes that provide valuable insights into database operations and interactions. These insights are essential for understanding the performance and behavior of database systems within a distributed application.

In the following table, you can see the key database span attributes used for service mapping in OpenTelemetry.

Attribute Description Example
db.system Database system (For example, MySQL and PostgreSQL) db.system="mysql"
db.instance Database instance name or identifier db.instance="my_database"
db.name The name of the database which is accessed db.name="users_db"
db.statement SQL query or database command executed db.statement="SELECT * FROM users"
db.operation Type of database operation (For example, SELECT and INSERT) db.operation="SELECT"

While these attributes primarily describe database interactions, they can indirectly assist with service mapping. For example, the db.instance attribute might help identify the service interacting with a specific database instance.

Messaging span attributes

OpenTelemetry provides semantic conventions for Messaging spans to maintain consistency across tracing systems, including attributes that offer insights.

The key Messaging span attributes used for service mapping in OpenTelemetry are:

Attribute Description Example
messaging.system Messaging system used (For example, Kafka, RabbitMQ, and AMQP) messaging.system="kafka"
messaging.destination Destination address (For example, topic name and queue name) messaging.destination="user-events"
messaging.operation Operation performed (For example, SEND, RECEIVE, PUBLISH, and SUBSCRIBE) messaging.operation="SEND"

These attributes help map services based on the messaging systems that they interact with and the specific topics or queues they use. For example, if a service is known to send messages to a specific Kafka topic, the messaging.destination attribute can help identify the service.

Troubleshooting

Infrastructure correlation missing for calls to IBM middleware

If the hostname collected by OpenTelemetry tracing for IBM middleware differs from the hostname that is collected by the Instana middleware sensor, you might encounter an Infrastructure: Correlation missing message in the Instana UI.

Depending on the environment where the IBM middleware is deployed, you can resolve this issue in the OpenTelemetry configuration or in the IBM middleware configuration:

OpenTelemetry configuration

  • Non-Kubernetes environment

If the IBM middleware is deployed on a standard virtual machine (VM), set a host alias for OpenTelemetry calls as follows:

To resolve this issue, set a host alias for OpenTelemetry calls by following these steps:

  1. On the server that is running IBM MQ, IBM ACE, or IBM DataPower, stop the respective service and export an environment variable:

    OTEL_RESOURCE_ATTRIBUTES=host.alias=<alias_of_the_host>
     

    Replace <alias_of_the_host> with the hostname collected by the Instana middleware sensor.

    For example, if the Instana IBM MQ sensor collects the hostname instmq1.example.com, but IBM MQ OpenTelemetry tracing collects the host's IP address, you must export the variable as follows:

    OTEL_RESOURCE_ATTRIBUTES=host.alias=instmq1.example.com
     
  2. Restart IBM MQ, IBM ACE, or IBM DataPower.

  • Kubernetes environment

When IBM middleware (such as IBM ACE, IBM MQ, or DataPower) is installed on a Kubernetes cluster, it runs in a container, which is different from the standard VM environment. Unlike VMs, containers have dynamic hostnames or IPs, which leads to unmonitored calls and incorrect infrastructure correlation in Instana.

To resolve this issue, complete the following steps:

  1. Export environment variables in the IBM middleware Custom Resource (CR) instance. In the CR configuration file, add the following environment variables in the deployment/demonset section:

        spec:
          containers:
          - env:
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: OTEL_RESOURCE_ATTRIBUTES
              value: "host.alias=$(POD_IP)"
     
  2. Wait for resync of the CR with the related deployments.

  3. Restart IBM MQ, IBM ACE, or IBM DataPower, if required.

This configuration help ensure that each IBM middleware container carries its POD_IP as its host.alias value, enabling proper infrastructure correlation.

IBM middleware configuration

For IBM App Connect Enterprise integration server, you can configure OpenTelemetry trace for all message flows in an integration server and export span data to an OpenTelemetry collector.

In the ResourceManagers section of the server.conf.yaml file, set the properties openTelemetryHostName in the OpenTelemetryManager subsection to override the Hostname attribute for telemetry spans. For more information, see Configuring OpenTelemetry trace for an integration server.

Note: To find the hostname in the Instana UI, go to Infrastructure > Analyze Infrastructure. From the "Entity types" list, Select IBM ACE Message Flow. Then, select the required instance from the list to view its details. The Host name is displayed under the IBM ACE Message Flow section.