Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics service graph poc #36

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions checkout/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/checkout/target/checkout-1.1-SNAPSHOT.jar ./app.jar
COPY --from=builder /usr/src/app/checkout/target/lib ./lib
COPY ./metric-config.yaml ./
# we ignore the version (which is from upstream) and use the latest version of the grafana distribution
ADD --chmod=644 https://github.com/grafana/grafana-opentelemetry-java/releases/latest/download/grafana-opentelemetry-java.jar /usr/src/app/opentelemetry-javaagent.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar
Expand Down
1 change: 1 addition & 0 deletions fraud-detection/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ FROM eclipse-temurin:21-jre
WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/fraud-detection/target/fraud-detection-1.1-SNAPSHOT.jar ./app.jar
COPY ./metric-config.yaml ./
# we ignore the version (which is from upstream) and use the latest version of the grafana distribution
ADD --chmod=644 https://github.com/grafana/grafana-opentelemetry-java/releases/latest/download/grafana-opentelemetry-java.jar /usr/src/app/opentelemetry-javaagent.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar
Expand Down
1 change: 1 addition & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ FROM eclipse-temurin:21-jre
WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/frontend/target/frontend-1.1-SNAPSHOT.jar ./app.jar
COPY ./metric-config.yaml ./
# we ignore the version (which is from upstream) and use the latest version of the grafana distribution
ADD --chmod=644 https://github.com/grafana/grafana-opentelemetry-java/releases/latest/download/grafana-opentelemetry-java.jar /usr/src/app/opentelemetry-javaagent.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public ResponseEntity<Order> create(@RequestBody OrderForm form, HttpServletRequ
}

// test un-instrumented backend. Note that the 8.8.8.8 DNS resolves the example.com domain
ResponseEntity<String> exampleDotComResponse = restTemplate.getForEntity("https://example.com/", String.class);
ResponseEntity<String> exampleDotComResponse = restTemplate.getForEntity("https://google.com/", String.class);
if (exampleDotComResponse.getStatusCode() != HttpStatus.OK) {
String exceptionShortDescription = "exampleDotCom-status-" + fraudDetectionResult.getStatusCode();
span.recordException(new Exception(exceptionShortDescription));
Expand Down
43 changes: 23 additions & 20 deletions k8s/anti-fraud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,26 @@ spec:
app: anti-fraud
spec:
containers:
- name: anti-fraud
image: fraud-detection:1.1-SNAPSHOT
imagePullPolicy: Never
ports:
- containerPort: 8080
env:
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://postgres:5432/compose-postgres
- name: SPRING_DATASOURCE_USERNAME
value: compose-postgres
- name: SPRING_DATASOURCE_PASSWORD
value: compose-postgres
- name: SPRING_JPA_HIBERNATE_DDL_AUTO
value: update
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://lgtm:4318"
- name: LOGGING_FILE_NAME
value: application.log
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name=anti-fraud,service.namespace=shop,service.version=1.1,deployment.environment=staging
- name: anti-fraud
image: fraud-detection:1.1-SNAPSHOT
imagePullPolicy: Never
ports:
- containerPort: 8080
env:
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://postgres:5432/compose-postgres
- name: SPRING_DATASOURCE_USERNAME
value: compose-postgres
- name: SPRING_DATASOURCE_PASSWORD
value: compose-postgres
- name: SPRING_JPA_HIBERNATE_DDL_AUTO
value: update
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://lgtm:4318"
- name: LOGGING_FILE_NAME
value: application.log
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name=anti-fraud,service.namespace=shop,service.version=1.1,deployment.environment=staging
- name: OTEL_EXPERIMENTAL_METRICS_VIEW_CONFIG
value: metric-config.yaml

2 changes: 2 additions & 0 deletions k8s/chckout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ spec:
value: "http://shipping:8080"
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name=checkout,service.namespace=shop,service.version=1.1,deployment.environment=staging
- name: OTEL_EXPERIMENTAL_METRICS_VIEW_CONFIG
value: metric-config.yaml

4 changes: 3 additions & 1 deletion k8s/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
value: compose-postgres
- name: SPRING_JPA_HIBERNATE_DDL_AUTO
value: update
- name: SPRING_REDIS_HOST
- name: SPRING_DATA_REDIS_HOST
value: redis
- name: ANTIFRAUDSERVICE_BASEURL
value: http://anti-fraud:8080
Expand All @@ -53,3 +53,5 @@ spec:
value: "rabbitmq"
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name=frontend,service.namespace=shop,service.version=1.1,deployment.environment=staging
- name: OTEL_EXPERIMENTAL_METRICS_VIEW_CONFIG
value: metric-config.yaml
50 changes: 50 additions & 0 deletions k8s/island.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: v1
kind: Service
metadata:
name: island
spec:
selector:
app: island
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: island
spec:
replicas: 1
selector:
matchLabels:
app: island
template:
metadata:
labels:
app: island
spec:
containers:
- name: island
image: fraud-detection:1.1-SNAPSHOT
imagePullPolicy: Never
ports:
- containerPort: 8080
env:
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://postgres:5432/compose-postgres
- name: SPRING_DATASOURCE_USERNAME
value: compose-postgres
- name: SPRING_DATASOURCE_PASSWORD
value: compose-postgres
- name: SPRING_JPA_HIBERNATE_DDL_AUTO
value: update
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://lgtm:4318"
- name: LOGGING_FILE_NAME
value: application.log
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name=island,service.namespace=shop,service.version=1.1,deployment.environment=staging
- name: OTEL_EXPERIMENTAL_METRICS_VIEW_CONFIG
value: metric-config.yaml

2 changes: 2 additions & 0 deletions k8s/shipping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ spec:
value: application.log
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name=shipping,service.namespace=shop,service.version=1.1,deployment.environment=staging
- name: OTEL_EXPERIMENTAL_METRICS_VIEW_CONFIG
value: metric-config.yaml
2 changes: 2 additions & 0 deletions k8s/warehouse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ spec:
value: "rabbitmq"
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name=warehouse,service.namespace=shop,service.version=1.1,deployment.environment=staging
- name: OTEL_EXPERIMENTAL_METRICS_VIEW_CONFIG
value: metric-config.yaml
13 changes: 13 additions & 0 deletions metric-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- selector:
instrument_name: http.server.request.duration
view:
attribute_keys:
- http.route
- http.request.method
- http.response.status_code
- error.type
- network.protocol.name
- network.protocol.version
- url.scheme
- server.address
- server.port
1 change: 1 addition & 0 deletions shipping/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ FROM eclipse-temurin:21-jre
WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/shipping/target/shipping-1.1-SNAPSHOT.jar ./app.jar
COPY ./metric-config.yaml ./
# we ignore the version (which is from upstream) and use the latest version of the grafana distribution
ADD --chmod=644 https://github.com/grafana/grafana-opentelemetry-java/releases/latest/download/grafana-opentelemetry-java.jar /usr/src/app/opentelemetry-javaagent.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar
Expand Down
1 change: 1 addition & 0 deletions warehouse/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ FROM eclipse-temurin:21-jre
WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/warehouse/target/warehouse-1.1-SNAPSHOT.jar ./app.jar
COPY ./metric-config.yaml ./
# we ignore the version (which is from upstream) and use the latest version of the grafana distribution
ADD --chmod=644 https://github.com/grafana/grafana-opentelemetry-java/releases/latest/download/grafana-opentelemetry-java.jar /usr/src/app/opentelemetry-javaagent.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar
Expand Down