Skip to content

Tag stats for origin backend storage downloads by namespace#563

Merged
Anton-Kalpakchiev merged 1 commit into
masterfrom
tag_downloads_with_namespace
Feb 11, 2026
Merged

Tag stats for origin backend storage downloads by namespace#563
Anton-Kalpakchiev merged 1 commit into
masterfrom
tag_downloads_with_namespace

Conversation

@Anton-Kalpakchiev

Copy link
Copy Markdown
Collaborator

One of the most useful metrics to track our usage patterns is the namespace - we even talk to different storage backends based on it (GCS, Terrablob, UPT, etc.). Therefore, I'm tagging the latency and number of downloads from remote storage backends by namespace, so we can get more insight into how Kraken is used.

Copilot AI review requested due to automatic review settings February 10, 2026 16:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds namespace tagging to remote-backend blob download metrics so origin storage usage/latency can be analyzed per namespace.

Changes:

  • Tag download_remote_blob timer metric with namespace.
  • Tag downloads counter metric with namespace.

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

Comment on lines +121 to +122
r.stats.Tagged(map[string]string{"namespace": namespace}).
Counter("downloads").Inc(1)

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

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

Tagging these metrics with the raw namespace value can create very high-cardinality time series (e.g., default configs include a catch-all backend rule namespace: .*, and origin endpoints accept namespace from request params). This can significantly increase metrics load/cost and may destabilize the metrics backend; consider tagging by a bounded dimension instead (such as matched backend rule / backend type, or a normalized namespace prefix) or explicitly documenting/enforcing an allowlist of namespaces to tag.

Copilot uses AI. Check for mistakes.
Comment on lines +115 to +116
r.stats.Tagged(map[string]string{"namespace": namespace}).
Timer("download_remote_blob").Record(t)

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

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

r.stats.Tagged(map[string]string{"namespace": namespace}) is called repeatedly (also again for the downloads counter below), which creates a new scope and allocates a new map each time. Consider creating a single namespaceStats := r.stats.Tagged(...) once in the closure and reusing it for both the timer and counter to reduce allocations and keep tagging consistent in one place.

Copilot uses AI. Check for mistakes.

@thijmv thijmv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Anton-Kalpakchiev Anton-Kalpakchiev merged commit f0db0cf into master Feb 11, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants