Skip to content

Introduce StructuredLogKeys constants for SLF4J addKeyValue calls#5093

Open
ZephyrYWZhou wants to merge 1 commit into
apache:mainfrom
ZephyrYWZhou:structured-log-keys
Open

Introduce StructuredLogKeys constants for SLF4J addKeyValue calls#5093
ZephyrYWZhou wants to merge 1 commit into
apache:mainfrom
ZephyrYWZhou:structured-log-keys

Conversation

@ZephyrYWZhou

Copy link
Copy Markdown

Summary

Centralizes hardcoded log key strings used in addKeyValue() calls into a single StructuredLogKeys constants class in polaris-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

  • Added: polaris-core/src/main/java/org/apache/polaris/core/StructuredLogKeys.java
    • Introduces a centralized constants class containing ~55 structured log key definitions.
    • Constants are grouped by domain (table, view, namespace, credential, task, error, etc.) for easier discovery and maintenance.
  • Updated: 17 files across polaris-core and runtime/service
    • Replaced hardcoded log key strings with StructuredLogKeys.* 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

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
@ZephyrYWZhou

Copy link
Copy Markdown
Author

@dimas-b would appreciate a review when you get a chance. Thanks!

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.

Introduce structured log key constants for SLF4J addKeyValue calls

1 participant