googleapis / googleapis/google-cloud-php

Do not throw an `ApiException` when grpc logging does not work

Open
#4,707 1 comment 0 reactions 0 assignees View on GitHub
type: feature request
Dominant language
PHP
Stars
1.2k
Forks
463
Avg merge
2d 1h
Merged PRs (30d)
145

Description

When debugging `grpc`-related issues in a PHP client library, some common steps include adding the below lines to the `php.ini` file:

```
grpc.grpc_verbosity=debug
grpc.grpc_trace=all,-timer_check
grpc.log_filename=/var/log/grpc.log
```

However, if one accidentally forgets to initialize and make the `grpc.log` file writeable (e.g. running `sudo chmod 666 /var/log/grpc.log`), then when running any sample PHP code that uses grpc, you get this error:

```
PHP Fatal error: Uncaught Google\ApiCore\ApiException: {
"message": "failed to connect to all addresses",
"code": 14,
"status": "UNAVAILABLE",
"details": []
}
```

This is misleading as it suggests that the service one is trying to access in unavailable, when in actuality the only issue is that the `grpc.log` file is missing/unwriteable.

This error immediately goes away when the `grpc.log` file is initialized and writeable, or if `grpc.log_filename` is removed/commented out and the logs are written directly to `stderr`.

Ideally in this scenario, `grpc` emits a more descriptive message along the lines of `Make sure the `grpc.log` file is initialized and writeable`, and `google-cloud-php` does not throw an `ApiException` that could throw off users.

Related issue in grpc here: https://github.com/grpc/grpc/issues/27987

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.