Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions servicetalk-examples/http/opentelemetry-jaeger/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright © 2026 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: "java"
apply plugin: "application"
apply from: "../../gradle/idea.gradle"

application {
mainClass = "io.servicetalk.examples.http.opentelemetry.jaeger.JaegerOtlpExample"
}

run {
systemProperty "io.opentelemetry.sdk.common.export.GrpcSenderProvider", "io.servicetalk.opentelemetry.client.ServiceTalkGrpcSenderProvider"
}

dependencies {
implementation platform("io.opentelemetry:opentelemetry-bom:$opentelemetryVersion")

implementation project(":servicetalk-annotations")
implementation project(":servicetalk-http-netty")
implementation project(":servicetalk-opentelemetry-http") // OpenTelemetry client/server filters
implementation project(":servicetalk-test-resources") // test certificates

// ServiceTalk OpenTelemetry transport provider (SPI discovery)
runtimeOnly project(":servicetalk-opentelemetry-client")
runtimeOnly project(":servicetalk-opentelemetry-asynccontext") // OpenTelemetry async context propagation

// OpenTelemetry Java SDK
implementation "io.opentelemetry:opentelemetry-api"
implementation "io.opentelemetry:opentelemetry-sdk"
// OTLP exporter (uses SPI to find transport)
// Exclude default OkHttp sender to use ServiceTalk's implementation exclusively
implementation("io.opentelemetry:opentelemetry-exporter-otlp") {
// exclude group: 'io.opentelemetry', module: 'opentelemetry-exporter-sender-okhttp'
}

implementation "org.slf4j:slf4j-api:$slf4jVersion"
runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
}
40 changes: 40 additions & 0 deletions servicetalk-examples/http/opentelemetry-jaeger/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Docker Compose configuration for Jaeger with mTLS-enabled OTLP Collector
#
# This setup includes:
# - Jaeger all-in-one for trace visualization
# - OpenTelemetry Collector with mTLS for secure trace ingestion

version: '3.8'

services:
# Jaeger backend for trace storage and visualization
jaeger:
image: jaegertracing/all-in-one:latest
container_name: jaeger
environment:
- COLLECTOR_OTLP_ENABLED=true
ports:
- "16686:16686" # Jaeger UI
- "4317:4317" # OTLP gRPC (internal, for collector)
- "4318:4318" # OTLP HTTP (internal, for collector)
networks:
- otel-network

# OpenTelemetry Collector with mTLS
# otel-collector:
# image: otel/opentelemetry-collector:latest
# container_name: otel-collector
# command: ["--config=/etc/otel-collector-config.yaml"]
# volumes:
# - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml:ro
# - ./certs:/certs:ro
# ports:
# - "4318:4318" # OTLP HTTP with mTLS
# depends_on:
# - jaeger
# networks:
# - otel-network

networks:
otel-network:
driver: bridge
85 changes: 85 additions & 0 deletions servicetalk-examples/http/opentelemetry-jaeger/generate-certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash
#
# Copyright © 2026 Apple Inc. and the ServiceTalk project authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -e

CERTS_DIR="./certs"

echo "Generating mTLS certificates for OTLP collector..."
echo ""

# Create certs directory
mkdir -p "$CERTS_DIR"
cd "$CERTS_DIR"

# Generate CA private key and certificate
echo "1. Generating CA certificate..."
openssl genrsa -out ca-key.pem 4096
openssl req -new -x509 -days 365 -key ca-key.pem -out ca-cert.pem \
-subj "/C=US/ST=California/L=Cupertino/O=ServiceTalk/CN=ServiceTalk CA"

# Generate server private key and certificate signing request
echo "2. Generating server certificate..."
openssl genrsa -out server-key.pem 4096
openssl req -new -key server-key.pem -out server-csr.pem \
-subj "/C=US/ST=California/L=Cupertino/O=ServiceTalk/CN=localhost"

# Create server certificate extensions file
cat > server-ext.cnf <<EOF
subjectAltName = DNS:localhost,DNS:otel-collector,IP:127.0.0.1
extendedKeyUsage = serverAuth
EOF

# Sign server certificate with CA
openssl x509 -req -days 365 -in server-csr.pem -CA ca-cert.pem -CAkey ca-key.pem \
-CAcreateserial -out server-cert.pem -extfile server-ext.cnf

# Generate client private key and certificate signing request
echo "3. Generating client certificate..."
openssl genrsa -out client-key.pem 4096
openssl req -new -key client-key.pem -out client-csr.pem \
-subj "/C=US/ST=California/L=Cupertino/O=ServiceTalk/CN=ServiceTalk Client"

# Create client certificate extensions file
cat > client-ext.cnf <<EOF
extendedKeyUsage = clientAuth
EOF

# Sign client certificate with CA
openssl x509 -req -days 365 -in client-csr.pem -CA ca-cert.pem -CAkey ca-key.pem \
-CAcreateserial -out client-cert.pem -extfile client-ext.cnf

# Clean up temporary files
rm -f server-csr.pem client-csr.pem server-ext.cnf client-ext.cnf ca-cert.srl

# Set appropriate permissions
chmod 644 *.pem
chmod 600 *-key.pem

echo ""
echo "✓ Certificates generated successfully in $CERTS_DIR/"
echo ""
echo "Generated files:"
echo " - ca-cert.pem (CA certificate - trust store)"
echo " - ca-key.pem (CA private key)"
echo " - server-cert.pem (Server certificate)"
echo " - server-key.pem (Server private key)"
echo " - client-cert.pem (Client certificate)"
echo " - client-key.pem (Client private key)"
echo ""
echo "Note: Keep *-key.pem files secure!"
echo ""
58 changes: 58 additions & 0 deletions servicetalk-examples/http/opentelemetry-jaeger/gradle.lockfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.google.api.grpc:proto-google-common-protos:2.51.0=runtimeClasspath
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,runtimeClasspath
com.google.protobuf:protobuf-bom:3.25.8=runtimeClasspath
com.google.protobuf:protobuf-java:3.25.8=runtimeClasspath
com.squareup.okhttp3:okhttp-jvm:5.3.2=runtimeClasspath
com.squareup.okhttp3:okhttp:5.3.2=runtimeClasspath
com.squareup.okio:okio-jvm:3.16.4=runtimeClasspath
com.squareup.okio:okio:3.16.4=runtimeClasspath
io.netty:netty-bom:4.1.133.Final=runtimeClasspath
io.netty:netty-buffer:4.1.133.Final=runtimeClasspath
io.netty:netty-codec-dns:4.1.133.Final=runtimeClasspath
io.netty:netty-codec-http2:4.1.133.Final=runtimeClasspath
io.netty:netty-codec-http:4.1.133.Final=runtimeClasspath
io.netty:netty-codec:4.1.133.Final=runtimeClasspath
io.netty:netty-common:4.1.133.Final=runtimeClasspath
io.netty:netty-handler:4.1.133.Final=runtimeClasspath
io.netty:netty-resolver-dns-classes-macos:4.1.133.Final=runtimeClasspath
io.netty:netty-resolver-dns-native-macos:4.1.133.Final=runtimeClasspath
io.netty:netty-resolver-dns:4.1.133.Final=runtimeClasspath
io.netty:netty-resolver:4.1.133.Final=runtimeClasspath
io.netty:netty-tcnative-boringssl-static:2.0.77.Final=runtimeClasspath
io.netty:netty-tcnative-classes:2.0.77.Final=runtimeClasspath
io.netty:netty-transport-classes-epoll:4.1.133.Final=runtimeClasspath
io.netty:netty-transport-classes-kqueue:4.1.133.Final=runtimeClasspath
io.netty:netty-transport-native-epoll:4.1.133.Final=runtimeClasspath
io.netty:netty-transport-native-kqueue:4.1.133.Final=runtimeClasspath
io.netty:netty-transport-native-unix-common:4.1.133.Final=runtimeClasspath
io.netty:netty-transport:4.1.133.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:2.14.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.14.0=runtimeClasspath
io.opentelemetry.semconv:opentelemetry-semconv:1.30.0=runtimeClasspath
io.opentelemetry:opentelemetry-api-incubator:1.48.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-api:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-common:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-context:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-exporter-common:1.59.0=runtimeClasspath
io.opentelemetry:opentelemetry-exporter-otlp-common:1.59.0=runtimeClasspath
io.opentelemetry:opentelemetry-exporter-otlp:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-exporter-sender-okhttp:1.59.0=runtimeClasspath
io.opentelemetry:opentelemetry-sdk-common:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.59.0=runtimeClasspath
io.opentelemetry:opentelemetry-sdk-logs:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-sdk-metrics:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-sdk-trace:1.59.0=compileClasspath,runtimeClasspath
io.opentelemetry:opentelemetry-sdk:1.59.0=compileClasspath,runtimeClasspath
org.apache.logging.log4j:log4j-api:2.23.1=runtimeClasspath
org.apache.logging.log4j:log4j-core:2.23.1=runtimeClasspath
org.apache.logging.log4j:log4j-slf4j-impl:2.23.1=runtimeClasspath
org.hamcrest:hamcrest:2.2=compileClasspath,runtimeClasspath
org.jctools:jctools-core:4.0.5=runtimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.2.21=runtimeClasspath
org.jetbrains:annotations:13.0=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=compileClasspath,runtimeClasspath
empty=annotationProcessor
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# OpenTelemetry Collector configuration with mTLS support
#
# This collector receives OTLP data over HTTPS with mutual TLS authentication
# and forwards it to Jaeger for visualization.

receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
tls:
cert_file: /certs/server-cert.pem
key_file: /certs/server-key.pem
ca_file: /certs/ca-cert.pem
client_ca_file: /certs/ca-cert.pem
# Require client certificates (mutual TLS)
client_ca_file_reload: false

processors:
batch:
timeout: 1s
send_batch_size: 1024

exporters:
# Forward to Jaeger
otlp/jaeger:
endpoint: jaeger:4317
tls:
insecure: true # Jaeger doesn't use TLS in this setup

# Debug exporter for debugging (replaces deprecated logging exporter)
debug:
verbosity: detailed

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp/jaeger, debug]
Loading
Loading