Fix account attribute to diagnostics metrics#643
Merged
daniyelnnr merged 14 commits intomasterfrom Dec 16, 2025
Merged
Conversation
Add account_name label to request metrics in otelRequestMetricsMiddleware to enable filtering and aggregation by account. Uses semantic attribute key for consistency with logs. Falls back to 'unknown' if account is not available in context.
Include account attribute in HTTP handler timing and request metrics using VTEX_ACCOUNT_NAME semantic attribute. Account is extracted from request context (ctx.vtex.account) for per-request tracking.
Include account attribute in server request metrics (total, closed, and aborted counters). Extracts account from request context for tracking request lifecycle events per account.
Include account attribute in GraphQL resolver metrics using the @Metric directive. Account is extracted from GraphQL context (ctx.vtex.account) for per-request tracking of field resolution.
Add x-vtex-account header to all outgoing HttpClient requests when account is available from IOContext. This enables downstream metrics middleware to extract account information from request headers for proper attribution of HTTP client operations.
Extract account from request headers (x-vtex-account) in HttpClient metrics middleware. Falls back to 'unknown_account' when header is not present. This enables tracking of outgoing HTTP client requests by account, matching the pattern used in logs and server-side metrics.
Change workspace type from boolean string ('true'/'false') to semantic
values ('production'/'development') in telemetry client. This aligns
with the pattern used in logger and improves metric readability.
- Added account attribute to diagnostics metrics for improved observability - Bumped version to 7.2.9-beta.0 in package.json
Updated the MAX_ATTRIBUTES constant from 5 to 7 to allow for additional attributes in diagnostics metrics, enhancing control over metric dimensions
Modified tests to reflect the new maximum attribute limit of 7 for diagnostics metrics. Adjusted expectations and warning messages accordingly to ensure accurate validation of attribute handling in various metric recording methods
- Increased maximum attributes limit for diagnostics metrics - Bumped version to 7.2.9-beta.1 in package.json
Replaced the enum definition of RequestsMetricLabels with a constant object, utilizing AttributeKeys.VTEX_ACCOUNT_NAME for the account name attribute. This change enhances consistency and maintainability in the metrics implementation.
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 PR adds account information to all diagnostics metrics (logs, HTTP handlers, GraphQL resolvers, and HTTP client operations) to enable filtering, aggregation, and analysis by account. This aligns metrics with the existing logging pattern where account context is already included.
The changes include:
account_nameattribute to request-level metrics (otelRequestMetricsMiddleware)x-vtex-accountheader in HttpClient requestsWhat problem is this solving?
Currently, diagnostics metrics lack account context, making it difficult to:
This creates a gap in observability where metrics cannot be easily attributed to specific accounts, requiring manual correlation or additional queries to understand account-specific behavior.
How should this be manually tested?
vtex.account.nameattributeScreenshots or example usage
Example metric with account attribute:
Example query filtering by account:
Types of changes