Skip to content

Commit

Permalink
chore: add jaeger java instrumentation example via an otel extension (#…
Browse files Browse the repository at this point in the history
…1470)

* fix: add jaeger java instrumentation example

* rm jars

* .dockerignore

* cleanup buildscript example

* cleanup imports & newlines

* update to non snapshots
  • Loading branch information
korniltsev authored Sep 8, 2022
1 parent c0d4152 commit 90f21bf
Show file tree
Hide file tree
Showing 28 changed files with 806 additions and 73 deletions.
3 changes: 2 additions & 1 deletion examples/tracing/jaeger/config.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040
# The URL for 'pyroscope.profile.url' attribute.
PYROSCOPE_PROFILE_URL=http://localhost:4040
JAEGER_ENDPOINT=http://jaeger:14268/api/traces
JAEGER_GRPC_ENDPOINT=http://jaeger:14250
OTEL_EXPORTER_JAEGER_ENDPOINT=http://jaeger:14250
OTEL_PYROSCOPE_ENDPOINT=http://localhost:4040
# With DEBUG_TRACER=1 traces aren't sent but printed to stdout.
DEBUG_TRACER=${DEBUG_TRACER:-0}
114 changes: 114 additions & 0 deletions examples/tracing/jaeger/docker-compose.no-loki.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
version: '3.9'

services:
jaeger:
image: 'jaegertracing/all-in-one:1.31'
ports:
- '6831:6831/udp'
- '16686:16686'
- '14268:14268'
- '14250:14250'

pyroscope:
image: 'pyroscope/pyroscope:latest'
environment:
- PYROSCOPE_CONFIG=/pyroscope.yaml
- PYROSCOPE_LOG_LEVEL=debug
ports:
- '4040:4040'
volumes:
- ./pyroscope.yaml:/pyroscope.yaml
command:
- 'server'

grafana:
image: pyroscope/grafana:dev
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
environment:
- 'GF_INSTALL_PLUGINS=pyroscope-panel'
ports:
- '3000:3000'

us-east:
env_file:
- config.env
environment:
- REGION=us-east
build:
context: 'go/rideshare'
dockerfile: Dockerfile

eu-north:
env_file:
- config.env
environment:
- REGION=eu-north
build:
context: 'go/rideshare'
dockerfile: Dockerfile

ap-south:
env_file:
- config.env
environment:
- REGION=ap-south
build:
context: 'go/rideshare'
dockerfile: Dockerfile

us-east-java:
env_file:
- config.env
environment:
- REGION=us-east
build:
context: 'java/rideshare'
dockerfile: Dockerfile

eu-north-java:
env_file:
- config.env
environment:
- REGION=eu-north
build:
context: 'java/rideshare'
dockerfile: Dockerfile

ap-south-java:
env_file:
- config.env
environment:
- REGION=ap-south
build:
context: 'java/rideshare'
dockerfile: Dockerfile

eu-north-java-instrumentation:
env_file:
- config.env
build:
context: 'java-instrumentation/rideshare'
dockerfile: Dockerfile

load-generator:
env_file:
- config.env
build:
context: 'go/rideshare'
dockerfile: Dockerfile.loadgen
depends_on:
- ap-south
- eu-north
- us-east
- ap-south-java
- eu-north-java
- us-east-java

jaeger-ui:
build:
context: ''
dockerfile: jaeger-ui/Dockerfile
ports:
- '4000:3000'
13 changes: 13 additions & 0 deletions examples/tracing/jaeger/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ services:
options:
loki-url: 'http://localhost:3100/loki/api/v1/push'

eu-north-java-instrumentation:
env_file:
- config.env
environment:
- REGION=eu-north
build:
context: 'java-instrumentation/rideshare'
dockerfile: Dockerfile
logging:
driver: loki
options:
loki-url: 'http://localhost:3100/loki/api/v1/push'

load-generator:
env_file:
- config.env
Expand Down
1 change: 1 addition & 0 deletions examples/tracing/jaeger/go/rideshare/loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var hosts = []string{
"us-east-java",
"eu-north-java",
"ap-south-java",
"eu-north-java-instrumentation",
}

var vehicles = []string{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
out/
.gradle/
.idea/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/
.idea/
.gradle
pyroscope.jar
out/
42 changes: 42 additions & 0 deletions examples/tracing/jaeger/java-instrumentation/rideshare/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM openjdk:11-slim-bullseye

WORKDIR /opt/app


COPY gradlew .
COPY gradle gradle
RUN ./gradlew --no-daemon


COPY build.gradle.kts settings.gradle.kts ./
RUN ./gradlew getDeps --no-daemon
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.17.0/opentelemetry-javaagent.jar opentelemetry-javaagent.jar
# ADD https://s01.oss.sonatype.org/content/repositories/snapshots/io/pyroscope/otel/0.10.1.2-SNAPSHOT/otel-0.10.1.2-20220907.093035-3.jar pyroscope-otel.jar
ADD https://repo1.maven.org/maven2/io/pyroscope/otel/0.10.1.3/otel-0.10.1.3.jar pyroscope-otel.jar

COPY src src
RUN ./gradlew assemble --no-daemon

ENV OTEL_SERVICE_NAME=ride-sharing-app-java-instrumentation
ENV OTEL_METRICS_EXPORTER=none
ENV OTEL_TRACES_EXPORTER=jaeger
ENV OTEL_EXPORTER_JAEGER_ENDPOINT=http://localhost:14250
ENV OTEL_TRACES_SAMPLER=always_on
ENV OTEL_PROPAGATORS=tracecontext
ENV OTEL_JAVAAGENT_EXTENSIONS=./pyroscope-otel.jar

ENV OTEL_PYROSCOPE_ADD_PROFILE_URL=true
ENV OTEL_PYROSCOPE_ADD_PROFILE_BASELINE_URL=true
ENV OTEL_PYROSCOPE_START_PROFILING=true
ENV OTEL_PYROSCOPE_ENDPOINT=http://localhost:4040

ENV PYROSCOPE_APPLICATION_NAME=ride-sharing-app-java-instrumentation
ENV PYROSCOPE_FORMAT=jfr
ENV PYROSCOPE_PROFILER_EVENT=itimer
ENV PYROSCOPE_SERVER_ADDRESS=http://localhost:4040
ENV PYROSCOPE_LABELS="region=eu-north"
ENV REGION=eu-north

CMD [ "java", "-javaagent:./opentelemetry-javaagent.jar", "-jar", "./build/libs/rideshare-instrumentation-1.0-SNAPSHOT.jar"]


Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
plugins {
id("java")
id("org.springframework.boot") version "2.7.1"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") //todo replace when otel is not shnapshot
maven("https://repo.spring.io/snapshot")
maven("https://repo.spring.io/milestone")
maven("https://repo.spring.io/release")

}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
}
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.3")
mavenBom("org.springframework.cloud:spring-cloud-sleuth-otel-dependencies:1.1.0-M7")
}
}

tasks.getByName<Test>("test") {
useJUnitPlatform()
}

tasks.create<Copy>("getDeps") {
from(configurations.getByName("compileClasspath"))
into("compileClasspath/")
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 90f21bf

Please sign in to comment.