Skip to content

Commit 091986c

Browse files
author
Jeel Mehta
committed
Changed error printing statements to error logging statements using _logger
1 parent fc7c2f1 commit 091986c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_bedrock_patches.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
import inspect
55
import io
66
import json
7+
import logging
78
import math
89
from typing import Any, Dict, Optional
910

1011
from botocore.response import StreamingBody
1112

13+
_logger = logging.getLogger(__name__)
14+
# Set logger level to DEBUG
15+
_logger.setLevel(logging.DEBUG)
16+
1217
from amazon.opentelemetry.distro._aws_attribute_keys import (
1318
AWS_BEDROCK_AGENT_ID,
1419
AWS_BEDROCK_DATA_SOURCE_ID,
@@ -275,7 +280,7 @@ def extract_attributes(self, attributes: _AttributeMapT):
275280
self._extract_mistral_attributes(attributes, request_body)
276281

277282
except json.JSONDecodeError:
278-
print("Error: Unable to parse the body as JSON")
283+
_logger.debug("Error: Unable to parse the body as JSON")
279284

280285
def _extract_titan_attributes(self, attributes, request_body):
281286
config = request_body.get("textGenerationConfig", {})
@@ -352,9 +357,9 @@ def on_success(self, span: Span, result: Dict[str, Any]):
352357
result["body"] = StreamingBody(new_stream, len(body_content))
353358

354359
except json.JSONDecodeError:
355-
print("Error: Unable to parse the response body as JSON")
360+
_logger.debug("Error: Unable to parse the response body as JSON")
356361
except Exception as e: # pylint: disable=broad-exception-caught, invalid-name
357-
print(f"Error processing response: {str(e)}")
362+
_logger.debug(f"Error processing response: {str(e)}")
358363
finally:
359364
if original_body is not None:
360365
original_body.close()

0 commit comments

Comments
 (0)