Skip to content

Reduce duplicated storage, metadata and telemetry code #1843

Open

Description

@ByteBaker

Several parts of the codebase repeat the same operations. This makes routine fixes harder to apply consistently and leaves more code to maintain.

Areas to clean up

  • Cloud storage: S3, GCS and Azure repeat much of get_objects, get_object_ranged, list_dates, list_hours, list_minutes and get_ingestor_meta_file_paths. Request counters and error propagation are also repeated.

  • Local storage: list_dirs, list_dirs_relative, list_dates, list_hours and list_minutes repeat directory scanning and filtering. Old and current stream discovery also share most of their logic.

  • Metadata handling: The role and OIDC handlers define copies of get_metadata and put_metadata, although shared versions already exist in rbac_utils. Methods such as put_dashboard, put_chat, put_filter, put_target and their delete counterparts repeat object-path persistence code.

  • Legacy migrations: v1_v4, v2_v4 and v3_v4 repeat stats and version updates. These common steps can be shared while retaining their snapshot handling.

  • Formatting and telemetry: Constant Display implementations, plain Default implementations and consecutive JSON map insertions contain boilerplate that existing derives and standard collection methods can replace.

  • Tests: JSON flattening and OpenTelemetry tests repeat fixtures, setup and assertions. Named parameterized cases can retain coverage with less repetition. Some JSON validation tests also discard the result of matches! instead of asserting it.

Proposed approach

Reuse existing helpers, extract common operations where needed, and use the existing derive and parameterized-test dependencies.

Keep provider-specific tenant paths, missing-directory behavior, metric labels, error handling, stored formats and migration behavior intact.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions