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

Support setting the operation when using the python standard logger #684

Open
ravirahman opened this issue Dec 6, 2022 · 0 comments
Open
Labels
api: logging Issues related to the googleapis/python-logging API. 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

@ravirahman
Copy link

Is your feature request related to a problem? Please describe.
It would be helpful if I could specify the LogEntryOperation via the extra argument when using the python standard logger. From the documentation here, this field is not supported.

Describe the solution you'd like
Similarly to how I can specify the labels via the extra argument, I would also like to be able to specify the operation.
For example:

import logging

logger = logging.getLogger(__name__)
logger.info("My log", extra={
    "labels": {"label_name": "label_value"},  # This works
    "operation": {"id": "operation_id", "producer": "my_producer", "first": True, "last": False},  # This doesn't work
})

Describe alternatives you've considered

For now, I was able to get around it by manually monkeypatching the google.cloud.logging_v2.handlers.handlers.CloudLoggingHandler and google.cloud.logging_v2.handlers.structured_log.StructuredLogHandler classes to include the operation. However, I'd much prefer that the google library support this directly.

Additional context
None

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/python-logging API. label Dec 6, 2022
@losalex losalex assigned daniel-sanche and unassigned losalex Dec 7, 2022
@losalex losalex added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Dec 7, 2022
@daniel-sanche daniel-sanche removed their assignment Oct 20, 2023
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. 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

3 participants