Skip to content

Commit

Permalink
backend: add deployment to replace backend2
Browse files Browse the repository at this point in the history
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
  • Loading branch information
frzifus committed Mar 11, 2024
1 parent 7c087b2 commit 8cde4cf
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
4 changes: 2 additions & 2 deletions 04-manual-instrumentation.md
Expand Up @@ -75,7 +75,7 @@ docker run --rm -it -p 127.0.0.1:4317:4317 -p 127.0.0.1:16686:16686 -e COLLECTOR
```

```bash
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 OTEL_SERVICE_NAME=go-backend go run app/backend4/main.go
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 OTEL_SERVICE_NAME=go-backend RATE_ERROR=20 RATE_HIGH_DELAY=20 go run app/backend4/main.go
```

## TODO: Publish container at ghcr.io/pavolloffay
Expand All @@ -87,7 +87,7 @@ kubectl apply -f https://raw.githubusercontent.com/pavolloffay/kubecon-eu-2024-o

Details

```yaml
```diff
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
2 changes: 1 addition & 1 deletion 05-sampling.md
Expand Up @@ -58,7 +58,7 @@ Tail sampling is where the decision to sample a trace takes place by considering
Update the ENV variables below in the backend2 deployment, which generates random spans with errors and latencies

```shell
kubectl set env deployment backend2-deployment ERROR_RATE=50 RATE_HIGH_DELAY=50 -n tutorial-application
kubectl set env deployment backend2-deployment RATE_ERROR=50 RATE_HIGH_DELAY=50 -n tutorial-application
kubectl get pods -n tutorial-application -w
```

Expand Down
2 changes: 1 addition & 1 deletion app/backend4/main.go
Expand Up @@ -51,7 +51,7 @@ func main() {
tp := sdktrace.NewTracerProvider(sdktrace.WithBatcher(otelExporter))
otel.SetTracerProvider(tp)

v, ok := os.LookupEnv("ERROR_RATE")
v, ok := os.LookupEnv("RATE_ERROR")
if !ok {
v = "0"
}
Expand Down
38 changes: 38 additions & 0 deletions backend/04-backend.yaml
@@ -0,0 +1,38 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend2-deployment
namespace: tutorial-application
labels:
app: backend2
spec:
replicas: 1
selector:
matchLabels:
app: backend2
template:
metadata:
labels:
app: backend2
annotations:
prometheus.io/scrape: "true"
instrumentation.opentelemetry.io/inject-sdk: "true"
spec:
containers:
- name: backend2
# TODO: switch to ghcr.io/pavolloffay
# https://github.com/users/frzifus/packages/container/package/kubecon-eu-2024-opentelemetry-kubernetes-tracing-tutorial-backend4
image: ghcr.io/frzifus/kubecon-eu-2024-opentelemetry-kubernetes-tracing-tutorial-backend4:with-instr
ports:
- containerPort: 5165
env:
- name: RATE_ERROR
value: 20
- name: RATE_HIGH_DELAY
value: 20
# NOTE: alternative to instrumentation annotation
# - name: OTEL_EXPORTER_OTLP_ENDPOINT
# value: http://otel-collector.observability-backend.svc.cluster.local:4317
# - name: OTEL_SERVICE_NAME
# value: go-backend

0 comments on commit 8cde4cf

Please sign in to comment.