Phonkee cleanup#1
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
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
promhtoph(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.
| // 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 { |
| // 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 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 on lines
+501
to
+502
| func TestRegisterFunction_SkipsNilCollectors(t *testing.T) { | ||
| // Register should not panic when encountering non-metric nested fields |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.