Skip to content

Commit

Permalink
docs: demo tape for initial otel
Browse files Browse the repository at this point in the history
  • Loading branch information
mxab committed Feb 9, 2024
1 parent fc446d4 commit 5b7b907
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 7 deletions.
3 changes: 1 addition & 2 deletions example/otel/example.nomad.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ job "example" {
group "demo" {
task "app" {
driver = "docker"

config {
image = "busybox:1.36.1"
args = ["/bin/sh", "-c", "env | grep OTEL_ && sleep 1h"]
args = ["/bin/sh", "-c", "env && sleep 1h"]
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions example/otel/example.nomad.ref.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ job "example" {
group "demo" {
task "app" {
driver = "docker"
meta {
otel = "true"
}
meta { otel = "true" }
config {
image = "busybox:1.36.1"
args = ["/bin/sh", "-c", "env | grep OTEL_ && sleep 1h"]
args = ["/bin/sh", "-c", "env && sleep 1h"]
}
}
}
Expand Down
64 changes: 64 additions & 0 deletions example/otel/otel-demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Output otel-demo.mp4

Require echo
Require nomad
Require vim
Require bat


Set Shell "bash"
Set FontSize 16
Set Width 1200
Set Height 600


Set TypingSpeed 100ms

Type `echo "Let's run a simple nomad job"` Enter
Type `vim demo.nomad.hcl` Enter
Set TypingSpeed 50ms
Type i

Type `job "example" {` Enter
Type ` group "demo" {` Enter
Type ` task "app" {` Enter
Type ` driver = "docker"` Enter
Type ` config {` Enter
Type ` image = "busybox:1.36.1"` Enter
Type ` args = ["/bin/sh", "-c", "env && sleep 1h"]` Enter
Type ` }` Enter
Type ` }` Enter
Type ` }` Enter
Type `}` Enter
Escape
Type `:wq` Enter
Set TypingSpeed 100ms
Sleep 2s


Type `nomad run -detach demo.nomad.hcl` Enter
Sleep 5s
Type `echo "Let's check the env vars of our job"` Enter
Type `nomad exec -job example sh -c 'env | grep OTEL_'` Enter
Sleep 1s
Type `echo "No 'OTEL_' env vars, let's update the job to enable otel"` Enter
Type `vim demo.nomad.hcl` Enter
Sleep 1s
Down Down Down Down
Type i
Enter
Up
Sleep 500ms
Type ` meta { otel = "true" }`
Sleep 500ms
Escape
Type `:wq` Enter
Sleep 1s
Type `echo "Let's run the updated job"` Enter
Type `nomad run -detach demo.nomad.hcl` Enter
Sleep 6s
Type `echo "Let's check the env vars of our job again"` Enter
Type `nomad exec -job example sh -c 'env | grep OTEL_'` Enter
Sleep 1s

Type `echo "yey, it worked!"` Enter Sleep 5s
2 changes: 1 addition & 1 deletion example/otel/otel.rego
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import rego.v1

# check for all task if they have a "Meta" field "otel" = "true"
# if it doesn't have a Templates field or its null create a patch for that

# inject the same data as mentioned here: https://github.com/hashicorp/nomad/commit/fb4887505c82346a8f9046f956530058ab92e55a#diff-ad403bc14b99a07b6bf1d5599b9109113bc30d03afd88d7c007dd55f1bdb6b2cR44
add_templates_list_ops contains op if {
some g, t
input.TaskGroups[g].Tasks[t].Meta.otel == "true"
Expand Down
7 changes: 7 additions & 0 deletions example/otel/tape.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

rm otel-demo.mp4
rm demo.nomad.hcl

export NOMAD_ADDR='http://localhost:6464'
exec vhs otel-demo.tape

0 comments on commit 5b7b907

Please sign in to comment.