File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
opentelemetry-exporter-gcp-logging
src/opentelemetry/exporter/cloud_logging
__snapshots__/test_cloud_logging Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14+ # Remove after this program no longer support Python 3.8.*
15+ from __future__ import annotations
1416import datetime
1517import logging
1618import urllib .parse
5961
6062# severityMapping maps the integer severity level values from OTel [0-24]
6163# to matching Cloud Logging severity levels.
62- SEVERITY_MAPPING : dict [ int , int ] = {
64+ SEVERITY_MAPPING = {
6365 0 : LogSeverity .DEFAULT , # Default, 0
6466 1 : LogSeverity .DEBUG , #
6567 2 : LogSeverity .DEBUG , #
@@ -172,10 +174,10 @@ def export(self, batch: Sequence[LogData]):
172174 log_entry .span_id = str (hex (log_record .span_id ))[2 :]
173175 if (
174176 log_record .severity_number
175- and log_record .severity_number in SEVERITY_MAPPING
177+ and log_record .severity_number . value in SEVERITY_MAPPING
176178 ):
177- log_entry .severity = SEVERITY_MAPPING [
178- log_record .severity_number
179+ log_entry .severity = SEVERITY_MAPPING [ #type: ignore[assignment]
180+ log_record .severity_number . value #type: ignore[index]
179181 ]
180182 log_entry .labels = {k : str (v ) for k , v in attrs_map .items ()}
181183 if type (log_record .body ) is dict :
Original file line number Diff line number Diff line change 2727 },
2828 "type" : " generic_node"
2929 },
30+ "severity" : " ERROR" ,
3031 "spanId" : " 16" ,
3132 "timestamp" : " 2025-01-15T21:25:10.997977393Z" ,
3233 "trace" : " projects/fakeproject/traces/25"
Original file line number Diff line number Diff line change 2525
2626Be sure to review the changes.
2727"""
28-
2928import re
3029from typing import List
3130
3938from opentelemetry .sdk ._logs ._internal import LogRecord
4039from opentelemetry .sdk .resources import Resource
4140from opentelemetry .sdk .util .instrumentation import InstrumentationScope
41+ from google .auth .credentials import AnonymousCredentials
4242
4343PROJECT_ID = "fakeproject"
4444
4545
46- def test_create_cloud_logging_exporter (caplog ) -> None :
46+ def test_create_cloud_logging_exporter () -> None :
4747 CloudLoggingExporter (default_log_name = "test" )
48- client = LoggingServiceV2Client ()
48+ client = LoggingServiceV2Client (credentials = AnonymousCredentials () )
4949 CloudLoggingExporter (project_id = PROJECT_ID , client = client )
5050
5151
5252def test_invalid_otlp_entries_raise_warnings (caplog ) -> None :
53- client = LoggingServiceV2Client ()
53+ client = LoggingServiceV2Client (credentials = AnonymousCredentials () )
5454 no_default_logname = CloudLoggingExporter (
5555 project_id = PROJECT_ID , client = client
5656 )
You can’t perform that action at this time.
0 commit comments