Skip to content

Move Postgres log rotation parameters to the postgres package #4215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2025

Conversation

cbandy
Copy link
Member

@cbandy cbandy commented Jul 22, 2025

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • Testing enhancement

This moves the log_filename and log_rotation parameters into internal/postgres, documents how they're related, and adds some tests. 📝 The internal/collector tests don't change.

Issue: PGO-2558

@cbandy cbandy requested a review from dsessler7 July 22, 2025 18:56
Comment on lines +78 to +79
- pkg: math/rand$
desc: Use the "math/rand/v2" package instead. See https://go.dev/doc/go1.22#math_rand_v2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason behind the switch to v2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to stay away from v1, really. The v2 rand.N is generic, so it can do time.Duration without casts; that was nice.

cbandy added 3 commits July 25, 2025 17:22
The behavior of these parameters is independent of OpenTelemetry.
This refactor is part of a larger series to make the Postgres log
directory configurable.
@cbandy cbandy merged commit 26725e9 into CrunchyData:main Jul 28, 2025
20 checks passed
@cbandy cbandy deleted the log-parameters branch July 28, 2025 17:42
Comment on lines +112 to +113
prefix := strings.ReplaceAll(filePrefix, "%", "%%")
suffix := strings.ReplaceAll(fileSuffix, "%", "%%")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ we're doubling % to escape in case the prefix/suffix have % -- but ours don't, right?
and if someone forgot/missed that we're handling this and doubled the % originally, we'd quadruple the %?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ours don't, right?

Right. Escaping occurred to me as I was writing the test. I expect the postgres package to know about these details, while other packages don't.

if someone forgot/missed that we're handling this and doubled the % originally, we'd quadruple the %?

Yep. If someone thinks to escape before calling, their test would show the wacky number of escapes.

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.

3 participants