-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile.production
More file actions
46 lines (35 loc) · 2.25 KB
/
Copy pathDockerfile.production
File metadata and controls
46 lines (35 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Example production Dockerfile:
# - Spring petclinic: https://github.com/spring-projects/spring-petclinic
# - Alloy OR OpenTelemetry Collector
# Use renovate to keep the version up-to-date
# renovate: datasource=github-releases depName=grafana-opentelemetry-java packageName=grafana/grafana-opentelemetry-java
ARG GRAFANA_OPENTELEMETRY_VERSION=2.18.1
FROM us-docker.pkg.dev/grafanalabs-global/docker-grafana-opentelemetry-java-prod/grafana-opentelemetry-java:$GRAFANA_OPENTELEMETRY_VERSION AS agent
FROM springio/petclinic
# 1. Install Alloy or OpenTelemetry Collector: https://grafana.com/docs/grafana-cloud/monitor-applications/collector
# 2. If Alloy or OpenTelemetry Collector is running on a different host, set the URL:
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
# 3. If Alloy or OpenTelemetry Collector does not offer gRPC, set the protocol to "http/protobuf":
ENV OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
# 4. Choose a **Service Name** to identify the service (e.g. `cart`)
ENV OTEL_SERVICE_NAME=<Service Name>
# 4. Add attributes to filter data (recommended):
# - **deployment.environment**: Name of the deployment environment (`staging` or `production`)
# - **service.namespace**: A namespace to group similar services
# (e.g. `shop` would create `shop/cart` in Application Observability)
# - **service.version**: The application version, to see if a new version has introduced a bug
# - **service.instance.id**: The unique instance, for example the Pod name (a UUID is generated by default)
ENV OTEL_RESOURCE_ATTRIBUTES=deployment.environment=<Environment>,service.namespace=<Namespace>,service.version=<Version>
# Build and run the application:
# 5. docker build -t grafana_opentelemetry_java_demo .
# 6. docker run -p 8080:8080 grafana_opentelemetry_java_demo
# 7. Open <http://localhost:8080> in your browser
# 8. Click on "Error" in the top right corner to generate an error
# 9. Open Application Observability in Grafana Cloud:
# - Click on the menu icon in the top left corner
# - Open the "Observability" menu
# - Click on "Application"
# Note: It might take up to five minutes for data to appear.
WORKDIR /app/
COPY --from=agent --chown=cnb /javaagent.jar /app/javaagent.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/app/javaagent.jar