豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

refactor: replace hardcoded gen_ai.* strings with OTel constants & update OTel packages#4793

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/replace-gen-ai-constants
Closed

refactor: replace hardcoded gen_ai.* strings with OTel constants & update OTel packages#4793
Copilot wants to merge 3 commits intomainfrom
copilot/replace-gen-ai-constants

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

Replace hardcoded gen_ai.* string literals with GenAiAttr/GenAiOperationName/OTelSemConv constants across 9 test files and 1 source file.

Changes:

  • Test files: use GenAiAttr.*, GenAiOperationName.*, OTelSemConv.METRIC_*/EVENT_* instead of raw strings
  • genAiAttributes.ts: 3 previously-custom attributes now use standard constants from v1.40.0 (USAGE_CACHE_READ_INPUT_TOKENS, USAGE_CACHE_CREATION_INPUT_TOKENS, AGENT_VERSION)
  • Update @opentelemetry/semantic-conventions 1.39.0 → 1.40.0
  • Update all other @opentelemetry/* packages to latest (api 1.9.1, SDK 2.6.1, exporters 0.214.0)

Comment thread src/platform/otel/common/genAiAttributes.ts Outdated
@zhichli
Copy link
Copy Markdown
Member

zhichli commented Mar 28, 2026

@copilot gen_ai.usage.cache_read.input_tokens i see this in this file ?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 28, 2026

@copilot gen_ai.usage.cache_read.input_tokens i see this in this file ?

Yes — gen_ai.usage.cache_read.input_tokens (line 71), gen_ai.usage.cache_creation.input_tokens (line 73), gen_ai.usage.reasoning_tokens (line 75), and gen_ai.agent.version (line 88) are kept as hardcoded strings because they don't exist in @opentelemetry/semantic-conventions yet. The /** Custom: not yet standardized ... */ JSDoc comments mark each one. Once the OTel lib adds them, we can swap them to OTelSemConv.* references.

@zhichli zhichli changed the title Replace hardcoded gen_ai.* strings with @opentelemetry/semantic-conventions constants refactor: replace hardcoded gen_ai.* strings with OTel constants & update OTel packages Mar 28, 2026
Copilot AI and others added 3 commits March 27, 2026 22:48
…ons library imports

- genAiAttributes.ts: Import ATTR_GEN_AI_* from @opentelemetry/semantic-conventions/incubating
  and ATTR_ERROR_TYPE/ATTR_SERVER_* from @opentelemetry/semantic-conventions stable.
  Replace all hardcoded gen_ai.* strings in GenAiAttr, GenAiOperationName, GenAiProviderName,
  GenAiTokenType, and StdAttr with OTel library constants. Keep custom attributes
  (cache, reasoning, agent.version) that are not yet standardized.
- genAiEvents.ts: Use ATTR_EVENT_NAME and EVENT_GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS
  from OTel library instead of hardcoded strings.
- genAiMetrics.ts: Use METRIC_GEN_AI_CLIENT_OPERATION_DURATION and
  METRIC_GEN_AI_CLIENT_TOKEN_USAGE from OTel library.
- otelChatDebugLogProvider.ts: Replace hardcoded gen_ai.* attribute strings
  with GenAiAttr/GenAiOperationName/CopilotChatAttr constants.

Agent-Logs-Url: https://github.com/microsoft/vscode-copilot-chat/sessions/aaf7dc17-ec13-4d9a-8507-4acb95edbcbd

Co-authored-by: zhichli <57812115+zhichli@users.noreply.github.com>
…try/semantic-conventions/incubating'

Replace individual named imports with a single namespace import across
genAiAttributes.ts, genAiEvents.ts, and genAiMetrics.ts. The incubating
path re-exports stable attributes, so we no longer need a separate
import from '@opentelemetry/semantic-conventions'.

Agent-Logs-Url: https://github.com/microsoft/vscode-copilot-chat/sessions/ecec45d9-0757-4cdb-b478-62d2f1d273f8

Co-authored-by: zhichli <57812115+zhichli@users.noreply.github.com>
…ntion constants

- Replace hardcoded gen_ai.* attribute strings in 9 test files with
  GenAiAttr/GenAiOperationName/OTelSemConv constants
- Update genAiAttributes.ts: use new v1.40.0 standard constants for
  USAGE_CACHE_READ_INPUT_TOKENS, USAGE_CACHE_CREATION_INPUT_TOKENS,
  and AGENT_VERSION (previously custom)
- Update @opentelemetry/semantic-conventions from 1.39.0 to 1.40.0
- Update all other @opentelemetry packages to latest versions
@zhichli zhichli force-pushed the copilot/replace-gen-ai-constants branch from 59cb55f to 7f4ee0e Compare March 28, 2026 05:48
@zhichli zhichli marked this pull request as ready for review March 28, 2026 05:49
@zhichli zhichli requested review from Copilot and removed request for Copilot March 28, 2026 05:49
@zhichli zhichli enabled auto-merge March 28, 2026 05:49
@zhichli zhichli added this pull request to the merge queue Mar 28, 2026
@zhichli zhichli removed this pull request from the merge queue due to a manual request Mar 28, 2026
@zhichli zhichli closed this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants