Skip to content

Phonkee cleanup#1

Merged
phonkee merged 7 commits into
mainfrom
phonkee-cleanup
May 21, 2026
Merged

Phonkee cleanup#1
phonkee merged 7 commits into
mainfrom
phonkee-cleanup

Conversation

@phonkee

@phonkee phonkee commented May 20, 2026

Copy link
Copy Markdown
Owner

No description provided.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR renames the library from promh to ph and refreshes the public-facing API/docs/tests around metric declaration, registration, and validation.

Changes:

  • Renamed module/package/tag key from promh to ph (including docs and examples).
  • Refactored validation and error-path formatting; added helper for unset-field errors.
  • Expanded and modernized test suite and README (including TrackingRegistry-based assertions).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
validate.go Updates metric-type validation logic, error formatting, and skip-tag parsing.
prometheus.go Simplifies collector registration logic in the reflection-based Register.
prometheus_test.go Major test expansion covering New, embedded structs, options immutability, validate behavior, and renamers.
options.go Fixes option builder methods to avoid mutating the receiver (via cloning).
attribs.go Renames tag key constant to ph.
apply.go Updates embedded skip-tag parsing invocation.
assert.go Enhances AssertMetricExists to also check tracked descriptors for Vec metrics without observations.
testing.go Package rename to ph for TrackingRegistry.
metric.go Updates attrib parsing calls to new signature.
new.go Package rename to ph.
collector.go Package rename to ph.
logger.go Package rename to ph.
debug.go Package rename to ph.
defaults.go Package rename to ph.
error.go Package rename to ph.
reflect.go Package rename to ph.
renamer.go Package rename to ph.
must.go Package rename to ph.
panic.go Package rename to ph.
mode.go Package rename to ph.
example/example.go Updates import path and tag key to ph.
README.md Rewrites docs to match ph naming and expanded API surface.
go.mod Renames module path to github.com/phonkee/ph.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread validate.go
// ignoreSkips tells whether to ignore fields with `skip` tag, if false then it will return error if field with `skip` tag is not set
// Validate checks all the metric fields if they are set.
// withSkips controls whether fields tagged with skip=true are excluded from validation.
func Validate[T any](what *T, withSkips bool) error {
Comment thread validate.go
// Validate checks all the metric fields if they are set
// ignoreSkips tells whether to ignore fields with `skip` tag, if false then it will return error if field with `skip` tag is not set
// Validate checks all the metric fields if they are set.
// withSkips controls whether fields tagged with skip=true are excluded from validation.
Comment thread prometheus.go
Comment on lines 55 to +59
switch fieldType.Type {
case counterTyp, counterVecTyp, gaugeTyp, gaugeVecTyp, histogramTyp, histogramVecTyp:
collector = field.Interface().(prometheus.Collector)
if err := registerer.Register(field.Interface().(prometheus.Collector)); err != nil {
return err
}
Comment thread prometheus_test.go
Comment on lines +501 to +502
func TestRegisterFunction_SkipsNilCollectors(t *testing.T) {
// Register should not panic when encountering non-metric nested fields
@phonkee
phonkee merged commit 3a2584d into main May 21, 2026
1 check passed
@phonkee
phonkee deleted the phonkee-cleanup branch May 21, 2026 00:11
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.

2 participants