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

Add spring-petclinic app as a demo #34

Merged
merged 8 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions docs/Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ TODO: add explanation of why this or not other component
- [Grafana Mimir](https://grafana.com/oss/mimir/)
- [Grafana Tempo](https://grafana.com/oss/tempo/)
- [Prometheus](https://prometheus.io/)

## Petclinic

In order to allow Grafana link logs and traces with each other, we've added a property `logging.pattern.level = trace_id=%mdc{trace_id} span_id=%mdc{span_id} trace_flags=%mdc{trace_flags} %5p` in `src/main/resources/application.properties` file which includes traceid and spanid in logs.
1 change: 1 addition & 0 deletions otel/jvm-autoinstrumentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ spec:
type: parentbased_traceidratio
argument: "1"
java:
# image: "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:1.22.0"
tilanis marked this conversation as resolved.
Show resolved Hide resolved
env:
- name: OTLP_METRICS_EXPORTER
value: otlp
Expand Down
103 changes: 102 additions & 1 deletion try-me/observability/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as config from './src/config.js'
import { HelmRelease } from './src/chart_install.js';
import { MinioBucket } from './src/create_bucket.js';
import { Deployment } from '@pulumi/kubernetes/apps/v1/index.js';

Check warning on line 6 in try-me/observability/index.js

View workflow job for this annotation

GitHub Actions / build

'Deployment' is defined but never used
tilanis marked this conversation as resolved.
Show resolved Hide resolved

const createNamespace = (name) => {
return new k8s.core.v1.Namespace(name, {
Expand Down Expand Up @@ -104,7 +105,107 @@
chartValuesPath: "./charts_values/kube_state_metrics_values.yaml",
chartRepositoryUrl: "https://prometheus-community.github.io/helm-charts"
});


let applicationProperties = `
# database init, supports mysql too
database=h2
spring.sql.init.schema-locations=classpath*:db/\${database}/schema.sql
spring.sql.init.data-locations=classpath*:db/\${database}/data.sql

# Web
spring.thymeleaf.mode=HTML

# JPA
spring.jpa.hibernate.ddl-auto=none
spring.jpa.open-in-view=true

# Internationalization
spring.messages.basename=messages/messages

# Actuator
management.endpoints.web.exposure.include=*

# Logging
logging.level.org.springframework=INFO
logging.pattern.level = trace_id=%mdc{trace_id} span_id=%mdc{span_id} trace_flags=%mdc{trace_flags} %5p
# logging.level.org.springframework.web=DEBUG
# logging.level.org.springframework.context.annotation=TRACE

# Maximum time static resources should be cached
spring.web.resources.cache.cachecontrol.max-age=12h
`;

new k8s.core.v1.ConfigMap("application-properties", {
metadata: {
name: "application-properties"
},
data: {
"application.properties": applicationProperties
}
})

new k8s.apps.v1.Deployment("petclinic", {
metadata: {
name: "petclinic",
labels: {
app: "petclinic",
},
},
spec: {
replicas: 1,
selector: {
matchLabels: {
app: "petclinic",
},
},
template: {
metadata: {
labels: {
app: "petclinic",
},
},
spec: {
containers: [{
image: "softwaremill/spring-petclinic:0.0.1",
name: "petclinic",
ports: [{
containerPort: 8080,
}],
volumeMounts: [{
mountPath: "/src/main/resources/",
name: "application-properties"
}],
}],
volumes: [{
name: "application-properties",
configMap: {
name: "application-properties",
items: [{
key: "application.properties",
path: "application.properties"
}],
}
}],
},
},
},
});

new k8s.core.v1.Service("petclinic", {
metadata: {
name: "petclinic",
},
spec: {
ports: [{
port: 8080,
protocol: "TCP",
targetPort: 8080,
}],
selector: {
app: "petclinic",
},
}});

// TODO: further installed chart processing if required

// return Pulumi outputs
Expand Down