Skip to content

Commit

Permalink
removed cortex_ and thanos_ prefixes from memcached metrics names
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Ángel Ortuño <ortuman@gmail.com>
  • Loading branch information
ortuman committed Dec 12, 2022
1 parent 4fd8d8f commit 6a40d0f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
6 changes: 3 additions & 3 deletions cache/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ func WrapWithLRUCache(c Cache, name string, reg prometheus.Registerer, lruSize i
defaultTTL: defaultTTL,

requests: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "cortex_cache_memory_requests_total",
Name: "cache_memory_requests_total",
Help: "Total number of requests to the in-memory cache.",
ConstLabels: map[string]string{"name": name},
}),
hits: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "cortex_cache_memory_hits_total",
Name: "cache_memory_hits_total",
Help: "Total number of requests to the in-memory cache that were a hit.",
ConstLabels: map[string]string{"name": name},
}),
}

cache.items = promauto.With(reg).NewGaugeFunc(prometheus.GaugeOpts{
Name: "cortex_cache_memory_items_count",
Name: "cache_memory_items_count",
Help: "Total number of items currently in the in-memory cache.",
ConstLabels: map[string]string{"name": name},
}, func() float64 {
Expand Down
26 changes: 13 additions & 13 deletions cache/lru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ func TestLRUCache_StoreFetch(t *testing.T) {
require.True(t, time.Until(item.(*Item).ExpiresAt) > 1*time.Hour)

require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
# HELP cortex_cache_memory_items_count Total number of items currently in the in-memory cache.
# TYPE cortex_cache_memory_items_count gauge
cortex_cache_memory_items_count{name="test"} 3
# HELP cortex_cache_memory_hits_total Total number of requests to the in-memory cache that were a hit.
# TYPE cortex_cache_memory_hits_total counter
cortex_cache_memory_hits_total{name="test"} 2
# HELP cortex_cache_memory_requests_total Total number of requests to the in-memory cache.
# TYPE cortex_cache_memory_requests_total counter
cortex_cache_memory_requests_total{name="test"} 4
# HELP cache_memory_items_count Total number of items currently in the in-memory cache.
# TYPE cache_memory_items_count gauge
cache_memory_items_count{name="test"} 3
# HELP cache_memory_hits_total Total number of requests to the in-memory cache that were a hit.
# TYPE cache_memory_hits_total counter
cache_memory_hits_total{name="test"} 2
# HELP cache_memory_requests_total Total number of requests to the in-memory cache.
# TYPE cache_memory_requests_total counter
cache_memory_requests_total{name="test"} 4
`)))
}

Expand All @@ -72,8 +72,8 @@ func TestLRUCache_Evictions(t *testing.T) {
}, time.Minute)

require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
# HELP cortex_cache_memory_items_count Total number of items currently in the in-memory cache.
# TYPE cortex_cache_memory_items_count gauge
cortex_cache_memory_items_count{name="test"} 2
`), "cortex_cache_memory_items_count"))
# HELP cache_memory_items_count Total number of items currently in the in-memory cache.
# TYPE cache_memory_items_count gauge
cache_memory_items_count{name="test"} 2
`), "cache_memory_items_count"))
}
4 changes: 2 additions & 2 deletions cache/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func NewMemcachedCache(name string, logger log.Logger, memcached cacheutil.Remot
}

c.requests = promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "thanos_cache_memcached_requests_total",
Name: "cache_memcached_requests_total",
Help: "Total number of items requests to memcached.",
ConstLabels: prometheus.Labels{"name": name},
})

c.hits = promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "thanos_cache_memcached_hits_total",
Name: "cache_memcached_hits_total",
Help: "Total number of items requests to the cache that were a hit.",
ConstLabels: prometheus.Labels{"name": name},
})
Expand Down
2 changes: 0 additions & 2 deletions cache/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
)

// SpanlessTracingCache wraps a Cache and logs Fetch operation in the parent spans.
// This is different than Thanos' TracingCache because this logs in the parent span
// without creating a new span.
type SpanlessTracingCache struct {
c Cache
resolver spanlogger.TenantResolver
Expand Down
16 changes: 8 additions & 8 deletions cacheutil/memcached_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func newMemcachedClient(
) (*memcachedClient, error) {
addressProvider := dns.NewProvider(
logger,
prometheus.WrapRegistererWithPrefix("thanos_memcached_", reg),
prometheus.WrapRegistererWithPrefix("memcached_", reg),
dns.MiekgdnsResolverType,
)

Expand All @@ -272,13 +272,13 @@ func newMemcachedClient(
asyncQueue: make(chan func(), config.MaxAsyncBufferSize),
stop: make(chan struct{}, 1),
getMultiGate: gate.New(
prometheus.WrapRegistererWithPrefix("thanos_memcached_getmulti_", reg),
prometheus.WrapRegistererWithPrefix("memcached_getmulti_", reg),
config.MaxGetMultiConcurrency,
),
}

c.clientInfo = promauto.With(reg).NewGaugeFunc(prometheus.GaugeOpts{
Name: "thanos_memcached_client_info",
Name: "memcached_client_info",
Help: "A metric with a constant '1' value labeled by configuration options from which memcached client was configured.",
ConstLabels: prometheus.Labels{
"timeout": config.Timeout.String(),
Expand All @@ -295,15 +295,15 @@ func newMemcachedClient(
)

c.operations = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "thanos_memcached_operations_total",
Name: "memcached_operations_total",
Help: "Total number of operations against memcached.",
}, []string{"operation"})
c.operations.WithLabelValues(opGetMulti)
c.operations.WithLabelValues(opSet)
c.operations.WithLabelValues(opDelete)

c.failures = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "thanos_memcached_operation_failures_total",
Name: "memcached_operation_failures_total",
Help: "Total number of operations against memcached that failed.",
}, []string{"operation", "reason"})
for _, op := range []string{opGetMulti, opSet, opDelete} {
Expand All @@ -315,15 +315,15 @@ func newMemcachedClient(
}

c.skipped = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "thanos_memcached_operation_skipped_total",
Name: "memcached_operation_skipped_total",
Help: "Total number of operations against memcached that have been skipped.",
}, []string{"operation", "reason"})
c.skipped.WithLabelValues(opGetMulti, reasonMaxItemSize)
c.skipped.WithLabelValues(opSet, reasonMaxItemSize)
c.skipped.WithLabelValues(opSet, reasonAsyncBufferFull)

c.duration = promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
Name: "thanos_memcached_operation_duration_seconds",
Name: "memcached_operation_duration_seconds",
Help: "Duration of operations against memcached.",
Buckets: []float64{0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.2, 0.5, 1, 3, 6, 10},
}, []string{"operation"})
Expand All @@ -332,7 +332,7 @@ func newMemcachedClient(
c.duration.WithLabelValues(opDelete)

c.dataSize = promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
Name: "thanos_memcached_operation_data_size_bytes",
Name: "memcached_operation_data_size_bytes",
Help: "Tracks the size of the data stored in and fetched from memcached.",
Buckets: []float64{
32, 256, 512, 1024, 32 * 1024, 256 * 1024, 512 * 1024, 1024 * 1024, 32 * 1024 * 1024, 256 * 1024 * 1024, 512 * 1024 * 1024,
Expand Down

0 comments on commit 6a40d0f

Please sign in to comment.