You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Golden files](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/golden) are YAML representation
4
+
of OpenTelemetry signals.
5
+
6
+
Golden files are used in conjunction with the [cmd/golden](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/golden) utility
7
+
which can listen for OTLP traffic and compare it to incoming traffic. If the input matches the golden file, the program
8
+
exits with code 0, and exits with code 1 otherwise.
9
+
10
+
## Update Golden files
11
+
12
+
Golden files are typically not managed by hand. We use a feature of the golden command to capture input and write it to file.
13
+
14
+
To do so, in the docker-compose.yaml file, uncomment the parameter `--write-expected` and delete the data/expected.yaml file.
15
+
16
+
Run the Docker compose setup with (replacing VERSION with the right version to test for):
17
+
```shell
18
+
MY_UID="$(id -u)" MY_GID="$(id -g)" IMG=ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:VERSION docker-compose up -d --wait
19
+
```
20
+
21
+
Check in on your docker compose:
22
+
23
+
```shell
24
+
$> docker ps -a
25
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
26
+
4716ece9c21e ghcr.io/open-telemetry/opentelemetry-collector-contrib/golden:latest "/golden --expected …" About a minute ago Exited (0) About a minute ago golden
27
+
13e72a5f997d ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.139.0 "/otelcol-contrib --…" About a minute ago Up About a minute 4317-4318/tcp, 55679/tcp collector
28
+
```
29
+
30
+
Note how golden exited with code 0, meaning it managed to perform its function.
31
+
32
+
The golden utility will write the file to disk, and you can add it via git to make a diff and understand the changes.
33
+
34
+
Make a PR with the changes ; CI runs the same steps and will check the match works.
0 commit comments