Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix metrics publishing by caching publisher command instances by both command group key + command key #1920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ali-jawad wants to merge 1 commit into Netflix:master
base: master
Choose a base branch
Loading
from ali-jawad:caching-publishers-uniquely
Open

fix metrics publishing by caching publisher command instances by both command group key + command key #1920

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ...re/src/main/java/com/netflix/hystrix/strategy/metrics/Hys trixMetricsPublisherFactory.java
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ public static void reset() {

/* package */ HystrixMetricsPublisherFactory() {}

// String is CommandKey.name() (we can't use CommandKey directly as we can't guarantee it implements hashcode/equals correctly)
private final ConcurrentHashMap commandPublishers = new ConcurrentHashMap();

/* package */ HystrixMetricsPublisherCommand getPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandOwner, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) {
// attempt to retrieve from cache first
HystrixMetricsPublisherCommand publisher = commandPublishers.get(commandKey.name());
String cacheKey = commandOwner.name() + commandKey.name();
HystrixMetricsPublisherCommand publisher = commandPublishers.get(cacheKey);
if (publisher != null) {
return publisher;
} else {
synchronized (this) {
HystrixMetricsPublisherCommand existingPublisher = commandPublishers.get(commandKey.name());
HystrixMetricsPublisherCommand existingPublisher = commandPublishers.get(cacheKey);
if (existingPublisher != null) {
return existingPublisher;
} else {
HystrixMetricsPublisherCommand newPublisher = HystrixPlugins.getInstance().getMetricsPublisher().getMetric sPublisherForCommand(commandKey, commandOwner, metrics, circuitBreaker, properties);
commandPublishers.putIfAbsent(commandKey.name(), newPublisher);
commandPublishers.putIfAbsent(cacheKey, newPublisher);
newPublisher.initialize();
return newPublisher;
}
Expand Down