Skip to content

Commit

Permalink
Remove silently_fail
Browse files Browse the repository at this point in the history
  • Loading branch information
xrmx committed Aug 21, 2024
1 parent 4249cbc commit 546bf65
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from opentelemetry.trace.propagation import set_span_in_context
from opentelemetry.trace.status import Status, StatusCode

from .utils import extract_content, silently_fail
from .utils import extract_content


def chat_completions_create(original_method, version, tracer: Tracer):
Expand Down Expand Up @@ -109,7 +109,6 @@ def _set_input_attributes(span, attributes):
set_span_attribute(span, field, value)


@silently_fail
def _set_response_attributes(span, kwargs, result):
set_span_attribute(span, genai.GEN_AI_RESPONSE_MODEL, result.model)
if getattr(result, "choices", None) is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging


def silently_fail(func):
"""
A decorator that catches exceptions thrown by the decorated function and logs them as warnings.
"""

logger = logging.getLogger(func.__module__)

def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as exception:
logger.warning(
"Failed to execute %s, error: %s",
func.__name__,
str(exception),
)

return wrapper


def extract_content(choice):
if not hasattr(choice, "message"):
Expand Down

0 comments on commit 546bf65

Please sign in to comment.