JBoss EAP XP 6.0 で始める OpenTelemetry (OTEL) 入門

こんにちは、Technical Account Manager (TAM) の鈴村圭史です。 2025年、エンタープライズ Java 開発の現場では 「可観測性(Observability)」の重要性がこれまで以上に高まっています。

今回は、最新の Red Hat JBoss Enterprise Application Platform Expansion Pack 6.0(以下、JBoss EAP XP 6.0) を利用して、OpenTelemetry(OTEL)による可視化環境を構築する方法をハンズオン形式で紹介します。 インフラ基盤のセットアップから、JBoss EAP XP 6.0 の構成、そしてアプリケーションのトレース/ログ/メトリクスの可視化まで、順に手を動かしながら確認していきます。

用語解説

JBoss EAP XP 6.0 とは?

JBoss EAP XP(Expansion Pack)は、安定した JBoss EAP をベースに、最新の MicroProfile 仕様やクラウドネイティブ機能を提供する拡張パックです。 XP 6.0 は JBoss EAP 8.1 上で動作し、MicroProfile 7.0 に準拠しています。

これにより、Jakarta EE 10 の安定性MicroProfile の先進機能の両方を活用できます。 特に XP 6.0 では MicroProfile Telemetry 2.0 がサポートされ、OpenTelemetry との統合が大幅に強化されています。

OpenTelemetry (OTEL) とは?

OpenTelemetry は、トレース・メトリクス・ログといったテレメトリデータを生成・収集し、外部にエクスポートするための標準フレームワークです。

従来の「監視(Monitoring)」が “壊れていないかを見る” ものであるのに対し、 可観測性(Observability)は “なぜそうなっているのか” を理解するためのものです。

マイクロサービスや分散システムのトラブルシューティングにおいて、今や欠かせない技術となっています。

検証環境の構成

今回は、ローカル環境で構築します。

  • 基盤: Podman (専用ネットワーク otel-net)
  • APサーバー: JBoss EAP 8.1 + XP 6.0
  • 可視化基盤:
    • OTEL Collector: テレメトリデータの収集と転送
    • Jaeger: トレース情報の表示(オプション)
ステップ 1: インフラ基盤の構築 (Podman)

まず、Jaeger と OTEL Collector を立ち上げます。

1. 専用ネットワークの作成

podman network create otel-net

2. Jaeger (All-in-One) の起動

podman run -d --name jaeger \
  --network otel-net \
  -e COLLECTOR_OTLP_ENABLED=true \
  -p 16686:16686 \
  docker.io/jaegertracing/all-in-one:latest

3. OTEL Collector 設定ファイル (otel-config.yaml) の作成

トレース、ログ、メトリクスのすべてに対応した設定ファイルを作成します。

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: "0.0.0.0:4317"
      http:
        endpoint: "0.0.0.0:4318"
  prometheus:
    config:
      scrape_configs:
        - job_name: 'jboss-eap'
          scrape_interval: 10s
          static_configs:
            - targets: ['host.containers.internal:9990']
exporters:
  debug:
    verbosity: detailed
  otlp:
    endpoint: "jaeger:4317"
    tls:
      insecure: true
service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [debug, otlp]
    logs:
      receivers: [otlp]
      exporters: [debug]
    metrics:
      receivers: [prometheus]
      exporters: [debug]

4. OTEL Collector の起動

podman run -d --name otel-collector \
  --network otel-net \
  -p 4317:4317 \
  -p 4318:4318 \
  --add-host host.containers.internal:host-gateway \
  -v $(pwd)/otel-config.yaml:/etc/otelcol/config.yaml:Z \
  docker.io/otel/opentelemetry-collector:latest
ステップ 2: JBoss EAP XP 6 のインストールと設定

次に、JBoss EAP XP 6.0 をセットアップし、OpenTelemetry サブシステムを有効化します。

1. インストール

JBoss EAP Installation Manager を使用して XP 6.0 プロファイルをインストールします。 弊社製品のダウンロードサイトから、EAP のInstallation Manager (もしくは、EAP 8.1 などの)の zip 版をダウンロードし展開します。 Installation Manager を使用すると、EAP と XP の依存モジュールが正しく配置されたディレクトリ構成を自動で作成できます。 eap-xp-6 ディレクトリに移動してから、EAP を起動します。

./bin/jboss-eap-installation-manager.sh install --profile eap-xp-6.0 --dir eap-xp-6
cd eap-xp-6
./bin/standalone.sh

2. OpenTelemetry サブシステムの設定

起動したターミナルとは別のターミナルを開いて、管理CLIを使用して追加の設定を行います。

./bin/jboss-cli.sh --connect
# 以下のコマンドを順に実行
/extension=org.wildfly.extension.opentelemetry:add

/subsystem=opentelemetry:add( \
    service-name=eap-xp6-server \
)
reload

ステップ 3: アプリケーションの準備

XP 6 上で動作させるための簡単な JAX-RS アプリケーションを用意します。プロジェクト構成は次の通りです。

サンプルコード構成:

jaxrs-test/
├── pom.xml
└── src
    └── main
        ├── java
        │   └── com
        │       └── example
        │           ├── HelloResource.java
        │           └── RestApplication.java
        ├── resources
        │   └── META-INF
        │       └── microprofile-config.properties
        └── webapp
            └── WEB-INF
                └── beans.xml

サンプルのコードは、この記事の一番最後に記載します。 アプリケーションをコンパイルして、EAP にデプロイします。

mvn clean package
cp target/jax-rs.war <PATHTO>/eap-xp-6/standalone/deployment/jax-rs.war

ステップ 4: 実行と確認

1. XP 6 の起動

./bin/standalone.sh  -bmanagement 0.0.0.0

2. トラフィックの生成

デプロイしたアプリケーションにアクセスしてトレースデータを生成します。

curl http://localhost:8080/jax-rs/api/hello

3. 可視化の確認

Collector ログの確認: podman logs -f otel-collector を実行し、Trace, Log, Metrics のデータが流れてきていることを確認します。 Collector のログには、EAP から送られてきたトレースやログがリアルタイムで表示されます。アプリケーションのアクセスした結果として次のようなログが出力されます。

 podman logs otel-collector -f


2025-12-12T03:37:34.203Z    info    Logs    {"resource": {"service.instance.id": "e8273ca9-94e6-451b-b0f3-250a1cd1cc58", "service.name": "otelcol", "service.version": "0.141.0"}, "otelcol.component.id": "debug", "otelcol.component.kind": "exporter", "otelcol.signal": "logs", "resource logs": 1, "log records": 1}
2025-12-12T03:37:34.203Z    info    ResourceLog #0
Resource SchemaURL: 
Resource attributes:
     -> service.name: Str(eap-xp6-server)
     -> telemetry.sdk.language: Str(java)
     -> telemetry.sdk.name: Str(opentelemetry)
     -> telemetry.sdk.version: Str(1.42.1.redhat-00001)
ScopeLogs #0
ScopeLogs SchemaURL: 
InstrumentationScope io.smallrye.opentelemetry 
LogRecord #0
ObservedTimestamp: 2025-12-12 03:37:34.006242847 +0000 UTC
Timestamp: 2025-12-12 03:37:34.006012341 +0000 UTC
SeverityText: INFO
SeverityNumber: Info(9)
Body: Str(--- JAX-RS HelloResource Accessed ---)
Trace ID: 231c425c58a933394ba848b42b3d8f9b
Span ID: 0ced270d06823f4e
Flags: 1
    {"resource": {"service.instance.id": "e8273ca9-94e6-451b-b0f3-250a1cd1cc58", "service.name": "otelcol", "service.version": "0.141.0"}, "otelcol.component.id": "debug", "otelcol.component.kind": "exporter", "otelcol.signal": "logs"}

また、Jaeger UI での確認には、ブラウザで http://localhost:16686 にアクセスします。 Service で eap-xp6-server を選択して、trace を確認します。

まとめ

今回は、ローカル環境で JBoss EAP XP 6.0 を利用して、OpenTelemetry(OTEL)を試してみました。 ぜひ試してみてください。

サンプルコード

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>jaxrs-test</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <version.bom.expansion>6.0.0.GA-redhat-00016</version.bom.expansion>        
        <version.bom.ee>8.1.2.GA-redhat-00004</version.bom.ee>
    </properties>

    <repositories>
        <repository>
            <id>redhat-ga-maven-repository</id>
            <name>Red Hat GA Maven Repository</name>
            <url>https://maven.repository.redhat.com/ga/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>jboss-public-maven-repository</id>
            <name>JBoss Public Maven Repository</name>
            <url>https://repository.jboss.org/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>redhat-ga-maven-repository</id>
            <name>Red Hat GA Maven Repository</name>
            <url>https://maven.repository.redhat.com/ga/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.bom</groupId>
                <artifactId>jboss-eap-expansion</artifactId>
                <version>${version.bom.expansion}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.bom</groupId>
                <artifactId>jboss-eap-ee-with-tools</artifactId>
                <version>${version.bom.ee}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>    
</project>

HelloResource.java

package com.example;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;

@Path("/hello")
public class HelloResource {
    @GET
    @Produces("text/plain")
    public String sayHello() {
        System.out.println("--- JAX-RS HelloResource Accessed ---");
        return "Hello, OpenTelemetry via JAX-RS!";
    }
}

RestApplication.java

package com.example;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("/api")
public class RestApplication extends Application {}

microprofile-config.properties

otel.sdk.disabled=false
otel.traces.exporter=otlp

otel.exporter.otlp.protocol=http/protobuf
otel.exporter.otlp.endpoint=http://localhost:4318

otel.service.name=my-jaxrs-app

beans.xml

<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" bean-discovery-mode="all"></beans>

* 各記事は著者の見解によるものでありその所属組織を代表する公式なものではありません。その内容については非公式見解を含みます。