Skip to content

Replace deprecated strings.Title() in scheduler metrics #4776

@dejanzele

Description

@dejanzele

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

strings.Title() is deprecated since Go 1.18 and we still use it in two places in the scheduler metrics code.

Describe the solution you'd like

Replace both calls with cases.Title(language.English).String(...) from golang.org/x/text/cases and golang.org/x/text/language.

Files to change

  • internal/scheduler/metrics.go:484 - strings.Title(strings.ToLower(phase))
  • internal/scheduler/metrics.go:493 - strings.Title(strings.ToLower(phase))

Example

// Before
phase: strings.Title(strings.ToLower(phase)),

// After
phase: cases.Title(language.English).String(strings.ToLower(phase)),

The cases.Title caser is safe for concurrent use, so you can create it once as a package-level variable rather than creating a new one on every call.

Acceptance criteria

  • Both strings.Title() calls replaced
  • No strings.Title import remains
  • go test ./internal/scheduler/... passes
  • golangci-lint run ./internal/scheduler/... passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    component/schedulingArmada Server, Scheduler and Scheduler Injestergood first issueGood for newcomerslanguage/goPull requests that update Go code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions