|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import os |
15 | 16 | import time |
16 | 17 | from dataclasses import dataclass |
17 | 18 | from typing import Any |
18 | 19 |
|
19 | 20 | from google.adk.agents.invocation_context import InvocationContext |
| 21 | +from google.adk.agents.run_config import StreamingMode |
20 | 22 | from google.adk.events import Event |
21 | 23 | from google.adk.models.llm_request import LlmRequest |
22 | 24 | from google.adk.models.llm_response import LlmResponse |
|
34 | 36 | from typing_extensions import override |
35 | 37 |
|
36 | 38 | from veadk.config import settings |
| 39 | +from veadk.consts import DEFAULT_MODEL_AGENT_API_BASE |
37 | 40 | from veadk.tracing.telemetry.exporters.base_exporter import BaseExporter |
38 | 41 | from veadk.utils.logger import get_logger |
39 | 42 |
|
@@ -296,13 +299,16 @@ def record_call_llm( |
296 | 299 | llm_request: Request object with model and parameter details |
297 | 300 | llm_response: Response object with content and usage metadata |
298 | 301 | """ |
| 302 | + is_streaming = bool( |
| 303 | + invocation_context.run_config and invocation_context.run_config.streaming_mode != StreamingMode.NONE) |
| 304 | + server_address = getattr(invocation_context.agent, "model_api_base", None) or "unknown" |
299 | 305 | attributes = { |
300 | 306 | "gen_ai_system": "volcengine", |
301 | 307 | "gen_ai_response_model": llm_request.model, |
302 | 308 | "gen_ai_operation_name": "chat", |
303 | 309 | "gen_ai_operation_type": "llm", |
304 | | - "stream": "false", |
305 | | - "server_address": "api.volcengine.com", |
| 310 | + "stream": is_streaming, |
| 311 | + "server_address": server_address, |
306 | 312 | } # required by Volcengine APMPlus |
307 | 313 |
|
308 | 314 | if llm_response.usage_metadata: |
@@ -337,7 +343,7 @@ def record_call_llm( |
337 | 343 | if llm_response.error_code and self.chat_exception_counter: |
338 | 344 | exception_attributes = { |
339 | 345 | **attributes, |
340 | | - "error_type": llm_response.error_message, |
| 346 | + "error_type": llm_response.error_code, |
341 | 347 | } |
342 | 348 | self.chat_exception_counter.add(1, exception_attributes) |
343 | 349 |
|
|
0 commit comments