Skip to content

Commit

Permalink
chore: Merge main into experimental-v4 (#906)
Browse files Browse the repository at this point in the history
* fix: Added missing import into logger.py (#896)

* test: Fixed unsupported resource type in system test (#904)

* fix: Added type hints to CloudLoggingHandler constructor (#903)

* fix: Added type hints to CloudLoggingHandler constructor

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Removed Client typing due to circular imports

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gkevinzheng and gcf-owl-bot[bot] committed Jul 29, 2024
1 parent bf4efa9 commit a7b99fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions google/cloud/logging_v2/handlers/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@
import json
import logging

from google.cloud.logging_v2.handlers.transports import BackgroundThreadTransport
from typing import Optional, IO

from google.cloud.logging_v2.handlers.transports import (
BackgroundThreadTransport,
Transport,
)
from google.cloud.logging_v2.handlers._monitored_resources import (
detect_resource,
add_resource_labels,
)
from google.cloud.logging_v2.handlers._helpers import get_request_data
from google.cloud.logging_v2.resource import Resource


DEFAULT_LOGGER_NAME = "python"

Expand Down Expand Up @@ -149,11 +156,11 @@ def __init__(
self,
client,
*,
name=DEFAULT_LOGGER_NAME,
transport=BackgroundThreadTransport,
resource=None,
labels=None,
stream=None,
name: str = DEFAULT_LOGGER_NAME,
transport: Transport = BackgroundThreadTransport,
resource: Resource = None,
labels: Optional[dict] = None,
stream: Optional[IO] = None,
**kwargs,
):
"""
Expand Down
1 change: 1 addition & 0 deletions google/cloud/logging_v2/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from google.api_core.exceptions import InvalidArgument
from google.rpc.error_details_pb2 import DebugInfo

import google.cloud.logging_v2
import google.protobuf.message

_GLOBAL_RESOURCE = Resource(type="global", labels={})
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def test_handlers_w_extras(self):
"trace_sampled": True,
"http_request": expected_request,
"source_location": expected_source,
"resource": Resource(type="cloudiot_device", labels={}),
"resource": Resource(type="global", labels={}),
"labels": {"test-label": "manual"},
}
cloud_logger.warning(LOG_MESSAGE, extra=extra)
Expand Down

0 comments on commit a7b99fd

Please sign in to comment.