Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud function logging error severity #1370

Closed
JHDC opened this issue Jun 8, 2021 · 8 comments
Closed

Cloud function logging error severity #1370

JHDC opened this issue Jun 8, 2021 · 8 comments
Assignees
Labels
api: cloudfunctions Issues related to the Cloud Run functions API. api: logging Issues related to the Cloud Logging API. external This issue is blocked on a bug with the actual product. priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. status: investigating The issue is under investigation, which is determined to be non-trivial. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@JHDC
Copy link

JHDC commented Jun 8, 2021

I've run into trouble logging with error severity using cloud functions. Spinning up the example from documentation does not work (logs are displayed with default severity), nor does specifying a severity while using the google/cloud-logging package via composer.

Attached is a screenshot of log output while using the example code from https://github.com/GoogleCloudPlatform/php-docs-samples/blob/HEAD/functions/helloworld_log/index.php

Screen Shot 2021-06-08 at 10 36 02 AM

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jun 8, 2021
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Jun 9, 2021
@bshaffer
Copy link
Contributor

Hmm, this may be an issue with compatibility between Google Cloud Functions and our google/cloud-logging library. Have you tried using stdout for logging, instead of using google/cloud-logging?

I'll look into it...

@danoscarmike danoscarmike added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Jul 19, 2021
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Nov 3, 2021
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Dec 5, 2021
@danoscarmike danoscarmike added the api: logging Issues related to the Cloud Logging API. label Jan 5, 2022
@grayside grayside added the api: cloudfunctions Issues related to the Cloud Run functions API. label Jan 21, 2022
@grayside grayside self-assigned this Mar 24, 2022
@grayside
Copy link
Contributor

I've reproduced the problem with the sample, it does not work because some change in the HTTP proxy server in the runtime was changed, and is now prefixing stderr messages with a string that breaks JSON parsing.

Given the logging library uses a different mechanism to ship logs, I'm guessing we have at least two different problems.

When I add cloud/logging to the sample, my local composer v3 is fine but I get the following error on deployment (before even reproducing the reported issue)

gcloud functions deploy --runtime php74 --trigger-http log --entry-point helloLogging
Deploying function (may take a while - up to 2 minutes)...⠹
For Cloud Build Logs, visit: https://console.cloud.google.com/cloud-build/builds;region=us-central1/9651d4e0-15cd-4a3f-b862-079e9447696e?project=[...]
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - psr/cache is locked to version 2.0.0 and an update of this package was not requested.
    - psr/cache 2.0.0 requires php >=8.0.0 -> your php version (7.4.27) does not satisfy that requirement.
  Problem 2
    - psr/log is locked to version 2.0.0 and an update of this package was not requested.
    - psr/log 2.0.0 requires php >=8.0.0 -> your php version (7.4.27) does not satisfy that requirement.
  Problem 3
    - psr/cache 2.0.0 requires php >=8.0.0 -> your php version (7.4.27) does not satisfy that requirement.
    - google/grpc-gcp v0.2.0 requires psr/cache ^1.0.1||^2.0.0||^3.0.0 -> satisfiable by psr/cache[2.0.0].
    - google/grpc-gcp is locked to version v0.2.0 and an update of this package was not requested.; Error ID: 467317e4

All right, let's run composer update!

composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 2 updates, 0 removals
  - Upgrading guzzlehttp/psr7 (2.1.0 => 2.2.1)
  - Upgrading symfony/polyfill-php80 (v1.24.0 => v1.25.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Downloading guzzlehttp/psr7 (2.2.1)
  - Downloading symfony/polyfill-php80 (v1.25.0)
  - Upgrading guzzlehttp/psr7 (2.1.0 => 2.2.1): Extracting archive
  - Upgrading symfony/polyfill-php80 (v1.24.0 => v1.25.0): Extracting archive
Generating autoload files
7 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Deploy fails the same way.

@bshaffer do you have insight into this build problem?

@grayside grayside added the external This issue is blocked on a bug with the actual product. label Apr 21, 2022
@yoshi-automation yoshi-automation removed the 🚨 This issue needs some love. label Apr 21, 2022
@jorisvaesen
Copy link

jorisvaesen commented Jun 19, 2022

This issue is related to php-fpm. By default decorate_workers_output is on, which prepends text to all logs written to php://stderr. This makes it impossible to use structured logs in Cloud Functions (gen2) with php runtime.

To make structured logs work on php runtimes, the value should be changed to off on container generation done by Cloud Run which means a change of the default Dockerfile related to Cloud Functions php runtimes (7.4 + 8.1).

Ref: docker-library/php#207

@FelipeVeiga
Copy link

any news about it ?

@bshaffer bshaffer added the status: investigating The issue is under investigation, which is determined to be non-trivial. label Dec 16, 2022
@bshaffer
Copy link
Contributor

bshaffer commented Dec 16, 2022

I agree that decorate_workers_output = off is the solution. We are looking into it (b/229998968).

@rogerthatdev
Copy link

@bshaffer Would you verify if this has been resolved?

@bshaffer
Copy link
Contributor

bshaffer commented May 9, 2023

The bug above was marked as fixed on April 10th of this year. I have not verified it's been fixed yet.

@engelke engelke closed this as completed Jul 11, 2023
@iennae
Copy link
Contributor

iennae commented May 16, 2024

the underlying sample has been updated to reflect the verification that this is working with #1936. thank you @glasnt and @bshaffer !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: cloudfunctions Issues related to the Cloud Run functions API. api: logging Issues related to the Cloud Logging API. external This issue is blocked on a bug with the actual product. priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. status: investigating The issue is under investigation, which is determined to be non-trivial. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

10 participants