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
While playing around with this - which is super helpful, thanks! - I came up with another approach than the current demos to meet my needs.
The benefits of this is that:
No otel-cli exec, so we can use bash functions
No background, so we don't need to deal with the race issues
No tp-carrier needed either, which is not a big deal but avoids a lot of temporary files
Just wanted to share and didn't have a good way to do so, so I thought I would open an issue:
#!/bin/bashexport OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317
functiongen-uid() {
tr -dc 'a-f0-9'< /dev/urandom | head -c$1
}
# Usage: trace <span name> [command ...]functiontrace() {
# Throughout, "local" usage is critical to avoid nested calls overwriting thingslocal start="$(date -u +%s.%N)"# First, get a trace and span ID. We need to get one now so we can propogate it to the child# Get trace ID from TRACEPARENT, if presentlocal tid="$(<<<${TRACEPARENT:-} cut -d- -f2)"
tid="${tid:-"$(gen-uid 32)"}"# Always generate a new span IDlocal sid="$(gen-uid 16)"# Execute the command they wanted with the propogation through TRACEPARENT
TRACEPARENT="00-${tid}-${sid}-01""${@:2}"local end="$(date -u +%s.%N)"# Now report this span. We override the IDs to the ones we set before.# TODO: support attributes
otel-cli span \
--service "test2" \
--name "$1" \
--start "$start" \
--end "$end" \
--force-trace-id "$tid" \
--force-span-id "$sid"
}
functionnested() {
trace "child1" sleep .1
trace "child2" sleep .2
trace "deep" deep
}
functiondeep() {
trace "in-deep" sleep .1
}
trace "parent" nested
I am happy to close this immediately as an "FYI", send it to demos/, etc, whatever.
The text was updated successfully, but these errors were encountered:
While playing around with this - which is super helpful, thanks! - I came up with another approach than the current demos to meet my needs.
The benefits of this is that:
otel-cli exec
, so we can use bash functionsbackground
, so we don't need to deal with the race issuestp-carrier
needed either, which is not a big deal but avoids a lot of temporary filesJust wanted to share and didn't have a good way to do so, so I thought I would open an issue:
I am happy to close this immediately as an "FYI", send it to demos/, etc, whatever.
The text was updated successfully, but these errors were encountered: