diff --git a/example/otel/example.nomad.hcl b/example/otel/example.nomad.hcl index c38a397..80c1415 100644 --- a/example/otel/example.nomad.hcl +++ b/example/otel/example.nomad.hcl @@ -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"] } } } diff --git a/example/otel/example.nomad.ref.hcl b/example/otel/example.nomad.ref.hcl index a3b1bd3..f0f6829 100644 --- a/example/otel/example.nomad.ref.hcl +++ b/example/otel/example.nomad.ref.hcl @@ -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"] } } } diff --git a/example/otel/otel-demo.tape b/example/otel/otel-demo.tape new file mode 100644 index 0000000..286d823 --- /dev/null +++ b/example/otel/otel-demo.tape @@ -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 diff --git a/example/otel/otel.rego b/example/otel/otel.rego index a549508..e3880e4 100644 --- a/example/otel/otel.rego +++ b/example/otel/otel.rego @@ -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" diff --git a/example/otel/tape.sh b/example/otel/tape.sh new file mode 100755 index 0000000..afa0e9c --- /dev/null +++ b/example/otel/tape.sh @@ -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