google-cloud-logging 3.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/cloud/logging/__init__.py +53 -0
- google/cloud/logging/gapic_version.py +16 -0
- google/cloud/logging/handlers/__init__.py +31 -0
- google/cloud/logging/handlers/middleware/__init__.py +17 -0
- google/cloud/logging/handlers/transports/__init__.py +28 -0
- google/cloud/logging/py.typed +2 -0
- google/cloud/logging_v2/__init__.py +61 -0
- google/cloud/logging_v2/_gapic.py +647 -0
- google/cloud/logging_v2/_helpers.py +152 -0
- google/cloud/logging_v2/_http.py +549 -0
- google/cloud/logging_v2/_instrumentation.py +92 -0
- google/cloud/logging_v2/client.py +429 -0
- google/cloud/logging_v2/entries.py +358 -0
- google/cloud/logging_v2/gapic_metadata.json +481 -0
- google/cloud/logging_v2/gapic_version.py +16 -0
- google/cloud/logging_v2/handlers/__init__.py +31 -0
- google/cloud/logging_v2/handlers/_helpers.py +283 -0
- google/cloud/logging_v2/handlers/_monitored_resources.py +303 -0
- google/cloud/logging_v2/handlers/app_engine.py +139 -0
- google/cloud/logging_v2/handlers/container_engine.py +62 -0
- google/cloud/logging_v2/handlers/handlers.py +340 -0
- google/cloud/logging_v2/handlers/middleware/__init__.py +17 -0
- google/cloud/logging_v2/handlers/middleware/request.py +52 -0
- google/cloud/logging_v2/handlers/structured_log.py +150 -0
- google/cloud/logging_v2/handlers/transports/__init__.py +29 -0
- google/cloud/logging_v2/handlers/transports/background_thread.py +343 -0
- google/cloud/logging_v2/handlers/transports/base.py +61 -0
- google/cloud/logging_v2/handlers/transports/sync.py +68 -0
- google/cloud/logging_v2/logger.py +541 -0
- google/cloud/logging_v2/metric.py +180 -0
- google/cloud/logging_v2/py.typed +2 -0
- google/cloud/logging_v2/resource.py +51 -0
- google/cloud/logging_v2/services/__init__.py +15 -0
- google/cloud/logging_v2/services/config_service_v2/__init__.py +22 -0
- google/cloud/logging_v2/services/config_service_v2/async_client.py +4232 -0
- google/cloud/logging_v2/services/config_service_v2/client.py +4686 -0
- google/cloud/logging_v2/services/config_service_v2/pagers.py +820 -0
- google/cloud/logging_v2/services/config_service_v2/transports/__init__.py +33 -0
- google/cloud/logging_v2/services/config_service_v2/transports/base.py +748 -0
- google/cloud/logging_v2/services/config_service_v2/transports/grpc.py +1345 -0
- google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py +1660 -0
- google/cloud/logging_v2/services/logging_service_v2/__init__.py +22 -0
- google/cloud/logging_v2/services/logging_service_v2/async_client.py +1272 -0
- google/cloud/logging_v2/services/logging_service_v2/client.py +1686 -0
- google/cloud/logging_v2/services/logging_service_v2/pagers.py +516 -0
- google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py +33 -0
- google/cloud/logging_v2/services/logging_service_v2/transports/base.py +361 -0
- google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py +566 -0
- google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py +703 -0
- google/cloud/logging_v2/services/metrics_service_v2/__init__.py +22 -0
- google/cloud/logging_v2/services/metrics_service_v2/async_client.py +1119 -0
- google/cloud/logging_v2/services/metrics_service_v2/client.py +1534 -0
- google/cloud/logging_v2/services/metrics_service_v2/pagers.py +196 -0
- google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py +33 -0
- google/cloud/logging_v2/services/metrics_service_v2/transports/base.py +320 -0
- google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py +520 -0
- google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py +629 -0
- google/cloud/logging_v2/sink.py +233 -0
- google/cloud/logging_v2/types/__init__.py +178 -0
- google/cloud/logging_v2/types/log_entry.py +435 -0
- google/cloud/logging_v2/types/logging.py +602 -0
- google/cloud/logging_v2/types/logging_config.py +2418 -0
- google/cloud/logging_v2/types/logging_metrics.py +412 -0
- google_cloud_logging-3.13.0.dist-info/METADATA +143 -0
- google_cloud_logging-3.13.0.dist-info/RECORD +68 -0
- google_cloud_logging-3.13.0.dist-info/WHEEL +5 -0
- google_cloud_logging-3.13.0.dist-info/licenses/LICENSE +202 -0
- google_cloud_logging-3.13.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Copyright 2016 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Define Cloud Logging API Metrics."""
|
|
16
|
+
|
|
17
|
+
from google.cloud.exceptions import NotFound
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Metric(object):
|
|
21
|
+
"""Metrics represent named filters for log entries.
|
|
22
|
+
|
|
23
|
+
See
|
|
24
|
+
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, name, *, filter_=None, client=None, description=""):
|
|
28
|
+
"""
|
|
29
|
+
Args:
|
|
30
|
+
name (str): The name of the metric.
|
|
31
|
+
filter_ (str): the advanced logs filter expression defining the entries
|
|
32
|
+
tracked by the metric. If not passed, the instance should
|
|
33
|
+
already exist, to be refreshed via :meth:`reload`.
|
|
34
|
+
client (Optional[~logging_v2.client.Client]): A client which holds
|
|
35
|
+
credentials and project configuration for the sink (which requires a project).
|
|
36
|
+
description (Optional[str]): An optional description of the metric.
|
|
37
|
+
|
|
38
|
+
"""
|
|
39
|
+
self.name = name
|
|
40
|
+
self._client = client
|
|
41
|
+
self.filter_ = filter_
|
|
42
|
+
self.description = description
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def client(self):
|
|
46
|
+
"""Clent bound to the logger."""
|
|
47
|
+
return self._client
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def project(self):
|
|
51
|
+
"""Project bound to the logger."""
|
|
52
|
+
return self._client.project
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def full_name(self):
|
|
56
|
+
"""Fully-qualified name used in metric APIs"""
|
|
57
|
+
return f"projects/{self.project}/metrics/{self.name}"
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def path(self):
|
|
61
|
+
"""URL path for the metric's APIs"""
|
|
62
|
+
return f"/{self.full_name}"
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def from_api_repr(cls, resource, client):
|
|
66
|
+
"""Construct a metric given its API representation
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
resource (dict): metric resource representation returned from the API
|
|
70
|
+
client (~logging_v2.client.Client): Client which holds
|
|
71
|
+
credentials and project configuration for the sink.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
google.cloud.logging_v2.metric.Metric
|
|
75
|
+
"""
|
|
76
|
+
metric_name = resource["name"]
|
|
77
|
+
filter_ = resource["filter"]
|
|
78
|
+
description = resource.get("description", "")
|
|
79
|
+
return cls(metric_name, filter_=filter_, client=client, description=description)
|
|
80
|
+
|
|
81
|
+
def _require_client(self, client):
|
|
82
|
+
"""Check client or verify over-ride. Also sets ``parent``.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
client (Union[None, ~logging_v2.client.Client]):
|
|
86
|
+
The client to use. If not passed, falls back to the
|
|
87
|
+
``client`` stored on the current sink.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
google.cloud.logging_v2.client.Client: The client passed in
|
|
91
|
+
or the currently bound client.
|
|
92
|
+
"""
|
|
93
|
+
if client is None:
|
|
94
|
+
client = self._client
|
|
95
|
+
return client
|
|
96
|
+
|
|
97
|
+
def create(self, *, client=None):
|
|
98
|
+
"""Create the metric via a PUT request
|
|
99
|
+
|
|
100
|
+
See
|
|
101
|
+
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
client (Optional[~logging_v2.client.Client]):
|
|
105
|
+
The client to use. If not passed, falls back to the
|
|
106
|
+
``client`` stored on the current sink.
|
|
107
|
+
"""
|
|
108
|
+
client = self._require_client(client)
|
|
109
|
+
client.metrics_api.metric_create(
|
|
110
|
+
self.project, self.name, self.filter_, self.description
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
def exists(self, *, client=None):
|
|
114
|
+
"""Test for the existence of the metric via a GET request
|
|
115
|
+
|
|
116
|
+
See
|
|
117
|
+
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/get
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
client (Optional[~logging_v2.client.Client]):
|
|
121
|
+
The client to use. If not passed, falls back to the
|
|
122
|
+
``client`` stored on the current sink.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
bool: Boolean indicating existence of the metric.
|
|
126
|
+
"""
|
|
127
|
+
client = self._require_client(client)
|
|
128
|
+
|
|
129
|
+
try:
|
|
130
|
+
client.metrics_api.metric_get(self.project, self.name)
|
|
131
|
+
except NotFound:
|
|
132
|
+
return False
|
|
133
|
+
else:
|
|
134
|
+
return True
|
|
135
|
+
|
|
136
|
+
def reload(self, *, client=None):
|
|
137
|
+
"""API call: sync local metric configuration via a GET request
|
|
138
|
+
|
|
139
|
+
See
|
|
140
|
+
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/get
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
client (Optional[~logging_v2.client.Client]):
|
|
144
|
+
The client to use. If not passed, falls back to the
|
|
145
|
+
``client`` stored on the current sink.
|
|
146
|
+
"""
|
|
147
|
+
client = self._require_client(client)
|
|
148
|
+
data = client.metrics_api.metric_get(self.project, self.name)
|
|
149
|
+
self.description = data.get("description", "")
|
|
150
|
+
self.filter_ = data["filter"]
|
|
151
|
+
|
|
152
|
+
def update(self, *, client=None):
|
|
153
|
+
"""API call: update metric configuration via a PUT request
|
|
154
|
+
|
|
155
|
+
See
|
|
156
|
+
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/update
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
client (Optional[~logging_v2.client.Client]):
|
|
160
|
+
The client to use. If not passed, falls back to the
|
|
161
|
+
``client`` stored on the current sink.
|
|
162
|
+
"""
|
|
163
|
+
client = self._require_client(client)
|
|
164
|
+
client.metrics_api.metric_update(
|
|
165
|
+
self.project, self.name, self.filter_, self.description
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def delete(self, *, client=None):
|
|
169
|
+
"""API call: delete a metric via a DELETE request
|
|
170
|
+
|
|
171
|
+
See
|
|
172
|
+
https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/delete
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
client (Optional[~logging_v2.client.Client]):
|
|
176
|
+
The client to use. If not passed, falls back to the
|
|
177
|
+
``client`` stored on the current sink.
|
|
178
|
+
"""
|
|
179
|
+
client = self._require_client(client)
|
|
180
|
+
client.metrics_api.metric_delete(self.project, self.name)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright 2017 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Monitored Resource for the Google Logging API V2."""
|
|
16
|
+
|
|
17
|
+
import collections
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Resource(collections.namedtuple("Resource", "type labels")):
|
|
21
|
+
"""A monitored resource identified by specifying values for all labels.
|
|
22
|
+
|
|
23
|
+
Attributes:
|
|
24
|
+
type (str): The resource type name.
|
|
25
|
+
labels (dict): A mapping from label names to values for all labels
|
|
26
|
+
enumerated in the associated :class:`ResourceDescriptor`.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
__slots__ = ()
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def _from_dict(cls, info):
|
|
33
|
+
"""Construct a resource object from the parsed JSON representation.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
info (dict): A ``dict`` parsed from the JSON wire-format representation.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Resource: A resource object.
|
|
40
|
+
"""
|
|
41
|
+
return cls(type=info["type"], labels=info.get("labels", {}))
|
|
42
|
+
|
|
43
|
+
def _to_dict(self):
|
|
44
|
+
"""Build a dictionary ready to be serialized to the JSON format.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
dict:
|
|
48
|
+
A dict representation of the object that can be written to
|
|
49
|
+
the API.
|
|
50
|
+
"""
|
|
51
|
+
return {"type": self.type, "labels": self.labels}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
from .client import ConfigServiceV2Client
|
|
17
|
+
from .async_client import ConfigServiceV2AsyncClient
|
|
18
|
+
|
|
19
|
+
__all__ = (
|
|
20
|
+
"ConfigServiceV2Client",
|
|
21
|
+
"ConfigServiceV2AsyncClient",
|
|
22
|
+
)
|