feat(profiling): label-discovery endpoint (POST /profiles/labels)#4
Closed
FrameAutomata wants to merge 2 commits into
Closed
feat(profiling): label-discovery endpoint (POST /profiles/labels)#4FrameAutomata wants to merge 2 commits into
FrameAutomata wants to merge 2 commits into
Conversation
Add POST /profiles/labels returning a map of allowlisted label key to distinct values from profiling_samples.labels, filtered by service, type, and time range. The allowlist currently exposes only "endpoint". The repository method mirrors the existing metric tag discovery (DiscoverTagValues): one DISTINCT query per allowlisted key. The shared allowlist loop lives in a build-tag-agnostic file so only the dialect-specific query is split across the pgch and sqlite builds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
distinctLabelValues called lit.RegisterModel on every request, writing lit's unsynchronized global model map while concurrent lit queries read it — a potential "concurrent map writes" fatal crash under parallel SQLite-mode requests. Register the result model once in init() via models.ExtensionModelRegistrations, matching profileGroupRow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Opened against the wrong base — superseded by the upstream PR tracewayapp#238. |
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.
What
Adds
POST /api/profiles/labels— given{fromDate, toDate, serviceName, type}, returns a map of allowlisted label key → distinct values pulled fromprofiling_samples.labels, e.g.:{ "endpoint": ["/a", "/b"] }Values are deduplicated, sorted ascending, and filtered by project, service, profile type, and time range. Empty values are excluded, and a key with no values is omitted from the response entirely.
The allowlist currently exposes a single key (
endpoint); it's a slice so adding keys later is a one-line change.Why
The dashboard profiles UI needs to discover which label values exist (e.g. which endpoints were profiled) so it can offer them as flame-graph filters. The
labelscolumn and label-based filtering already landed onmain; this PR adds the read/discovery side.How
DiscoverLabelslives in a build-tag-agnostic file (profile.repository_labels.go); it loops the allowlist and delegates each key todistinctLabelValues, which is implemented per backend: ClickHouse (labels[?], pgch build) and SQLite (json_extract, default build). This mirrors the existingMetricPointRepository.DiscoverTagValues.DiscoverLabelshandler follows the siblingGetSeries/GetFlameGraphpattern (validatesserviceName/type, 400 otherwise).models.ExtensionModelRegistrations(alongsideprofileGroupRow) rather than per request.Testing
profile_labels_test.go(SQLite build): asserts distinct + sorted values, allowlist enforcement (non-allowlistedregionexcluded), the service/type/time filters, and that a key with only empty values is omitted.default(SQLite) and-tags pgch(ClickHouse) builds compile;go vetclean.profiling_samplesrows →POST /api/profiles/labelsreturns{"endpoint":["/a","/b"]}.🤖 Generated with Claude Code