Skip to content

Conversation

@fdc310
Copy link
Member

@fdc310 fdc310 commented Jan 1, 2026

…ation

概述 / Overview

请在此部分填写你实现/解决/优化的内容:
Summary of what you implemented/solved/optimized:

增加了遥测数据上传,将使用运行器,模型,运行时间和适配器及使用版本和错误上传

更改前后对比截图 / Screenshots

请在此部分粘贴更改前后对比截图(可以是界面截图、控制台输出、对话截图等):
Please paste the screenshots of changes before and after here (can be interface screenshots, console output, conversation screenshots, etc.):

修改前 / Before:

修改后 / After:

检查清单 / Checklist

PR 作者完成 / For PR author

请在方括号间写x以打勾 / Please tick the box with x

  • 阅读仓库贡献指引了吗? / Have you read the contribution guide?
  • 与项目所有者沟通过了吗? / Have you communicated with the project maintainer?
  • 我确定已自行测试所作的更改,确保功能符合预期。 / I have tested the changes and ensured they work as expected.

项目维护者完成 / For project maintainer

  • 相关 issues 链接了吗? / Have you linked the related issues?
  • 配置项写好了吗?迁移写好了吗?生效了吗? / Have you written the configuration items? Have you written the migration? Has it taken effect?
  • 依赖加到 pyproject.toml 和 core/bootutils/deps.py 了吗 / Have you added the dependencies to pyproject.toml and core/bootutils/deps.py?
  • 文档编写了吗? / Have you written the documentation?

RockChinQ and others added 24 commits December 25, 2025 20:54
…alog components with icons for vision and function call
… and update related logic across the application
…refactor UserService to utilize new service methods
…ent Space model synchronization in ModelManager
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. eh: Feature enhance: 新功能添加 / add new features pd: Need testing pending: 待测试的PR / PR waiting to be tested labels Jan 1, 2026
…e availability and update related components
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds telemetry support to track query execution metrics and send them to a configurable remote server. The implementation collects runtime statistics including adapter type, runner name, model name, execution duration, errors, and version information, then asynchronously uploads this data to a Space server.

  • Added telemetry configuration section with enabled flag and server URL
  • Implemented async telemetry reporting module with payload sanitization and error handling
  • Integrated telemetry collection into the chat query handler to track execution metrics

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 13 comments.

File Description
src/langbot/templates/config.yaml Added telemetry configuration section with enabled flag and server URL settings
src/langbot/pkg/telemetry/telemetry.py New module implementing async telemetry payload sending with sanitization and timeout handling
src/langbot/pkg/telemetry/init.py Empty init file for telemetry package
src/langbot/pkg/pipeline/process/handlers/chat.py Integrated telemetry tracking into query handler to collect execution metrics in finally block

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +168 to +169
if 'start_ts' in locals():
duration_ms = int((end_ts - start_ts) * 1000)
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using locals() to check for variable existence is fragile and can lead to unexpected behavior. The start_ts variable is always defined on line 92 before any exception can occur, so this check using 'start_ts' in locals() is unnecessary. If there's concern about exceptions happening before line 92, the code should use a different pattern such as initializing start_ts to None before the try block and checking if start_ts is not None.

Copilot uses AI. Check for mistakes.
'model_name': model_name,
'version': semantic_version,
'pipeline_plugins': pipeline_plugins,
'error': locals().get('error_info', None),
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using locals().get('error_info', None) to retrieve error_info is fragile and indirect. The error_info variable is only set within the exception handler on line 150, so it won't exist in the finally block unless an exception occurred. A clearer approach would be to initialize error_info = None before the try block and set it in the except block, making the code more explicit and maintainable.

Copilot uses AI. Check for mistakes.
Comment on lines 14 to 16
- timeout_seconds: optional int, overall request timeout (default 5)
Posts to {server.rstrip('/')}/api/v1/telemetry as JSON. Failures are logged but do not raise.
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring mentions a timeout_seconds configuration parameter that doesn't appear to be used in the implementation. The actual code uses a hardcoded timeout of 10 seconds on lines 52 and 55. Either implement support for the documented timeout_seconds parameter or remove it from the docstring to avoid confusion.

Copilot uses AI. Check for mistakes.
Comment on lines 78 to 97
print('Exception during telemetry send:')
import traceback
traceback.print_exc()
except Exception as e:
try:
ap.logger.warning(f'Failed to create HTTP client for telemetry or sanitize payload: {e}', exc_info=True)
except Exception:
pass
print('Exception while creating HTTP client for telemetry:')
import traceback
traceback.print_exc()
except Exception as e:
# Never raise from telemetry; surface as warning for visibility
try:
ap.logger.warning(f'Unexpected telemetry error: {e}', exc_info=True)
except Exception:
pass
print('Unexpected telemetry error:')
import traceback
traceback.print_exc()
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The print statements and traceback.print_exc() calls should be removed or replaced with proper logging. These debug print statements are inappropriate for production code and will clutter stdout/stderr. The exception is already being logged with exc_info=True on line 83, which provides the same traceback information through the proper logging system.

Suggested change
print('Exception during telemetry send:')
import traceback
traceback.print_exc()
except Exception as e:
try:
ap.logger.warning(f'Failed to create HTTP client for telemetry or sanitize payload: {e}', exc_info=True)
except Exception:
pass
print('Exception while creating HTTP client for telemetry:')
import traceback
traceback.print_exc()
except Exception as e:
# Never raise from telemetry; surface as warning for visibility
try:
ap.logger.warning(f'Unexpected telemetry error: {e}', exc_info=True)
except Exception:
pass
print('Unexpected telemetry error:')
import traceback
traceback.print_exc()
except Exception as e:
try:
ap.logger.warning(f'Failed to create HTTP client for telemetry or sanitize payload: {e}', exc_info=True)
except Exception:
pass
except Exception as e:
# Never raise from telemetry; surface as warning for visibility
try:
ap.logger.warning(f'Unexpected telemetry error: {e}', exc_info=True)
except Exception:
pass

Copilot uses AI. Check for mistakes.
Comment on lines 78 to 97
print('Exception during telemetry send:')
import traceback
traceback.print_exc()
except Exception as e:
try:
ap.logger.warning(f'Failed to create HTTP client for telemetry or sanitize payload: {e}', exc_info=True)
except Exception:
pass
print('Exception while creating HTTP client for telemetry:')
import traceback
traceback.print_exc()
except Exception as e:
# Never raise from telemetry; surface as warning for visibility
try:
ap.logger.warning(f'Unexpected telemetry error: {e}', exc_info=True)
except Exception:
pass
print('Unexpected telemetry error:')
import traceback
traceback.print_exc()
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The print statements and traceback.print_exc() calls should be removed or replaced with proper logging. These debug print statements are inappropriate for production code and will clutter stdout/stderr. The exception is already being logged with exc_info=True on line 92, which provides the same traceback information through the proper logging system.

Suggested change
print('Exception during telemetry send:')
import traceback
traceback.print_exc()
except Exception as e:
try:
ap.logger.warning(f'Failed to create HTTP client for telemetry or sanitize payload: {e}', exc_info=True)
except Exception:
pass
print('Exception while creating HTTP client for telemetry:')
import traceback
traceback.print_exc()
except Exception as e:
# Never raise from telemetry; surface as warning for visibility
try:
ap.logger.warning(f'Unexpected telemetry error: {e}', exc_info=True)
except Exception:
pass
print('Unexpected telemetry error:')
import traceback
traceback.print_exc()
except Exception as e:
try:
ap.logger.warning(f'Failed to create HTTP client for telemetry or sanitize payload: {e}', exc_info=True)
except Exception:
pass
except Exception as e:
# Never raise from telemetry; surface as warning for visibility
try:
ap.logger.warning(f'Unexpected telemetry error: {e}', exc_info=True)
except Exception:
pass

Copilot uses AI. Check for mistakes.
Comment on lines 52 to 55
async with httpx.AsyncClient(timeout=httpx.Timeout(10)) as client:
try:
# Use asyncio.wait_for to ensure we always bound the total time
resp = await asyncio.wait_for(client.post(url, json=sanitized), timeout=10 + 1)
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is redundant timeout handling here. The timeout value of 10 seconds is specified twice - once in the httpx.Timeout(10) and again in asyncio.wait_for with timeout=10+1. This creates confusion and the asyncio.wait_for timeout should align with the httpx timeout or use a configuration value. Additionally, the hardcoded timeout value of 10 seconds should be extracted as a configurable parameter or at least a named constant for maintainability.

Copilot uses AI. Check for mistakes.

import asyncio
import httpx
import typing
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'typing' is not used.

Suggested change
import typing

Copilot uses AI. Check for mistakes.
if isinstance(j, dict) and j.get('code') is not None and int(j.get('code')) >= 400:
app_err = True
ap.logger.warning(f'Telemetry post to {url} returned application error code {j.get("code")} - {j.get("msg")}')
except Exception:
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'except' clause does nothing but pass and there is no explanatory comment.

Suggested change
except Exception:
except Exception:
# Ignore JSON parsing / shape errors; treat as no structured app-level error

Copilot uses AI. Check for mistakes.
except Exception as e:
try:
ap.logger.warning(f'Failed to create HTTP client for telemetry or sanitize payload: {e}', exc_info=True)
except Exception:
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
# Never raise from telemetry; surface as warning for visibility
try:
ap.logger.warning(f'Unexpected telemetry error: {e}', exc_info=True)
except Exception:
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'except' clause does nothing but pass and there is no explanatory comment.

Suggested change
except Exception:
except Exception:
# If logging itself fails, ignore the error to avoid raising from telemetry.

Copilot uses AI. Check for mistakes.
RockChinQ and others added 16 commits January 1, 2026 17:01
…lugin market, and roadmap across multiple languages
refactor: model config dialog and introduce LangBot Models service integration
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eh: Feature enhance: 新功能添加 / add new features pd: Need testing pending: 待测试的PR / PR waiting to be tested size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants