Skip to content

Commit 0aeab23

Browse files
authored
feat: adds support for dockerfile, and docker-compose (#17)
* feat: adds initial version of async application using kafka * chore: rename the directory * feat: adds support for dockerfile, and docker-compose * fix: fixed the resolution of env vars * fix: adds network support for this * fix: fix the generation of config.yaml file, URL expose * feat: fixed the agent version which was causing http2 issue
1 parent 0ee2b82 commit 0aeab23

File tree

12 files changed

+133
-6
lines changed

12 files changed

+133
-6
lines changed

async-kafka-application/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
## Sample application for aync trace
2-
- under developement
1+
## Sample application for async trace
2+
Build
3+
- run the command `./gradlew jar`
4+
- run the command to prepare docker file `docker build ./`
5+
6+
Running
7+
- use docker-compose file provided in docker folder and run
8+
- change the ENV `TRACE_EXPORTER_END_POINT` for your appropriate endpoint
9+
- `docker-compose -f docker-compose.yaml up`
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ARG VERSION=1.0
2+
# ARG HYPERTRACE_AGENT_VERSION=1.0.5
3+
4+
FROM openjdk:11.0.10-jdk-buster
5+
WORKDIR /app
6+
RUN wget https://github.com/hypertrace/javaagent/releases/download/1.0.5/hypertrace-agent-all.jar && ls .
7+
COPY build/libs libs/
8+
COPY build/resources resources/
9+
COPY config.yaml config.yaml
10+
COPY run.sh run.sh
11+
RUN chmod a+x run.sh
12+
13+
ENV HT_CONFIG_FILE=config.yaml
14+
ENV SERVICE_NAME=async-kafka-consumer
15+
ENV KAFKA_BOOTSTRAP_SERVERS=localhost:9092
16+
ENV TRACE_EXPORTER_END_POINT=localhost:9411
17+
EXPOSE ${PORT}
18+
19+
#ENTRYPOINT ["java", "-javaagent:/app/hypertrace-agent-all.jar", "-jar", "./libs/async-kafka-consumer-1.0.jar"]
20+
ENTRYPOINT ["./run.sh"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
service_name: async-kafka-consumer
22
reporting:
3-
endpoint: http://localhost:9411/api/v2/spans
3+
endpoint: http://host.docker.internal/api/v2/spans
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
ENDPOINT=${TRACE_EXPORTER_END_POINT:-"http://localhost:9411/api/v2/spans"}
4+
NAME=${SERVICE_NAME:-"async-kafka-consumer"}
5+
6+
# prepare config.yaml file
7+
text=''
8+
text=$text"service_name: ${NAME}\n"
9+
text=$text"reporting:\n"
10+
text=$text" endpoint: ${ENDPOINT}\n"
11+
echo -e $text > config.yaml
12+
13+
java -javaagent:/app/hypertrace-agent-all.jar -jar /app/libs/async-kafka-consumer-1.0.jar
14+

async-kafka-application/async-kafka-consumer/src/main/java/org/hypertrace/example/async/kafka/consumer/Entry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class Entry {
1313

1414
public static void main(String[] args) {
1515
try {
16-
Config config = ConfigFactory.parseResources("application.conf");
16+
Config config = ConfigFactory.parseResources("application.conf").resolve();
1717
String bootstrapServer = config.getString("kafka.bootstrap.server");
1818
String consumerTopic = config.getString("kafka.consumer.topic");
1919
int maxWaitTime = config.getInt("maxWaitTime");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
kafka {
22
bootstrap.server="localhost:9092"
3+
bootstrap.server = ${?KAFKA_BOOTSTRAP_SERVERS}
34
consumer.topic="test-async-trace"
45
}
56
maxWaitTime=20
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ARG VERSION=1.0
2+
# ARG HYPERTRACE_AGENT_VERSION=1.0.5
3+
4+
FROM openjdk:11.0.10-jdk-buster
5+
WORKDIR /app
6+
RUN wget https://github.com/hypertrace/javaagent/releases/download/1.0.5/hypertrace-agent-all.jar && ls .
7+
COPY build/libs libs/
8+
COPY build/resources resources/
9+
COPY config.yaml config.yaml
10+
COPY run.sh run.sh
11+
RUN chmod a+x run.sh
12+
13+
ENV HT_CONFIG_FILE=config.yaml
14+
ENV SERVICE_NAME=async-kafka-producer-httpservice
15+
ENV KAFKA_BOOTSTRAP_SERVERS=localhost:9092
16+
ENV PORT=2020
17+
ENV TRACE_EXPORTER_END_POINT=localhost:9411
18+
19+
EXPOSE ${PORT}
20+
#ENTRYPOINT ["java", "-javaagent:/app/hypertrace-agent-all.jar", "-jar", "./libs/async-kafka-producer-httpservice-1.0.jar"]
21+
ENTRYPOINT ["./run.sh"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
service_name: async-kafka-producer-httpservice
22
reporting:
3-
endpoint: http://localhost:9411/api/v2/spans
3+
endpoint: http://host.docker.internal:9411/api/v2/spans
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
ENDPOINT=${TRACE_EXPORTER_END_POINT:-"http://localhost:9411/api/v2/spans"}
4+
NAME=${SERVICE_NAME:-"async-kafka-producer-httpservice"}
5+
6+
# prepare config.yaml file
7+
text=''
8+
text=$text"service_name: ${NAME}\n"
9+
text=$text"reporting:\n"
10+
text=$text" endpoint: ${ENDPOINT}\n"
11+
echo -e $text > config.yaml
12+
13+
java -javaagent:/app/hypertrace-agent-all.jar -jar ./libs/async-kafka-producer-httpservice-1.0.jar

async-kafka-application/async-kafka-producer-httpservice/src/main/java/org/hypertrace/example/async/kafka/producer/httpservice/Entry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Entry {
1212

1313
public static void main(String[] args) {
1414
try {
15-
Config config = ConfigFactory.parseResources("application.conf");
15+
Config config = ConfigFactory.parseResources("application.conf").resolve();
1616
updateRuntime();
1717
server.init(config);
1818
server.start();

0 commit comments

Comments
 (0)