This repository has been archived by the owner on Mar 27, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metrics to track memcached performance
- Loading branch information
Showing
10 changed files
with
178 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
33 changes: 33 additions & 0 deletions
33
heroic-component/src/main/java/com/spotify/heroic/statistics/MemcachedReporter.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2018 Spotify AB. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.spotify.heroic.statistics; | ||
|
||
public interface MemcachedReporter { | ||
|
||
void reportMemcachedHit(); | ||
|
||
void reportMemcachedMiss(); | ||
|
||
void reportMemcachedTimeout(); | ||
|
||
void reportMemcachedError(); | ||
} |
This file contains 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
36 changes: 36 additions & 0 deletions
36
heroic-component/src/main/java/com/spotify/heroic/statistics/noop/NoopMemcachedReporter.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.spotify.heroic.statistics.noop; | ||
|
||
import com.spotify.heroic.statistics.MemcachedReporter; | ||
|
||
public class NoopMemcachedReporter implements MemcachedReporter { | ||
|
||
private NoopMemcachedReporter() { | ||
} | ||
|
||
@Override | ||
public void reportMemcachedHit() { | ||
|
||
} | ||
|
||
@Override | ||
public void reportMemcachedMiss() { | ||
|
||
} | ||
|
||
@Override | ||
public void reportMemcachedTimeout() { | ||
|
||
} | ||
|
||
@Override | ||
public void reportMemcachedError() { | ||
|
||
} | ||
|
||
private static final NoopMemcachedReporter instance = new NoopMemcachedReporter(); | ||
|
||
public static NoopMemcachedReporter get() { | ||
return instance; | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
76 changes: 76 additions & 0 deletions
76
...antic/src/main/java/com/spotify/heroic/statistics/semantic/SemanticMemcachedReporter.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2018 Spotify AB. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.spotify.heroic.statistics.semantic; | ||
|
||
import com.codahale.metrics.Meter; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import com.spotify.heroic.statistics.MemcachedReporter; | ||
import com.spotify.metrics.core.MetricId; | ||
import com.spotify.metrics.core.SemanticMetricRegistry; | ||
import io.opencensus.internal.PublicForTesting; | ||
import lombok.ToString; | ||
|
||
@ToString(of = {}) | ||
@VisibleForTesting | ||
public class SemanticMemcachedReporter implements MemcachedReporter { | ||
|
||
private static final String COMPONENT = "memcached"; | ||
|
||
@VisibleForTesting | ||
private final Meter memcachedHit; | ||
@PublicForTesting | ||
private final Meter memcachedMiss; | ||
@PublicForTesting | ||
private final Meter memcachedTimeout; | ||
@PublicForTesting | ||
private final Meter memcachedError; | ||
|
||
public SemanticMemcachedReporter(SemanticMetricRegistry registry, final String consumerType) { | ||
final MetricId id = MetricId.build().tagged("component", COMPONENT, "consumer", consumerType); | ||
|
||
memcachedHit = registry.meter(id.tagged("what", "memcached-performance", "result", | ||
"hit")); | ||
memcachedMiss = registry.meter(id.tagged("what", "memcached-performance", "result", | ||
"miss")); | ||
memcachedTimeout = registry.meter(id.tagged("what", "memcached-performance", "result", | ||
"timeout")); | ||
|
||
memcachedError = registry.meter(id.tagged("what", "memcached-performance", "result", | ||
"error")); | ||
|
||
|
||
} | ||
|
||
|
||
@Override | ||
public void reportMemcachedHit() { memcachedHit.mark(); } | ||
|
||
@Override | ||
public void reportMemcachedMiss() { memcachedMiss.mark(); } | ||
|
||
@Override | ||
public void reportMemcachedTimeout() { memcachedTimeout.mark(); } | ||
|
||
@Override | ||
public void reportMemcachedError() { memcachedError.mark(); } | ||
} | ||
|
This file contains 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