refactor: replace hardcoded gen_ai.* strings with OTel constants & update OTel packages#4793
Closed
refactor: replace hardcoded gen_ai.* strings with OTel constants & update OTel packages#4793
Conversation
Copilot created this pull request from a session on behalf of
zhichli
March 28, 2026 02:23
View session
zhichli
reviewed
Mar 28, 2026
Member
|
@copilot gen_ai.usage.cache_read.input_tokens i see this in this file ? |
Contributor
Author
Yes — |
…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
59cb55f to
7f4ee0e
Compare
zhichli
approved these changes
Mar 28, 2026
bpasero
approved these changes
Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace hardcoded
gen_ai.*string literals withGenAiAttr/GenAiOperationName/OTelSemConvconstants across 9 test files and 1 source file.Changes:
GenAiAttr.*,GenAiOperationName.*,OTelSemConv.METRIC_*/EVENT_*instead of raw stringsgenAiAttributes.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)@opentelemetry/semantic-conventions1.39.0 → 1.40.0@opentelemetry/*packages to latest (api 1.9.1, SDK 2.6.1, exporters 0.214.0)