Google::Cloud::Storage::File#exists? はファイルが存在しない場合にエラーログを出力する

bucket = Google::Cloud::Storage.new(project_id: gcp_project).bucket(gcs_bucket)
file = bucket.file(file_path, skip_lookup: true)
do_something if file.exists?

みたいなコード書いた場合、ファイルが存在しない場合は file.exists? がちゃんと false を返してくれるのだが、

E, [2023-02-27T15:57:39.741887 #83900] ERROR -- : Error - #<Google::Apis::ClientError: notFound: No such object: ...

みたいなエラーが出力される。

エラーがウザい場合は、files メソッド使ってファイル数で判定するしかなさそう。

files = bucket.files(prefix: file_path)
do_something if files.length.positive?

どうも google-api-ruby-client が OpenCensus (現 OpenTelemetry) を使ってるせいでエラーログが出るっぽい?

Google::Cloud::Storage::File#exists? は、ファイルが存在しない場合は ensure_gapi! を呼び出してるっぽい。
https://github.com/googleapis/google-cloud-ruby/blob/4a6a5b77e43975bdcfcdd15a4e5a186b860b47eb/google-cloud-storage/lib/google/cloud/storage/file.rb#L1936

ensure_gapi! の中で reload! を呼び出している。
https://github.com/googleapis/google-cloud-ruby/blob/4a6a5b77e43975bdcfcdd15a4e5a186b860b47eb/google-cloud-storage/lib/google/cloud/storage/file.rb#L2010

reload! の中で Google::Cloud::Storage::Service#get_file を呼んる。
https://github.com/googleapis/google-cloud-ruby/blob/4a6a5b77e43975bdcfcdd15a4e5a186b860b47eb/google-cloud-storage/lib/google/cloud/storage/file.rb#L1921

Service#get_file の中で、Google::Apis::StorageV1::StorageService#get_object を呼んでる。
https://github.com/googleapis/google-cloud-ruby/blob/4a6a5b77e43975bdcfcdd15a4e5a186b860b47eb/google-cloud-storage/lib/google/cloud/storage/service.rb#L380

StorageService#get_object の中で、Google::Apis::Core::BaseService#execute_or_queue_command を呼んでる。
https://github.com/googleapis/google-api-ruby-client/blob/main/generated/google-apis-storage_v1/lib/google/apis/storage_v1/service.rb#L1773

BaseService#execute_or_queue_command の中で、(おそらくは) Google::Apis::Core::HttpCommand#execute を呼んでる。
https://github.com/googleapis/google-api-ruby-client/blob/main/google-apis-core/lib/google/apis/core/base_service.rb#L418

HttpCommand#execute の中で OpenCensus を使っている。
https://github.com/googleapis/google-api-ruby-client/blob/main/google-apis-core/lib/google/apis/core/http_command.rb#L101