Skip to content

Commit 887ffc6

Browse files
author
Liudmila Molkova
committed
lint
1 parent 654fe25 commit 887ffc6

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

instrumentation/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/patch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
is_streaming,
3434
message_to_event,
3535
set_span_attribute,
36-
silently_fail,
3736
)
3837

3938

@@ -86,7 +85,6 @@ def traced_method(wrapped, instance, args, kwargs):
8685
return traced_method
8786

8887

89-
@silently_fail
9088
def _set_response_attributes(
9189
span, result, event_logger: EventLogger, capture_content: bool
9290
):

instrumentation/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/utils.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import logging
1615
from os import environ
1716
from typing import Optional, Union
1817
from urllib.parse import urlparse
@@ -32,35 +31,13 @@
3231
"OTEL_INSTRUMENTATION_OPENAI_CAPTURE_MESSAGE_CONTENT"
3332
)
3433

35-
3634
def is_content_enabled() -> bool:
3735
capture_content = environ.get(
3836
OTEL_INSTRUMENTATION_OPENAI_CAPTURE_MESSAGE_CONTENT, None
3937
)
4038

4139
return bool(capture_content)
4240

43-
44-
def silently_fail(func):
45-
"""
46-
A decorator that catches exceptions thrown by the decorated function and logs them as warnings.
47-
"""
48-
49-
logger = logging.getLogger(func.__module__)
50-
51-
def wrapper(*args, **kwargs):
52-
try:
53-
return func(*args, **kwargs)
54-
except Exception as exception: # pylint: disable=broad-exception-caught
55-
logger.warning(
56-
"Failed to execute %s, error: %s",
57-
func.__name__,
58-
str(exception),
59-
)
60-
61-
return wrapper
62-
63-
6441
def extract_tool_calls(item, capture_content):
6542
tool_calls = get_property_value(item, "tool_calls")
6643
if tool_calls is None:

instrumentation/opentelemetry-instrumentation-openai-v2/tests/test_chat_completions.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright The OpenTelemetry Authors
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+
# pylint: disable=too-many-locals
15+
116
from typing import Optional
217

318
import pytest
@@ -709,7 +724,7 @@ def remove_none_values(body):
709724
for key, value in body.items():
710725
if value is None:
711726
continue
712-
elif isinstance(value, dict):
727+
if isinstance(value, dict):
713728
result[key] = remove_none_values(value)
714729
elif isinstance(value, list):
715730
result[key] = [remove_none_values(i) for i in value]

0 commit comments

Comments
 (0)