diff --git a/scripts/run_docker_compare.bash b/scripts/run_docker_compare.bash index a4f1236..f316406 100755 --- a/scripts/run_docker_compare.bash +++ b/scripts/run_docker_compare.bash @@ -5,6 +5,8 @@ IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${SHELL:="NO"} # or YES to launch a shell instead of running the test +: ${TRACE:="NO"} # or YES to send traces to jaeger +: ${BACKTRACE:="NO"} # or YES to print a rust backtrace when panicking cd "$DIR/../" REALPATH=$(command -v uu-realpath || command -v realpath) @@ -29,7 +31,6 @@ function launch_container { set -euo pipefail IFS=\$'\n\t' -export CARGO_TARGET_DIR=/target cargo run -- /input.org EOF ) @@ -40,9 +41,16 @@ EOF additional_flags+=(-i -t) fi - # TODO: add support for reporting to jaeger with RUST_BACKTRACE=1 RUST_LOG=debug + if [ "$TRACE" = "YES" ]; then + # We use the host network so it can talk to jaeger hosted at 127.0.0.1 + additional_flags+=(--network=host --env RUST_LOG=debug) + fi - docker run "${additional_flags[@]}" --rm -v "${org_file}:/input.org:ro" -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target -w /source organic-test "${additional_args[@]}" + if [ "$BACKTRACE" = "YES" ]; then + additional_flags+=(--env RUST_BACKTRACE=full) + fi + + docker run "${additional_flags[@]}" --rm -v "${org_file}:/input.org:ro" -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test "${additional_args[@]}" } main "${@}" diff --git a/scripts/run_docker_integration_test.bash b/scripts/run_docker_integration_test.bash index 4285fcc..0f66eae 100755 --- a/scripts/run_docker_integration_test.bash +++ b/scripts/run_docker_integration_test.bash @@ -46,12 +46,11 @@ function launch_container { set -euo pipefail IFS=\$'\n\t' -export CARGO_TARGET_DIR=/target cargo test --no-fail-fast --lib --test test_loader "$test" -- --show-output EOF ) - docker run --rm -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target -w /source organic-test sh -c "$init_script" + docker run --rm -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test sh -c "$init_script" } diff --git a/src/init_tracing.rs b/src/init_tracing.rs index 17b71f4..9b72926 100644 --- a/src/init_tracing.rs +++ b/src/init_tracing.rs @@ -15,7 +15,8 @@ pub fn init_telemetry() -> Result<(), Box> { // TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned. let exporter = opentelemetry_otlp::new_exporter() .tonic() - .with_endpoint("http://localhost:4317/v1/traces"); + // Using "localhost" is broken inside the docker container when tracing + .with_endpoint("http://127.0.0.1:4317/v1/traces"); let tracer = opentelemetry_otlp::new_pipeline() .tracing()