Introduce StructuredLogKeys constants for SLF4J addKeyValue calls#5093
Open
ZephyrYWZhou wants to merge 1 commit into
Open
Introduce StructuredLogKeys constants for SLF4J addKeyValue calls#5093ZephyrYWZhou wants to merge 1 commit into
ZephyrYWZhou wants to merge 1 commit into
Conversation
Centralize hardcoded log key strings used in addKeyValue() calls into a single StructuredLogKeys constants class. This prevents typos, enables IDE autocomplete and find-all-references, and provides a single source of truth for structured log key names used in search and alerting. Replaces ~100 hardcoded string literals across 17 files with references to constants in StructuredLogKeys. The 4 remaining dynamic expression-based keys (e.g., 'entity.getTableIdentifier()') are left as-is since they represent variable names rather than stable log keys. Fixes apache#5033
Author
|
@dimas-b would appreciate a review when you get a chance. Thanks! |
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.
Summary
Centralizes hardcoded log key strings used in
addKeyValue()calls into a singleStructuredLogKeysconstants class inpolaris-core.Fixes #5033.
Problem
Around 100
addKeyValue()calls across the codebase use hardcoded string literals for structured log key names (for example,"tableIdentifier"and"metadataLocation"). This makes typos difficult to catch, prevents IDE autocomplete and find-all-references, and leaves no single source of truth for log keys used in search, dashboards, and alerting.Changes
polaris-core/src/main/java/org/apache/polaris/core/StructuredLogKeys.javapolaris-coreandruntime/serviceStructuredLogKeys.*constants.Four expression-based keys (for example,
entity.getTableIdentifier()) are intentionally left unchanged because they represent dynamically generated field names rather than stable structured log keys.Testing
No behavioral changes. This is a refactoring only. Compilation succeeds, and the generated structured log output is identical before and after the change.
Checklist
StructuredLogKeys