diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 56808422d..31aba491f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,153 +1,154 @@ name: Build and push docker image to ghcr on: - workflow_dispatch: - push: - branches: - - 'main' - tags: - - 'v*' + workflow_dispatch: + push: + branches: + - "main" + - "otel-fixups" + tags: + - "v*" jobs: - build-and-push-image: - concurrency: - group: ${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - runs-on: a100-runner - permissions: - contents: write - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - security-events: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: true - dotnet: true - haskell: true - large-packages: false - swap-storage: true - - - name: Install soci - uses: lerentis/soci-installer@v1.0.1 - with: - soci-release: 'v0.4.0' - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2.10.0 - - - name: Set up containerd for ubuntu - uses: crazy-max/ghaction-setup-containerd@v2.2.0 - with: - config-inline: | - version = 2 - - # persistent data location - root = "/runner/build/containerd" - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/predibase/lorax - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha,prefix=,suffix=,format=short - type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} - - - name: Create a hash from tags - env: - tags: ${{ steps.meta.outputs.tags }} - id: vars - run: | - tag_hash=$(echo -n "$tags" | md5sum | awk '{print $1}') - echo "tag_hash=$tag_hash" >> $GITHUB_OUTPUT - echo "cache_dir=/runner/build/images/cache" >> $GITHUB_OUTPUT - echo "image_dir=/runner/build/images" >> $GITHUB_OUTPUT - echo "image_path=/runner/build/images/lorax" >> $GITHUB_OUTPUT - - - name: Create and update image/cache directory - env: - image_dir: ${{ steps.vars.outputs.image_dir }} - cache_dir: ${{ steps.vars.outputs.cache_dir }} - run: | - sudo mkdir -p $image_dir - sudo chown ubuntu:ubuntu $image_dir - - sudo mkdir -p $cache_dir - sudo chown ubuntu:ubuntu $cache_dir - - - name: Export Docker image as OCI - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile # Path to your Dockerfile - push: false - tags: ${{ steps.meta.outputs.tags }} - outputs: type=oci,compression=gzip,dest=${{ steps.vars.outputs.image_path }}-${{ steps.vars.outputs.tag_hash }}.tar.gz - cache-from: type=local,src=${{ steps.vars.outputs.cache_dir }} - cache-to: type=local,mode=max,image-manifest=true,oci-mediatypes=true,dest=${{ steps.vars.outputs.cache_dir }} - - - name: Import image in containerd - env: - tag_hash: ${{ steps.vars.outputs.tag_hash }} - image_path: ${{ steps.vars.outputs.image_path }} - run: | - echo "Importing $image_path-$tag_hash to Containerd" - sudo ctr i import --no-unpack --all-platforms --digests $image_path-$tag_hash.tar.gz - - - name: Log in to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_PAT }} - - - name: Push image with containerd - env: - tags: ${{ steps.meta.outputs.tags }} - run: | - for tag in $tags - do - echo "Pushing $tag to GHCR" - sudo ctr i push --user "${{ github.repository_owner }}:${{ secrets.GHCR_PAT }}" $tag - done - - - name: Create and push soci index - env: - tags: ${{ steps.meta.outputs.tags }} - run: | - export SOCI_PATH=$HOME/.soci/soci - for tag in $tags - do - echo "Creating soci index for $tag" - sudo $SOCI_PATH create $tag - echo "Pushing soci index for $tag" - sudo $SOCI_PATH push --user ${{ github.repository_owner }}:${{ secrets.GHCR_PAT }} $tag - done - - - name: Prune older images - env: - tag_hash: ${{ steps.vars.outputs.tag_hash }} - image_path: ${{ steps.vars.outputs.image_path }} - run: | - # Delete images older than a day from docker store - docker image prune -a -f --filter "until=24h" - - # Delete the on disk copy - rm -rf "$image_path-$tag_hash.tar.gz" - - # Delete the SHA image(s) from containerd store - sudo ctr i rm $(sudo ctr i ls -q) + build-and-push-image: + concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + runs-on: a100-runner + permissions: + contents: write + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + android: true + dotnet: true + haskell: true + large-packages: false + swap-storage: true + + - name: Install soci + uses: lerentis/soci-installer@v1.0.1 + with: + soci-release: "v0.4.0" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2.10.0 + + - name: Set up containerd for ubuntu + uses: crazy-max/ghaction-setup-containerd@v2.2.0 + with: + config-inline: | + version = 2 + + # persistent data location + root = "/runner/build/containerd" + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/predibase/lorax + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix=,suffix=,format=short + type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} + + - name: Create a hash from tags + env: + tags: ${{ steps.meta.outputs.tags }} + id: vars + run: | + tag_hash=$(echo -n "$tags" | md5sum | awk '{print $1}') + echo "tag_hash=$tag_hash" >> $GITHUB_OUTPUT + echo "cache_dir=/runner/build/images/cache" >> $GITHUB_OUTPUT + echo "image_dir=/runner/build/images" >> $GITHUB_OUTPUT + echo "image_path=/runner/build/images/lorax" >> $GITHUB_OUTPUT + + - name: Create and update image/cache directory + env: + image_dir: ${{ steps.vars.outputs.image_dir }} + cache_dir: ${{ steps.vars.outputs.cache_dir }} + run: | + sudo mkdir -p $image_dir + sudo chown ubuntu:ubuntu $image_dir + + sudo mkdir -p $cache_dir + sudo chown ubuntu:ubuntu $cache_dir + + - name: Export Docker image as OCI + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile # Path to your Dockerfile + push: false + tags: ${{ steps.meta.outputs.tags }} + outputs: type=oci,compression=gzip,dest=${{ steps.vars.outputs.image_path }}-${{ steps.vars.outputs.tag_hash }}.tar.gz + cache-from: type=local,src=${{ steps.vars.outputs.cache_dir }} + cache-to: type=local,mode=max,image-manifest=true,oci-mediatypes=true,dest=${{ steps.vars.outputs.cache_dir }} + + - name: Import image in containerd + env: + tag_hash: ${{ steps.vars.outputs.tag_hash }} + image_path: ${{ steps.vars.outputs.image_path }} + run: | + echo "Importing $image_path-$tag_hash to Containerd" + sudo ctr i import --no-unpack --all-platforms --digests $image_path-$tag_hash.tar.gz + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_PAT }} + + - name: Push image with containerd + env: + tags: ${{ steps.meta.outputs.tags }} + run: | + for tag in $tags + do + echo "Pushing $tag to GHCR" + sudo ctr i push --user "${{ github.repository_owner }}:${{ secrets.GHCR_PAT }}" $tag + done + + - name: Create and push soci index + env: + tags: ${{ steps.meta.outputs.tags }} + run: | + export SOCI_PATH=$HOME/.soci/soci + for tag in $tags + do + echo "Creating soci index for $tag" + sudo $SOCI_PATH create $tag + echo "Pushing soci index for $tag" + sudo $SOCI_PATH push --user ${{ github.repository_owner }}:${{ secrets.GHCR_PAT }} $tag + done + + - name: Prune older images + env: + tag_hash: ${{ steps.vars.outputs.tag_hash }} + image_path: ${{ steps.vars.outputs.image_path }} + run: | + # Delete images older than a day from docker store + docker image prune -a -f --filter "until=24h" + + # Delete the on disk copy + rm -rf "$image_path-$tag_hash.tar.gz" + + # Delete the SHA image(s) from containerd store + sudo ctr i rm $(sudo ctr i ls -q) diff --git a/Cargo.lock b/Cargo.lock index 281d0be98..bbc26aeed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -225,18 +225,20 @@ dependencies = [ [[package]] name = "axum-tracing-opentelemetry" -version = "0.10.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164b95427e83b79583c7699a72b4a6b485a12bbdef5b5c054ee5ff2296d82f52" +checksum = "06985105829f176e9a3f113b1c71cc24e08f600ef0df4e70cd90d144f889e19f" dependencies = [ "axum", - "futures", + "futures-core", + "futures-util", "http", - "opentelemetry 0.18.0", + "opentelemetry 0.20.0", + "pin-project-lite", "tower", - "tower-http 0.3.5", "tracing", - "tracing-opentelemetry 0.18.0", + "tracing-opentelemetry 0.21.0", + "tracing-opentelemetry-instrumentation-sdk", ] [[package]] @@ -873,6 +875,12 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "grpc-metadata" version = "0.1.0" @@ -885,9 +893,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -895,7 +903,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.0.0", "slab", "tokio", "tokio-util", @@ -1129,6 +1137,23 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "init-tracing-opentelemetry" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f12893a5f71a99623566df4ec1811a3b0d38a103b0792741aec0688663f042" +dependencies = [ + "opentelemetry 0.23.0", + "opentelemetry-otlp 0.16.0", + "opentelemetry-resource-detectors", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk 0.23.0", + "thiserror", + "tracing", + "tracing-opentelemetry 0.24.0", + "tracing-subscriber", +] + [[package]] name = "instant" version = "0.1.12" @@ -1240,7 +1265,7 @@ version = "0.1.0" dependencies = [ "futures", "grpc-metadata", - "prost", + "prost 0.11.9", "prost-build", "regex", "thiserror", @@ -1280,6 +1305,7 @@ dependencies = [ "flume", "futures", "hf-hub", + "init-tracing-opentelemetry", "itertools 0.12.1", "lorax-client", "metrics", @@ -1290,7 +1316,7 @@ dependencies = [ "nohash-hasher", "once_cell", "opentelemetry 0.19.0", - "opentelemetry-otlp", + "opentelemetry-otlp 0.12.0", "rand", "regex", "reqwest", @@ -1301,7 +1327,7 @@ dependencies = [ "thiserror", "tokenizers", "tokio", - "tower-http 0.4.1", + "tower-http", "tracing", "tracing-opentelemetry 0.19.0", "tracing-subscriber", @@ -1766,22 +1792,61 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d6c3d7288a106c0a363e4b0e8d308058d56902adefb16f4936f417ffef086e" +checksum = "5f4b8347cc26099d3aeee044065ecc3ae11469796b4d65d065a23a584ed92a6f" dependencies = [ - "opentelemetry_api 0.18.0", - "opentelemetry_sdk 0.18.0", + "opentelemetry_api 0.19.0", + "opentelemetry_sdk 0.19.0", ] [[package]] name = "opentelemetry" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4b8347cc26099d3aeee044065ecc3ae11469796b4d65d065a23a584ed92a6f" +checksum = "9591d937bc0e6d2feb6f71a559540ab300ea49955229c347a517a28d27784c54" dependencies = [ - "opentelemetry_api 0.19.0", - "opentelemetry_sdk 0.19.0", + "opentelemetry_api 0.20.0", + "opentelemetry_sdk 0.20.0", +] + +[[package]] +name = "opentelemetry" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" +dependencies = [ + "futures-core", + "futures-sink", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", +] + +[[package]] +name = "opentelemetry-http" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7594ec0e11d8e33faf03530a4c49af7064ebba81c1480e01be67d90b356508b" +dependencies = [ + "async-trait", + "bytes", + "http", + "opentelemetry_api 0.20.0", +] + +[[package]] +name = "opentelemetry-http" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0ba633e55c5ea6f431875ba55e71664f2fa5d3a90bd34ec9302eecc41c865dd" +dependencies = [ + "async-trait", + "bytes", + "http", + "opentelemetry 0.23.0", + "reqwest", ] [[package]] @@ -1795,13 +1860,33 @@ dependencies = [ "futures-util", "http", "opentelemetry 0.19.0", - "opentelemetry-proto", - "prost", + "opentelemetry-proto 0.2.0", + "prost 0.11.9", "thiserror", "tokio", "tonic 0.8.3", ] +[[package]] +name = "opentelemetry-otlp" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94c69209c05319cdf7460c6d4c055ed102be242a0a6245835d7bc42c6ec7f54" +dependencies = [ + "async-trait", + "futures-core", + "http", + "opentelemetry 0.23.0", + "opentelemetry-http 0.12.0", + "opentelemetry-proto 0.6.0", + "opentelemetry_sdk 0.23.0", + "prost 0.12.6", + "reqwest", + "thiserror", + "tokio", + "tonic 0.11.0", +] + [[package]] name = "opentelemetry-proto" version = "0.2.0" @@ -1811,36 +1896,65 @@ dependencies = [ "futures", "futures-util", "opentelemetry 0.19.0", - "prost", + "prost 0.11.9", "tonic 0.8.3", ] +[[package]] +name = "opentelemetry-proto" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162" +dependencies = [ + "opentelemetry 0.23.0", + "opentelemetry_sdk 0.23.0", + "prost 0.12.6", + "tonic 0.11.0", +] + +[[package]] +name = "opentelemetry-resource-detectors" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5cd98b7277913e22e95b6fd3a5f7413438005471a6e33e8a4ae7b9a20be36ad" +dependencies = [ + "opentelemetry 0.23.0", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk 0.23.0", +] + +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1869fb4bb9b35c5ba8a1e40c9b128a7b4c010d07091e864a29da19e4fe2ca4d7" + [[package]] name = "opentelemetry_api" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24f96e21e7acc813c7a8394ee94978929db2bcc46cf6b5014fc612bf7760c22" +checksum = "ed41783a5bf567688eb38372f2b7a8530f5a607a4b49d38dd7573236c23ca7e2" dependencies = [ "fnv", "futures-channel", "futures-util", "indexmap 1.9.3", - "js-sys", "once_cell", "pin-project-lite", "thiserror", + "urlencoding", ] [[package]] name = "opentelemetry_api" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed41783a5bf567688eb38372f2b7a8530f5a607a4b49d38dd7573236c23ca7e2" +checksum = "8a81f725323db1b1206ca3da8bb19874bbd3f57c3bcd59471bfb04525b265b9b" dependencies = [ - "fnv", "futures-channel", "futures-util", "indexmap 1.9.3", + "js-sys", "once_cell", "pin-project-lite", "thiserror", @@ -1849,9 +1963,9 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca41c4933371b61c2a2f214bf16931499af4ec90543604ec828f7a625c09113" +checksum = "8b3a2a91fdbfdd4d212c0dcc2ab540de2c2bcbbd90be17de7a7daf8822d010c1" dependencies = [ "async-trait", "crossbeam-channel", @@ -1861,7 +1975,7 @@ dependencies = [ "futures-executor", "futures-util", "once_cell", - "opentelemetry_api 0.18.0", + "opentelemetry_api 0.19.0", "percent-encoding", "rand", "thiserror", @@ -1871,19 +1985,41 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b3a2a91fdbfdd4d212c0dcc2ab540de2c2bcbbd90be17de7a7daf8822d010c1" +checksum = "fa8e705a0612d48139799fcbaba0d4a90f06277153e43dd2bdc16c6f0edd8026" dependencies = [ "async-trait", "crossbeam-channel", - "dashmap", - "fnv", "futures-channel", "futures-executor", "futures-util", "once_cell", - "opentelemetry_api 0.19.0", + "opentelemetry_api 0.20.0", + "ordered-float 3.9.2", + "percent-encoding", + "rand", + "regex", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "opentelemetry_sdk" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" +dependencies = [ + "async-trait", + "futures-channel", + "futures-executor", + "futures-util", + "glob", + "lazy_static", + "once_cell", + "opentelemetry 0.23.0", + "ordered-float 4.2.2", "percent-encoding", "rand", "thiserror", @@ -1897,6 +2033,24 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "3.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ordered-float" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a91171844676f8c7990ce64959210cd2eaef32c2612c50f9fae9f8aaa6065a6" +dependencies = [ + "num-traits", +] + [[package]] name = "overload" version = "0.1.1" @@ -2073,7 +2227,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive 0.12.6", ] [[package]] @@ -2090,7 +2254,7 @@ dependencies = [ "multimap", "petgraph", "prettyplease", - "prost", + "prost 0.11.9", "prost-types", "regex", "syn 1.0.109", @@ -2111,13 +2275,26 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", ] [[package]] @@ -3059,8 +3236,8 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost", - "prost-derive", + "prost 0.11.9", + "prost-derive 0.11.9", "tokio", "tokio-stream", "tokio-util", @@ -3090,7 +3267,34 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost", + "prost 0.11.9", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.2", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost 0.12.6", "tokio", "tokio-stream", "tower", @@ -3132,25 +3336,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" -dependencies = [ - "bitflags 1.3.2", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tower-http" version = "0.4.1" @@ -3237,17 +3422,14 @@ dependencies = [ ] [[package]] -name = "tracing-opentelemetry" -version = "0.18.0" +name = "tracing-log" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ebb87a95ea13271332df069020513ab70bdb5637ca42d6e492dc3bbbad48de" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ + "log", "once_cell", - "opentelemetry 0.18.0", - "tracing", "tracing-core", - "tracing-log", - "tracing-subscriber", ] [[package]] @@ -3260,8 +3442,55 @@ dependencies = [ "opentelemetry 0.19.0", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.1.3", + "tracing-subscriber", +] + +[[package]] +name = "tracing-opentelemetry" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75327c6b667828ddc28f5e3f169036cb793c3f588d83bf0f262a7f062ffed3c8" +dependencies = [ + "once_cell", + "opentelemetry 0.20.0", + "opentelemetry_sdk 0.20.0", + "smallvec", + "tracing", + "tracing-core", + "tracing-log 0.1.3", + "tracing-subscriber", +] + +[[package]] +name = "tracing-opentelemetry" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f68803492bf28ab40aeccaecc7021096bd256baf7ca77c3d425d89b35a7be4e4" +dependencies = [ + "js-sys", + "once_cell", + "opentelemetry 0.23.0", + "opentelemetry_sdk 0.23.0", + "smallvec", + "tracing", + "tracing-core", + "tracing-log 0.2.0", "tracing-subscriber", + "web-time", +] + +[[package]] +name = "tracing-opentelemetry-instrumentation-sdk" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f523eba1b52bb854b804d43a039aafeaee5a623015065adbfef8016825319c15" +dependencies = [ + "http", + "opentelemetry-http 0.9.0", + "opentelemetry_api 0.20.0", + "tracing", + "tracing-opentelemetry 0.21.0", ] [[package]] @@ -3291,7 +3520,7 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.1.3", "tracing-serde", ] @@ -3607,6 +3836,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki" version = "0.22.0" diff --git a/router/Cargo.toml b/router/Cargo.toml index a8d94d2fb..8e7706d2c 100644 --- a/router/Cargo.toml +++ b/router/Cargo.toml @@ -17,7 +17,7 @@ path = "src/main.rs" [dependencies] async-stream = "0.3.3" axum = { version = "0.6.4", features = ["json"] } -axum-tracing-opentelemetry = "0.10.0" +axum-tracing-opentelemetry = "0.14.1" lorax-client = { path = "client" } clap = { version = "4.1.4", features = ["derive", "env"] } flume = "0.10.14" @@ -50,6 +50,7 @@ itertools = "0.12.1" async-trait = "0.1.80" minijinja = { version = "2.0.2" } minijinja-contrib = { version = "2.0.2", features = ["pycompat"] } +init-tracing-opentelemetry = { version = "0.19.0", features = ["tracing_subscriber_ext"] } [build-dependencies] vergen = { version = "8.0.0", features = ["build", "git", "gitcl"] } diff --git a/router/src/main.rs b/router/src/main.rs index 9282998e8..764b9a992 100644 --- a/router/src/main.rs +++ b/router/src/main.rs @@ -15,7 +15,6 @@ use std::fs::File; use std::io::BufReader; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::path::{Path, PathBuf}; -use std::sync::Arc; use thiserror::Error; use tokenizers::processors::template::TemplateProcessing; use tokenizers::tokenizer::Tokenizer; @@ -509,7 +508,6 @@ fn init_logging(otlp_endpoint: Option, json_output: bool) { if let Ok(tracer) = tracer { layers.push(tracing_opentelemetry::layer().with_tracer(tracer).boxed()); - axum_tracing_opentelemetry::init_propagator().unwrap(); }; } diff --git a/router/src/server.rs b/router/src/server.rs index 840bfb353..8acc8d20e 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -21,7 +21,7 @@ use axum::response::sse::{Event, KeepAlive, Sse}; use axum::response::{IntoResponse, Response}; use axum::routing::{get, post}; use axum::{http, Json, Router}; -use axum_tracing_opentelemetry::opentelemetry_tracing_layer; +use axum_tracing_opentelemetry::middleware::{OtelAxumLayer, OtelInResponseLayer}; use clap::error; use futures::stream::StreamExt; use futures::Stream; @@ -30,6 +30,7 @@ use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle}; use once_cell::sync::OnceCell; use reqwest_middleware::{ClientBuilder, ClientWithMiddleware}; use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware}; +use reqwest::Client; use std::convert::Infallible; use std::net::SocketAddr; use std::sync::atomic::AtomicBool; @@ -430,6 +431,7 @@ async fn generate( metrics::increment_counter!("lorax_request_count"); tracing::debug!("Input: {}", req.0.inputs); + tracing::info!("Request Headers: {}", req_headers); if info.embedding_model { metrics::increment_counter!("lorax_request_failure", "err" => "bad_request"); @@ -960,7 +962,7 @@ async fn request_logger( tracing::info!("Request logging enabled, sending logs to {url_string}"); let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3); - let client = ClientBuilder::new(reqwest::Client::new()) + let client = ClientBuilder::new(Client::new()) .with(RetryTransientMiddleware::new_with_policy(retry_policy)) .build(); while let Some((tokens, api_token, model_id)) = rx.recv().await { @@ -1255,7 +1257,8 @@ pub async fn run( .layer(Extension(compat_return_full_text)) .layer(Extension(infer)) .layer(Extension(prom_handle.clone())) - .layer(opentelemetry_tracing_layer()) + .layer(OtelAxumLayer::default()) + .layer(OtelInResponseLayer::default()) .layer(cors_layer) .layer(Extension(cloned_tokenizer));