Skip to content

Commit e66faf1

Browse files
authored
Merge pull request #5 from xenOs76/feature/add_tracing
add tracing
2 parents 7c375f1 + 770c747 commit e66faf1

24 files changed

+711
-46
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.direnv
22
dist
3+
etc
34
tmp
45
.idea
56
.vscode
7+
tempo-data
8+
docker-compose/tempo-data

LICENSE

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
MIT License
22

3-
Copyright (c) 2025 xenOs76
3+
Copyright (c) 2025 xeno@os76.xyz
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

chart/ledlighter/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: ledlighter
33
description: ledlighter, a proxy for LED APIs
44
type: application
5-
version: 0.1.1
6-
appVersion: "0.0.2"
5+
version: 0.1.2
6+
appVersion: "0.0.3"

chart/ledlighter/templates/deployment.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ spec:
1313
{{- include "ledlighter.selectorLabels" . | nindent 6 }}
1414
template:
1515
metadata:
16-
{{- with .Values.podAnnotations }}
1716
annotations:
17+
{{- with .Values.podAnnotations }}
1818
{{- toYaml . | nindent 8 }}
1919
{{- end }}
20+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
2021
labels:
2122
{{- include "ledlighter.labels" . | nindent 8 }}
2223
{{- with .Values.podLabels }}
@@ -63,6 +64,23 @@ spec:
6364
volumeMounts:
6465
{{- toYaml . | nindent 12 }}
6566
{{- end }}
67+
env:
68+
{{- if .Values.otel.enable }}
69+
{{- with .Values.otel }}
70+
- name: OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
71+
value: {{ .otlpProtocol }}
72+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
73+
value: {{ .otlpEndpoint }}
74+
- name: OTEL_EXPORTER_OTLP_METRICS_PROTOCOL
75+
value: {{ .otlpMetricsProcotol }}
76+
- name: OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
77+
value: {{ .otlpMetricsEndpoint }}
78+
- name: OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
79+
value: {{ .otlpTracesProcotol }}
80+
- name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
81+
value: {{ .otlpTracesEndpoint }}
82+
{{- end }}
83+
{{- end }}
6684
{{- with .Values.volumes }}
6785
volumes:
6886
{{- toYaml . | nindent 8 }}

chart/ledlighter/templates/servicemonitor.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
{{ if .Values.prometheus.serviceMonitor.enabled }}
2+
{{ if .Values.prometheus.serviceMonitor.enable }}
33
apiVersion: monitoring.coreos.com/v1
44
kind: ServiceMonitor
55
metadata:
@@ -25,4 +25,3 @@ spec:
2525
{{- toYaml . | nindent 6 }}
2626
{{- end }}
2727
{{ end }}
28-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if .Values.appConfig.enableTraces }}
2+
apiVersion: telemetry.istio.io/v1
3+
kind: Telemetry
4+
metadata:
5+
name: {{ include "ledlighter.fullname" . }}-traces
6+
spec:
7+
selector:
8+
matchLabels:
9+
{{- with .Values.additionalLabels }}
10+
{{- toYaml . | nindent 6 }}
11+
{{- end }}
12+
tracing:
13+
- randomSamplingPercentage: {{ .Values.otel.tracing.randomSamplingPercentage | default "50" }}
14+
providers:
15+
- name: {{ .Values.otel.tracing.providerName | default "otel" }}
16+
customTags:
17+
istio_telemetry_tag:
18+
literal:
19+
value: {{ include "ledlighter.fullname" . }}
20+
{{- end }}

chart/ledlighter/values-for-gitea.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
image:
33
repository: registry.0.os76.xyz/xeno/ledlighter
44
pullPolicy: IfNotPresent
5-
tag: 0.0.12
5+
tag: 0.0.14
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# OpenTelemetry env variables
3+
#
4+
otel:
5+
enable: true
6+
otlpProtocol: grpc
7+
otlpEndpoint: zero.os76.xyz:4317
8+
otlpMetricsProcotol: http/protobuf
9+
otlpMetricsEndpoint: http://zero.os76.xyz:4318/v1/metrics
10+
otlpTracesProcotol: http/protobuf
11+
otlpTracesEndpoint: http://zero.os76.xyz:4318/v1/traces

chart/ledlighter/values.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ additionalLabels:
1919
# and volume mounts
2020
#
2121
appConfig:
22+
enableTraces: true
2223
leds:
2324
- id: 0
2425
description: "RGB strip, below desk's shelves"
@@ -83,11 +84,25 @@ istio:
8384
- istio-system/gateway-priv-os76
8485

8586
#
87+
# OpenTelemetry env variables
88+
#
89+
otel:
90+
enable: true
91+
otlpProtocol: grpc
92+
otlpEndpoint: opentelemetry-collector.monitoring:4317
93+
otlpMetricsProcotol: http/protobuf
94+
otlpMetricsEndpoint: http://opentelemetry-collector.monitoring:4318/v1/metrics
95+
otlpTracesProcotol: http/protobuf
96+
otlpTracesEndpoint: http://opentelemetry-collector.monitoring:4318/v1/traces
97+
tracing:
98+
randomSamplingPercentage: 100
99+
providerName: otel
100+
#
86101
# Prometheus
87102
#
88103
prometheus:
89104
serviceMonitor:
90-
enabled: true
105+
enable: true
91106
namespace: monitoring
92107
namespaceSelector:
93108
matchNames:

docker-compose-tempo.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#
2+
# Refs:
3+
# https://github.com/riandyrn/otelchi/tree/master/examples/multi-services
4+
# https://github.com/grafana/tempo/tree/main/example/docker-compose/local
5+
#
6+
7+
networks:
8+
custom_net:
9+
driver: bridge
10+
ipam:
11+
config:
12+
- subnet: 10.5.0.0/16
13+
gateway: 10.5.0.1
14+
15+
services:
16+
app:
17+
build: .
18+
restart: always
19+
ports:
20+
# http
21+
- "3080:3080"
22+
# metrics
23+
- "3088:3088"
24+
volumes:
25+
- type: bind
26+
source: ./docker-compose/ledlighter-config.yaml
27+
target: /config.yaml
28+
read_only: true
29+
environment:
30+
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
31+
- OTEL_EXPORTER_OTLP_ENDPOINT=tempo:4317
32+
- OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
33+
- OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://tempo:4318/v1/metrics
34+
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
35+
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://tempo:4318/v1/traces
36+
networks:
37+
- custom_net
38+
39+
echo-server:
40+
image: ealen/echo-server:0.9.2
41+
ports:
42+
- 3002:80
43+
networks:
44+
custom_net:
45+
ipv4_address: 10.5.0.99
46+
47+
# Tempo runs as user 10001, and docker compose creates the volume as root.
48+
# As such, we need to chown the volume in order for Tempo to start correctly.
49+
init:
50+
image: &tempoImage grafana/tempo:latest
51+
user: root
52+
entrypoint:
53+
- "chmod"
54+
- "777"
55+
- "/var/tempo"
56+
volumes:
57+
- ./tempo-data:/var/tempo
58+
networks:
59+
- custom_net
60+
61+
memcached:
62+
image: memcached:1.6.38
63+
container_name: memcached
64+
ports:
65+
- "11211:11211"
66+
environment:
67+
- MEMCACHED_MAX_MEMORY=64m # Set the maximum memory usage
68+
- MEMCACHED_THREADS=4 # Number of threads to use
69+
networks:
70+
- custom_net
71+
72+
tempo:
73+
image: *tempoImage
74+
command: ["-config.file=/etc/tempo.yaml"]
75+
volumes:
76+
- ./docker-compose/tempo.yaml:/etc/tempo.yaml
77+
- ./tempo-data:/var/tempo
78+
ports:
79+
- "14268:14268" # jaeger ingest
80+
- "3200:3200" # tempo
81+
- "9095:9095" # tempo grpc
82+
- "4317:4317" # otlp grpc
83+
- "4318:4318" # otlp http
84+
- "9411:9411" # zipkin
85+
depends_on:
86+
- init
87+
- memcached
88+
networks:
89+
- custom_net
90+
91+
prometheus:
92+
image: prom/prometheus:latest
93+
command:
94+
- --config.file=/etc/prometheus.yml
95+
- --web.enable-remote-write-receiver
96+
- --enable-feature=exemplar-storage
97+
- --enable-feature=native-histograms
98+
ports:
99+
- 9090:9090
100+
volumes:
101+
- ./docker-compose/prometheus.yml:/etc/prometheus.yml
102+
networks:
103+
- custom_net
104+
105+
grafana:
106+
image: grafana/grafana:12.0.2
107+
volumes:
108+
- ./docker-compose/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
109+
environment:
110+
- GF_AUTH_ANONYMOUS_ENABLED=true
111+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
112+
- GF_AUTH_DISABLE_LOGIN_FORM=true
113+
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
114+
ports:
115+
- "3001:3000"
116+
networks:
117+
- custom_net

0 commit comments

Comments
 (0)