Skip to content

Commit 219e9f7

Browse files
committed
Fix broken test, reformat file.
1 parent 87d7a89 commit 219e9f7

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

opentelemetry-exporter-gcp-logging/src/opentelemetry/exporter/cloud_logging/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import annotations
2+
23
# Copyright 2025 Google LLC
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -187,8 +188,8 @@ def export(self, batch: Sequence[LogData]):
187188
log_record.severity_number
188189
and log_record.severity_number.value in SEVERITY_MAPPING
189190
):
190-
log_entry.severity = SEVERITY_MAPPING[ #type: ignore[assignment]
191-
log_record.severity_number.value #type: ignore[index]
191+
log_entry.severity = SEVERITY_MAPPING[ # type: ignore[assignment]
192+
log_record.severity_number.value # type: ignore[index]
192193
]
193194
log_entry.labels = {k: str(v) for k, v in attrs_map.items()}
194195
if type(log_record.body) is dict:
@@ -200,7 +201,6 @@ def export(self, batch: Sequence[LogData]):
200201
self._write_log_entries(log_entries)
201202

202203
def _write_log_entries(self, log_entries: list[LogEntry]):
203-
batch: list[LogEntry] = []
204204
batch: list[LogEntry] = []
205205
batch_byte_size = 0
206206
for entry in log_entries:
@@ -223,4 +223,4 @@ def _write_log_entries(self, log_entries: list[LogEntry]):
223223
self.client.write_log_entries(entries=batch)
224224

225225
def shutdown(self):
226-
pass
226+
pass

opentelemetry-exporter-gcp-logging/tests/test_cloud_logging.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from typing import List
3030

3131
from fixtures.cloud_logging_fake import CloudLoggingFake, WriteLogEntriesCall
32+
from google.auth.credentials import AnonymousCredentials
3233
from google.cloud.logging_v2.services.logging_service_v2 import (
3334
LoggingServiceV2Client,
3435
)
@@ -38,17 +39,10 @@
3839
from opentelemetry.sdk._logs._internal import LogRecord
3940
from opentelemetry.sdk.resources import Resource
4041
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
41-
from google.auth.credentials import AnonymousCredentials
4242

4343
PROJECT_ID = "fakeproject"
4444

4545

46-
def test_create_cloud_logging_exporter() -> None:
47-
CloudLoggingExporter(default_log_name="test")
48-
client = LoggingServiceV2Client(credentials=AnonymousCredentials())
49-
CloudLoggingExporter(project_id=PROJECT_ID, client=client)
50-
51-
5246
def test_invalid_otlp_entries_raise_warnings(caplog) -> None:
5347
client = LoggingServiceV2Client(credentials=AnonymousCredentials())
5448
no_default_logname = CloudLoggingExporter(
@@ -57,8 +51,10 @@ def test_invalid_otlp_entries_raise_warnings(caplog) -> None:
5751
no_default_logname.export(
5852
[
5953
LogData(
60-
log_record = LogRecord(resource=Resource({}),
61-
attributes={str(i):"i" * 10000 for i in range(1000)}),
54+
log_record=LogRecord(
55+
resource=Resource({}),
56+
attributes={str(i): "i" * 10000 for i in range(1000)},
57+
),
6258
instrumentation_scope=InstrumentationScope("test"),
6359
)
6460
]
@@ -89,9 +85,6 @@ def test_convert_otlp(
8985
"value": {
9086
"stringValue": "You're a helpful assistant."
9187
},
92-
"value": {
93-
"stringValue": "You're a helpful assistant."
94-
},
9588
}
9689
]
9790
}

0 commit comments

Comments
 (0)