-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Hello,
I was working on integrating Docker buildx with OpenTelemetry on Jenkins and unfortunately I couldn't use otel exec because I needed to start a new span and finish it once it had built all the Docker images.
Here is my script that create a new builder:
docker buildx create \
--use \
--bootstrap \
--name "${BUILDER_NAME}" \
--driver docker-container \
--config ./buildkitd.toml \
--driver-opt "network=host" \
--driver-opt "env.TRACEPARENT=${TRACEPARENT:-}" \
--driver-opt "env.OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:${OTEL_GRPC_PORT:-4317}" \
--driver-opt "network=host" \
--driver-opt "default-load=true"
I had to generate a new TRACEPARENT manually, as described in this guide: Caller explicitly tracing.
private def startGlobalSpan() {
// First, get a trace and span ID. We need to get one now so we can propagate it to the child
// Get trace ID from TRACEPARENT, if present
spanTid = sh(script: 'echo ${TRACEPARENT:-} | cut -d- -f2', returnStdout: true).trim()
spanTid = spanTid ?: sh(script: "LC_ALL=C tr -dc 'a-f0-9' < /dev/urandom | head -c 32", returnStdout: true).trim()
// Always generate a new span ID
spanSid = sh(script: "LC_ALL=C tr -dc 'a-f0-9' < /dev/urandom | head -c 16", returnStdout: true).trim()
def traceParent = "00-${spanTid}-${spanSid}-01"
// Get start time before executing the code
spanStart = sh(script: 'python3 -c "import time; print(time.time())"', returnStdout: true).trim()
env.TRACEPARENT = traceParent
}
It would be great if OTEL-cli supported a simpler way to create TRACEPARENT without the need to use sockets.
Best regards,
Kamil
Metadata
Metadata
Assignees
Labels
No labels