impl(gax-internal): HttpSpanInfo struct, new, and update_from_outcome… #7316
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Rust SDK | |
permissions: read-all | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
release: | |
types: [published] | |
env: | |
GHA_RUST_VERSIONS: '{ "rust:msrv": "1.85", "rust:current": "1.89", "rust:nightly": "nightly" }' | |
GHA_GO_VERSIONS: '{ "go:current": "1.25.0" }' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: ['macos-14', 'ubuntu-24.04', 'windows-2025'] | |
rust-version: ['rust:current'] | |
include: | |
- os: 'ubuntu-24.04' | |
rust-version: 'rust:msrv' | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- run: rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Running tests for key crates | |
run: cargo clean && cargo test | |
- name: Build full workspace | |
# See Cargo.toml for the definition and motivation of this profile | |
run: cargo clean && cargo build --profile=ci --workspace | |
if: matrix.os != 'windows-2025' | |
- name: Running tests for full workspace | |
# See Cargo.toml for the definition and motivation of this profile | |
run: cargo clean && cargo test --profile=ci --workspace | |
if: github.event_name == 'push' | |
features: | |
strategy: | |
matrix: | |
os: ['ubuntu-24.04'] | |
rust-version: ['rust:current'] | |
runs-on: ${{ matrix.os }} | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup component add clippy | |
- run: rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Test crates with features disabled | |
run: | | |
set -e | |
cargo clean | |
echo "==== google-cloud-wkt ====" | |
for sub in test doc; do | |
cargo "${sub}" --package google-cloud-wkt --no-default-features | |
cargo "${sub}" --package google-cloud-wkt --no-default-features --features chrono | |
cargo "${sub}" --package google-cloud-wkt --no-default-features --features time | |
cargo "${sub}" --package google-cloud-wkt --no-default-features --features _internal-semver | |
cargo "${sub}" --package google-cloud-wkt --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-wkt --all-targets -- --deny warnings | |
cargo clippy --no-deps --package google-cloud-wkt --all-features --all-targets --profile=test -- --deny warnings | |
cargo clean | |
echo "==== google-cloud-gax ====" | |
for sub in test doc; do | |
cargo "${sub}" --package google-cloud-gax --no-default-features | |
cargo "${sub}" --package google-cloud-gax --no-default-features --features unstable-stream | |
cargo "${sub}" --package google-cloud-gax --no-default-features --features _internal-semver | |
cargo "${sub}" --package google-cloud-gax --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-gax --all-targets -- --deny warnings | |
cargo clippy --no-deps --package google-cloud-gax --all-features --all-targets --profile=test -- --deny warnings | |
cargo clean | |
echo "==== google-cloud-gax-internal ====" | |
for sub in test doc; do | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features --features _internal-common | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features --features _internal-http-client | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features --features _internal-grpc-client | |
cargo "${sub}" --package google-cloud-gax-internal --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-gax-internal --all-targets -- --deny warnings | |
cargo clippy --no-deps --package google-cloud-gax-internal --all-features --all-targets --profile=test -- --deny warnings | |
cargo clean | |
echo "==== google-cloud-lro ====" | |
for sub in test doc; do | |
cargo "${sub}" --profile=ci --package google-cloud-lro --no-default-features | |
cargo "${sub}" --profile=ci --package google-cloud-lro --no-default-features --features unstable-stream | |
cargo "${sub}" --profile=ci --package google-cloud-lro --no-default-features --features _internal-semver | |
cargo "${sub}" --profile=ci --package google-cloud-lro --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-lro --all-targets -- --deny warnings | |
cargo clippy --no-deps --package google-cloud-lro --all-features --all-targets --profile=test -- --deny warnings | |
# We use google-cloud-aiplatform-v1 to test the generator w.r.t. | |
# per-client features. As usual, we assume the generator works for | |
# other generated libraries if it works for one. | |
cargo clean | |
echo "==== google-cloud-aiplatform-v1 ====" | |
cargo build -p google-cloud-aiplatform-v1 --no-default-features | |
mapfile -t features < <(sed -n -e '/^default = \[/,/^\]/ p' src/generated/cloud/aiplatform/v1/Cargo.toml | sed -n -e '/",/ s/ *"\(.*\)",/\1/p') | |
for feature in "${features[@]}"; do | |
echo "==== google-cloud-aiplatform-v1 + ${feature} ====" | |
cargo build --profile=ci -p google-cloud-aiplatform-v1 --no-default-features --features "${feature}" | |
done | |
cargo clean | |
echo "==== google-cloud-storage ====" | |
for sub in test doc; do | |
cargo "${sub}" --profile=ci --package google-cloud-storage --no-default-features | |
cargo "${sub}" --profile=ci --package google-cloud-storage --no-default-features --features unstable-stream | |
cargo "${sub}" --profile=ci --package google-cloud-storage --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-storage --all-targets -- --deny warnings | |
cargo clippy --no-deps --package google-cloud-storage --all-features --all-targets --profile=test -- --deny warnings | |
coverage: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
cargo install cargo-tarpaulin --version 0.32.1 --locked | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: cargo tarpaulin --out xml | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v5 | |
with: | |
fail_ci_if_error: false | |
token: ${{ secrets.CODECOV_TOKEN }} | |
minimal-versions: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
cargo install cargo-minimal-versions [email protected] [email protected] --locked | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: | | |
set -e | |
cargo minimal-versions test --package integration-tests | |
cargo minimal-versions test --package user-guide-samples | |
cargo minimal-versions test --package storage-samples | |
cargo minimal-versions test --package google-cloud-storage | |
cargo minimal-versions test --package google-cloud-gax-internal | |
cargo minimal-versions test --package google-cloud-auth | |
cargo minimal-versions test --package google-cloud-gax | |
cargo minimal-versions test --package google-cloud-wkt | |
semver-checks: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Check for major breaks in key libraries | |
# TODO(#3265) - replace with a standard tool or a program in Go or Rust. | |
run: | | |
set -e | |
if [[ '${{ contains(github.event.pull_request.labels.*.name, 'rust: no-semver-checks') }}' == 'true' ]]; then | |
exit 0 | |
fi | |
dirs=( | |
src/wkt | |
src/gax | |
src/lro | |
src/auth | |
src/generated/cloud/location | |
src/generated/iam/v1 | |
src/generated/longrunning | |
) | |
git fetch origin main | |
cat >major-break.awk <<'_EOF_' | |
function v(s) { | |
s = substr(s, 2, length(s)-2); | |
return s | |
} | |
/^\+version/ { new = v($2) } | |
/^\-version/ { old = v($2) } | |
END { | |
if (new == "" || old == "") { | |
exit 1 | |
} | |
split(old, a, ".") | |
split(new, b, ".") | |
if (a[1] != b[1]) { | |
printf("major version mismatch: new=%s old=%s\n", new, old) | |
exit 0 | |
} | |
if (a[1] == "0" && b[1] == "0" && a[2] != b[2]) { | |
printf("minor version mismatch on 0.x series: new=%s old=%s\n", new, old) | |
exit 0 | |
} | |
printf("major versions match: old=%s, new=%s\n", old, new) | |
exit 1 | |
} | |
_EOF_ | |
set +e | |
for name in "${dirs[@]}"; do | |
if git diff origin/main..HEAD -- "${name}/Cargo.toml" | awk -F' = ' -f major-break.awk; then | |
cat <<_EOF_ | |
The major version (or minor for a 0.x series) of a critical package | |
(located in ${name}) is changing. The types from this package are part | |
of the public API for many other packages. You need to bump the | |
version of all downstream packages and then disable this check using | |
the 'rust: no-semver-checks' github label. | |
_EOF_ | |
exit 1 | |
fi | |
done | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
cargo install --locked [email protected] | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: | | |
set -e | |
cargo semver-checks --all-features -p google-cloud-wkt | |
cargo semver-checks --all-features -p google-cloud-api | |
cargo semver-checks --all-features -p google-cloud-rpc | |
cargo semver-checks --all-features -p google-cloud-gax | |
cargo semver-checks --all-features -p google-cloud-auth | |
cargo semver-checks --all-features -p google-cloud-gax-internal | |
cargo semver-checks --all-features -p google-cloud-type | |
cargo semver-checks --all-features -p google-cloud-iam-v1 | |
cargo semver-checks --all-features -p google-cloud-location | |
cargo semver-checks --all-features -p google-cloud-longrunning | |
cargo semver-checks --all-features -p google-cloud-lro | |
cargo semver-checks --all-features -p google-cloud-kms-v1 | |
cargo semver-checks --all-features -p google-cloud-language-v2 | |
cargo semver-checks --all-features -p google-cloud-secretmanager-v1 | |
cargo semver-checks --all-features -p google-cloud-speech-v2 | |
cargo semver-checks --all-features -p google-cloud-storage | |
showcase: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
go-version: ['go:current'] | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Setup Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v6 | |
with: | |
go-version: ${{ fromJson(env.GHA_GO_VERSIONS)[matrix.go-version] }} | |
- run: | | |
cargo test --features run-showcase-tests -p integration-tests | |
protojson-conformance: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
repository: 'protocolbuffers/protobuf' | |
ref: '31.x' | |
path: 'protobuf' | |
- uses: actions/checkout@v5 | |
with: | |
path: 'main' | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('main/Cargo.lock', 'main/.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Build conformance testee | |
working-directory: main | |
run: | | |
cargo build -p protojson-conformance | |
- name: Run conformance test | |
working-directory: protobuf | |
env: | |
USE_BAZEL_VERSION: '8.2.1' | |
run: | | |
bazelisk run --enable_bzlmod -- \ | |
//conformance:conformance_test_runner \ | |
--failure_list ${GITHUB_WORKSPACE}/main/src/protojson-conformance/expected_failures.txt \ | |
${GITHUB_WORKSPACE}/main/target/debug/protojson-conformance | |
docs: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current', 'rust:nightly'] | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
cargo install mdbook | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: cargo doc --workspace | |
if: matrix.rust-version == 'rust:current' | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
- run: cargo doc | |
# The nightly builds are slow for some reason, so we run a smaller set | |
# of documents for them. We expect these will catch most problems. | |
if: matrix.rust-version == 'rust:nightly' | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
- run: mdbook build guide | |
- run: mdbook test guide | |
- name: Upload user guide | |
if: matrix.rust-version == 'rust:current' | |
id: deployment | |
uses: actions/upload-pages-artifact@v4 # or specific "vX.X.X" version tag for this action | |
with: | |
path: guide/book/ | |
deploy: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-24.04 | |
permissions: | |
# to deploy to Pages | |
pages: write | |
# to verify the deployment originates from an appropriate source | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: docs | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
lint: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup component add clippy rustfmt | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: cargo clippy --workspace --all-targets --profile=test -- --deny warnings | |
- run: cargo fmt | |
- run: git diff --exit-code | |
regenerate: | |
# Verifies the generated code has not been tampered with. Or maybe that the | |
# code requires no tampering. | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
go-version: ['go:current'] | |
steps: | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/sidekick | |
key: ${{ github.job }}-${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
- uses: actions/checkout@v5 | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup component add rustfmt | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Setup Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v6 | |
with: | |
go-version: ${{ fromJson(env.GHA_GO_VERSIONS)[matrix.go-version] }} | |
- name: Install protoc | |
run: | | |
set -e | |
curl -fSSL --retry 3 --retry-all-errors --retry-delay 15 -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip | |
cd /usr/local | |
sudo unzip -x /tmp/protoc.zip | |
protoc --version | |
- name: Regenerate all the code | |
run: go run github.com/googleapis/librarian/cmd/[email protected] refreshall | |
- run: cargo fmt | |
# If there is any difference between the generated code and the | |
# committed code that is an error. All the inputs should be pinned, | |
# including the generator version and the googleapis SHA. | |
- run: git diff --exit-code |