Skip to content

Commit

Permalink
Added support for overriding span names (#63)
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
clintonb committed Nov 11, 2023
1 parent 3261320 commit dab6854
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ sleep_for() {
otel_trace_start_parent_span sleep_for 1
# Start a child span, associated to the parent
otel_trace_start_child_span sleep_for 2
# Start a child span with a custom name
local span_name="Sleeping"
otel_trace_start_child_span sleep_for 3

log_info "TraceId: ${OTEL_TRACE_ID}"
```
Expand Down
8 changes: 8 additions & 0 deletions library/otel_traces.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ otel_trace_start_parent_span() {
local name=$1
local span_id=$(generate_uuid 8)

if [ -n "${span_name-}" ]; then
name=$span_name
fi

local start_time_unix_nano=$(get_epoch_now)
local exit_code=0
"$@" && exit_code=$? || exit_code=$?
Expand Down Expand Up @@ -124,6 +128,10 @@ otel_trace_start_child_span() {
local name=$1
local span_id=$(generate_uuid 8)

if [ -n "${span_name-}" ]; then
name=$span_name
fi

local start_time_unix_nano=$(get_epoch_now)
local exit_code=0
"$@" && exit_code=$? || exit_code=$?
Expand Down

0 comments on commit dab6854

Please sign in to comment.