1- # Copyright 2025 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- # Remove after this program no longer support Python 3.8.*
151from __future__ import annotations
162# Copyright 2025 Google LLC
173#
2915import datetime
3016import logging
3117import urllib .parse
32- import logging
33- import urllib .parse
3418from typing import Optional , Sequence
3519
36- import google .auth
37- from google .api .monitored_resource_pb2 import MonitoredResource # type: ignore
38- from google .cloud .logging_v2 .services .logging_service_v2 import (
39- LoggingServiceV2Client ,
40- )
41-
4220import google .auth
4321from google .api .monitored_resource_pb2 import MonitoredResource # type: ignore
4422from google .cloud .logging_v2 .services .logging_service_v2 import (
5230from google .protobuf .struct_pb2 import Struct
5331from google .protobuf .timestamp_pb2 import Timestamp
5432from opentelemetry .exporter .cloud_logging .version import __version__
55- from google .logging .type .log_severity_pb2 import LogSeverity # type: ignore
56- from google .protobuf .struct_pb2 import Struct
57- from google .protobuf .timestamp_pb2 import Timestamp
58- from opentelemetry .exporter .cloud_logging .version import __version__
5933from opentelemetry .resourcedetector .gcp_resource_detector ._mapping import (
6034 get_monitored_resource ,
6135)
6236from opentelemetry .sdk import version as opentelemetry_sdk_version
6337from opentelemetry .sdk ._logs import LogData
6438from opentelemetry .sdk ._logs .export import LogExporter
6539from opentelemetry .sdk .resources import Resource
66- from opentelemetry .sdk ._logs import LogData
67- from opentelemetry .sdk ._logs .export import LogExporter
68- from opentelemetry .sdk .resources import Resource
6940
7041DEFAULT_MAX_ENTRY_SIZE = 256000 # 256 KB
7142DEFAULT_MAX_REQUEST_SIZE = 10000000 # 10 MB
@@ -166,7 +137,6 @@ def export(self, batch: Sequence[LogData]):
166137 log_record .resource or Resource ({})
167138 )
168139 # convert it to proto
169- monitored_resource : Optional [MonitoredResource ] = (
170140 monitored_resource : Optional [MonitoredResource ] = (
171141 MonitoredResource (
172142 type = monitored_resource_data .type ,
@@ -198,8 +168,6 @@ def export(self, batch: Sequence[LogData]):
198168 log_entry .trace_sampled = (
199169 log_record .trace_flags is not None
200170 and log_record .trace_flags .sampled
201- log_record .trace_flags is not None
202- and log_record .trace_flags .sampled
203171 )
204172 if TRACE_SAMPLED_ATTRIBUTE_KEY in attrs_map :
205173 log_entry .trace_sampled |= bool (
@@ -255,4 +223,4 @@ def _write_log_entries(self, log_entries: list[LogEntry]):
255223 self .client .write_log_entries (entries = batch )
256224
257225 def shutdown (self ):
258- pass
226+ pass
0 commit comments