Skip to content

Introduce structured log key constants for SLF4J addKeyValue calls #5033

Description

@ZephyrYWZhou

Is your feature request related to a problem? Please describe.

Not exactly a logic or performance issue. However, the current approach has several drawbacks:

  • Typos in log key strings can silently break log search, filtering, and alerting.
  • There is no single source of truth for available structured log keys.
  • Logging relies on hardcoded strings, creating inconsistency with the event system, which already uses constants.
  • Using raw strings prevents IDE features such as autocomplete, rename refactoring, and find-all-references, making maintenance more difficult.

Describe the solution you'd like

Introduce a centralized constants class for structured log keys, similar to how event constants are already defined:

public final class LogKeys {
    public static final String TABLE_IDENTIFIER = "tableIdentifier";
    public static final String METADATA_LOCATION = "metadataLocation";
    public static final String TABLE_LOCATIONS = "tableLocations";
    public static final String NAMESPACE = "namespace";
    public static final String VIEW_IDENTIFIER = "viewIdentifier";
    // ...
}

Then replace hardcoded string literals in addKeyValue() calls with the corresponding constants.

Before

LOGGER.atWarn()
    .addKeyValue("tableIdentifier", tableIdentifier)
    .log("...");

After

LOGGER.atWarn()
    .addKeyValue(LogKeys.TABLE_IDENTIFIER, tableIdentifier)
    .log("...");

Scope

  • Refactor approximately 102 addKeyValue() call sites across runtime/service/ and polaris-core/.
  • Consolidate approximately 30 distinct structured log key names into a single constants class.
  • No functional or behavioral changes; this is a refactoring focused on improving consistency, maintainability, and IDE support.

Describe alternatives you've considered

No response

Additional context

Questions for the community

  • Would this be a pattern the project is interested in adopting?
  • Where would you prefer these constants to live—polaris-core (for shared reuse) or runtime/service (closer to where they're consumed)?
  • Do you have any preference for the class name or its location?

If there's interest, I'd be happy to put together an implementation.

Activity

  1. added
    enhancement
    on Jul 10, 2026
  2. added a commit that references this issue on Jul 30, 2026
    a94bff0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions