Add diagnostics-semconv to standardize some attributes and headers#579
Merged
daniyelnnr merged 17 commits intomasterfrom Sep 26, 2025
Merged
Add diagnostics-semconv to standardize some attributes and headers#579daniyelnnr merged 17 commits intomasterfrom
daniyelnnr merged 17 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the codebase to centralize HTTP header constants by replacing individual header constant imports with a unified HeaderKeys object, while also introducing an AttributeKeys object for semantic diagnostics. It updates various middleware, router, and logger files to use these new keys and removes the deprecated constant imports.
- Consolidate header constants into HeaderKeys and update usage across the codebase.
- Introduce AttributeKeys for diagnostic semantic attributes and update the Logger accordingly.
- Remove unused imports and clean up legacy constants.
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/service/worker/runtime/utils/recorder.ts | Updated header constant usage to HeaderKeys. |
| src/service/worker/runtime/utils/context.ts | Replaced legacy header keys with HeaderKeys in context setup. |
| src/service/worker/runtime/http/router.ts | Updated route header constant to HeaderKeys. |
| src/service/worker/runtime/http/middlewares/vary.ts | Replaced vary header constants with HeaderKeys. |
| src/service/worker/runtime/http/middlewares/context.ts | Updated header references to use HeaderKeys in event context. |
| src/service/worker/runtime/http/middlewares/authTokens.ts | Removed deprecated header import. |
| src/service/worker/runtime/graphql/middlewares/updateSchema.ts | Updated header constant for provider to HeaderKeys. |
| src/service/worker/runtime/graphql/middlewares/response.ts | Updated header usage to HeaderKeys for cache control and meta headers. |
| src/service/worker/runtime/events/router.ts | Replaced legacy header constant with HeaderKeys for event handlers. |
| src/service/worker/runtime/events/middlewares/context.ts | Updated event context to use HeaderKeys. |
| src/service/worker/runtime/builtIn/middlewares.ts | Updated route header constant to HeaderKeys. |
| src/service/tracing/tracingMiddlewares.ts | Replaced legacy header keys with HeaderKeys during tracing. |
| src/service/logger/logger.ts | Updated logger to use AttributeKeys for semantic attributes. |
| src/constants.ts | Introduced HeaderKeys and AttributeKeys objects and removed legacy header constants. |
| src/clients/janus/Segment.ts | Updated product header to HeaderKeys.PRODUCT. |
| src/HttpClient/middlewares/request/setupAxios/interceptors/tracing/spanSetup.ts | Updated router cache header constant to HeaderKeys.ROUTER_CACHE. |
| src/HttpClient/middlewares/cache.ts | Replaced legacy header references with HeaderKeys in cache middleware. |
| src/HttpClient/HttpClient.ts | Updated HTTP header settings to use HeaderKeys. |
Files not reviewed (1)
- package.json: Language not supported
bdbbda5 to
7546806
Compare
Also update Jest config
Tests constants and their properties, checking attributes and headers introduced by the @vtex/diagnostics-semconv package
Refactor logger module to remove usage of deprecated attribute
Remove references to deprecated `VTEX_OPERATION_ID` in constants tests
Remove deprecated constant `ATTR_VTEX_OPERATION_ID` from diagnostics-semconv mock
Updated the telemetry client to replace hardcoded attribute keys with constants from AttributeKeys
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.
What is the purpose of this pull request?
This pull request introduces a major refactor to centralize HTTP header constants into a new
HeaderKeysobject within thesrc/constants.tsfile. This change improves maintainability and reduces redundancy by replacing individual header constants with a single structured object. Additionally, it introduces a newAttributeKeysobject for semantic attributes and updates the logger to use these attributes.Dependency Additions
@vtex/diagnostics-semconv, to support semantic conventions for diagnostics and tracing attributes.Logger Enhancements
Loggerclass to use the newAttributeKeysobject for semantic attributes, such asVTEX_OPERATION_IDandVTEX_ACCOUNT_NAME, instead of plain object properties. This ensures better alignment with the diagnostics library.Cleanup and Refactoring
HeaderKeysobject, further simplifying the codebase.What problem is this solving?
Introduces
@vtex/diagnostics-semconvlibrary to support VTEX semantic conventions, in a reduced scope with respect to telemetry signals and emphasizing the context of logs. Future updates will include updates to the instrumentation using the diagnostics library, as well as the use of the semantic conventions of these signals.How should this be manually tested?
The changes do not include new features or major behavior changes, so to test the changes simply build from this branch.
Screenshots or example usage
Types of changes