Skip to content

Commit 32ba20b

Browse files
committed
Dry run feedback
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
1 parent 203dbaf commit 32ba20b

2 files changed

Lines changed: 61 additions & 23 deletions

File tree

03-auto-instrumentation.md

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ kubectl patch deployment frontend-deployment -n tutorial-application -p '{"spec"
124124
kubectl patch deployment backend1-deployment -n tutorial-application -p '{"spec": {"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-python":"true"}}}} }'
125125
kubectl patch deployment backend2-deployment -n tutorial-application -p '{"spec": {"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-java":"true"}}}} }'
126126
kubectl get pods -n tutorial-application -w
127+
# Port forward again -> kubectl port-forward service/frontend-service -n tutorial-application 4000:4000
127128
...
128129
NAME READY STATUS RESTARTS AGE
129130
backend1-deployment-559946d88-c6zq7 0/1 Init:0/1 0 1s
@@ -169,11 +170,13 @@ Now let's execute some requests on the app [http://localhost:4000/](http://local
169170
![Trace search](./images/jaeger-trace-search.jpg)
170171
![Trace detail](./images/jaeger-trace-detail.jpg)
171172

172-
In addition to traces in the Java auto-instrumentation also emits logs and metrics.
173+
In addition to traces in the Java auto-instrumentation also emits **logs** and **metrics**.
173174
The logs in our case are printed into the collector stdout via `debug` exporter and metrics are sent via OTLP HTTP into Prometheus.
174175
The OpenTelemetry spec defines that the following metrics should be collected: [HTTP metrics](https://opentelemetry.io/docs/specs/semconv/http/http-metrics/).
175176

176177
```bash
178+
kubectl logs deployment.apps/otel-collector -n observability-backend
179+
...
177180
2024-02-28T10:08:21.807Z info LogsExporter {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 1, "log records": 7}
178181
2024-02-28T10:08:21.807Z info ResourceLog #0
179182
Resource SchemaURL: https://opentelemetry.io/schemas/1.21.0
@@ -221,10 +224,42 @@ ObservedTimestamp: 2024-02-28 10:08:21.638118261 +0000 UTC
221224
Timestamp: 2024-02-28 10:08:21.638 +0000 UTC
222225
SeverityText: INFO
223226
SeverityNumber: Info(9)
224-
Body: Str(Started DiceApplication in 2.105 seconds (process running for 4.485))
227+
Body: Str(Started DiceApplication in 3.459 seconds (process running for 6.305))
225228
Trace ID: 3bde5d3ee82303571bba6e1136781fe4
226229
Span ID: 46de5d3ee82303571bba6e1136781fe4
227230
Flags: 0
231+
232+
233+
kubectl logs -n tutorial-application deployment.apps/backend2-deployment
234+
...
235+
Defaulted container "backend2" out of: backend2, opentelemetry-auto-instrumentation-java (init)
236+
Picked up JAVA_TOOL_OPTIONS: -javaagent:/otel-auto-instrumentation-java/javaagent.jar
237+
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
238+
[otel.javaagent 2024-03-12 17:35:52:181 +0000] [main] INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 1.32.1
239+
240+
. ____ _ __ _ _
241+
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
242+
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
243+
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
244+
' |____| .__|_| |_|_| |_\__, | / / / /
245+
=========|_|==============|___/=/_/_/_/
246+
:: Spring Boot :: (v3.0.5)
247+
248+
2024-03-12T17:35:55.712Z INFO 7 --- [ main] io.opentelemetry.dice.DiceApplication : Starting DiceApplication v0.0.1-SNAPSHOT using Java 21.0.2 with PID 7 (/usr/src/app/build/libs/dice-0.0.1-SNAPSHOT.jar started by root in /usr/src/app)
249+
2024-03-12T17:35:55.749Z INFO 7 --- [ main] io.opentelemetry.dice.DiceApplication : No active profile set, falling back to 1 default profile: "default"
250+
2024-03-12T17:35:57.556Z INFO 7 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 5165 (http)
251+
2024-03-12T17:35:57.588Z INFO 7 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
252+
2024-03-12T17:35:57.589Z INFO 7 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.7]
253+
2024-03-12T17:35:57.667Z INFO 7 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
254+
2024-03-12T17:35:57.669Z INFO 7 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1800 ms
255+
2024-03-12T17:35:58.293Z INFO 7 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 5165 (http) with context path ''
256+
2024-03-12T17:35:58.308Z INFO 7 --- [ main] io.opentelemetry.dice.DiceApplication : Started DiceApplication in 3.459 seconds (process running for 6.305)
257+
2024-03-12T17:37:04.363Z INFO 7 --- [nio-5165-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
258+
2024-03-12T17:37:04.364Z INFO 7 --- [nio-5165-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
259+
2024-03-12T17:37:04.365Z INFO 7 --- [nio-5165-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
260+
2024-03-12T17:37:04.435Z INFO 7 --- [nio-5165-exec-1] io.opentelemetry.dice.RollController : Player 2 is rolling the dice: 2
261+
2024-03-12T17:37:04.736Z WARN 7 --- [nio-5165-exec-3] io.opentelemetry.dice.RollController : Illegal number rolled, setting result to '1'
262+
2024-03-12T17:37:04.737Z INFO 7 --- [nio-5165-exec-3] io.opentelemetry.dice.RollController : Player 2 is rolling the dice: 1
228263
```
229264
230265
```bash
@@ -234,9 +269,30 @@ Open Prometheus in the browser [localhost:8080](http://localhost:8080/graph?g0.e
234269
235270
![Metrics from Java agent from backend2-deployment](./images/prometheus_javaagent_metrics_list.jpg)
236271
237-
### Customize spans created by the auto-instrumentation
272+
### Customize Java auto-instrumentation with config (capture more data)
273+
274+
In this section we will configure the Java auto-instrumentation by modifying `Instrumentation` CR to:
275+
* create custom spans - for the main method of the application
276+
* capture server response HTTP headers
277+
278+
See the [Java agent docs](https://opentelemetry.io/docs/languages/java/automatic/configuration/) with all the configuration options.
279+
280+
See the [Instrumentation CR](./app/instrumentation-java-custom-config.yaml).
281+
282+
```bash
283+
kubectl apply -f https://raw.githubusercontent.com/pavolloffay/kubecon-eu-2024-opentelemetry-kubernetes-tracing-tutorial/main/app/instrumentation-java-custom-config.yaml
284+
kubectl rollout restart deployment.apps/backend2-deployment -n tutorial-application
285+
kubectl get pods -w -n tutorial-application
286+
```
287+
288+
![Span from backend2-deployment](./images/jaeger-capture-custom-headers.jpg)
238289
239-
In this section we will modify [Java backend2](./app/backend2) service to:
290+
### Customize Java auto-instrumentation with code (capture more data)
291+
292+
> [!NOTE]
293+
> This is an optional more advanced section.
294+
295+
In this section we will modify [Java backend2](./app/backend2) service to:
240296
* create a new span to observe execution of a business method
241297
* attach attributes to span
242298
@@ -282,23 +338,5 @@ kubectl get pods -w -n tutorial-application
282338

283339
![Span from backend2-deployment](./images/jaeger-with-span.jpg)
284340

285-
### Customize Java auto-instrumentation
286-
287-
In this section we will configure the Java auto-instrumentation by modifying `Instrumentation` CR to:
288-
* create custom spans - for the main method of the application
289-
* capture server response HTTP headers
290-
291-
See the [Java agent docs](https://opentelemetry.io/docs/languages/java/automatic/configuration/) with all the configuration options.
292-
293-
See the [Instrumentation CR](./app/instrumentation-java-custom-config.yaml).
294-
295-
```bash
296-
kubectl apply -f https://raw.githubusercontent.com/pavolloffay/kubecon-eu-2024-opentelemetry-kubernetes-tracing-tutorial/main/app/instrumentation-java-custom-config.yaml
297-
kubectl rollout restart deployment.apps/backend2-deployment -n tutorial-application
298-
kubectl get pods -w -n tutorial-application
299-
```
300-
301-
![Span from backend2-deployment](./images/jaeger-capture-custom-headers.jpg)
302-
303341
---
304342
[Next steps](./04-manual-instrumentation.md)

app/instrumentation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ spec:
1414
type: parentbased_traceidratio
1515
argument: "1"
1616
resource:
17-
addK8sUIDAttributes: false
17+
addK8sUIDAttributes: true
1818
python:
1919
env:
2020
# Required if endpoint is set to 4317.

0 commit comments

Comments
 (0)