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

Logging: support custom labels in GKE handler. #8

Closed
ZeeD opened this issue Aug 5, 2019 · 1 comment
Closed

Logging: support custom labels in GKE handler. #8

ZeeD opened this issue Aug 5, 2019 · 1 comment
Assignees
Labels
api: logging Issues related to the googleapis/python-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. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@ZeeD
Copy link

ZeeD commented Aug 5, 2019

handler = client.get_default_handler()
handler.labels = {"foo":"bar"}
logger = logging.getLogger("baz")
logger.addHandler(handler)
logger.warn("qux")

get_default_handler returns different implementations of the handler if you are on a local machine, or a GKE cluster.
The latter doesn't support the set of the labels.
Nor it warn about it.

@tseaver tseaver changed the title CloudLoggingHandler should allow the set of custom labels Logging: support custom labels in CloudLoggingHandler. Aug 5, 2019
@tseaver tseaver changed the title Logging: support custom labels in CloudLoggingHandler. Logging: support custom labels in GKE handler. Aug 5, 2019
@plamut plamut transferred this issue from googleapis/google-cloud-python Feb 5, 2020
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/python-logging API. label Feb 5, 2020
@plamut plamut added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Feb 5, 2020
@daniel-sanche daniel-sanche added this to the v2.5.0 milestone Feb 4, 2021
@keenan-devrel keenan-devrel added priority: p2 Moderately-important priority. Fix may not be included in next release. external This issue is blocked on a bug with the actual product. labels Apr 22, 2021
@daniel-sanche
Copy link
Contributor

This feature will now be supported for the StructuredLogHandler and the CloudLoggingHandler in the upcomming feature release (v2.4.0).

Unfortunately this change isn't coming to the default ContainerEngineHandler or AppEngineHandler, as we plan to remove them in favor of StructuredLogHandler and CloudLoggingHandler in the next major (v3.0.0) release. To use this feature on GKE, you'll have to set a different handler type:

import logging
import google.cloud.logging
from google.cloud.logging.handlers import StructuredLogHandler

handler = StructuredLogHandler(labels={"foo":"bar"})
logger = logging.getLogger()
logger.addHandler(handler)
logger.warn("qux", extra={"labels":{"another-label":"baz"}})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/python-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. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

4 participants