Skip to content

Conversation

@spmallette
Copy link
Owner

@spmallette spmallette commented Jun 30, 2020

@spmallette spmallette force-pushed the CASSANDRA-15909 branch 5 times, most recently from 4554c95 to eff2dc7 Compare July 10, 2020 11:47
Deprecated the old names by simply renaming the metrics but then creating a secondary alias to the same metric instance.
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

Choose a reason for hiding this comment

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

nit: unused?

return registerGauge(name, null, gauge);
}

private <T> Gauge<T> registerGauge(String name, String deprecated, Gauge<T> gauge)

Choose a reason for hiding this comment

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

nit: I'd like to avoid the "deprecated" terminology in the actual code (as opposed to in comments, where we can give hints about why aliases exist) in favor of "alias" in as many places as possible. (i.e. We have aliases, and they may exist for a number of reasons, including deprecation?) I'll expand on this in another comment in TableMetrics...

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes - i wasn't a fan of "deprecated" either.......i wasn't sure how much tolerance folks had though for more drastic changes here. i expected that could be discussed during review. i don't quite remember what else i had in mind though.

Choose a reason for hiding this comment

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

This one I think we can just change to alias. The stuff in TableMetrics (see comments there) is a more involved, but not that much more.

*
* @param deprecated The name of the deprecated metric cannot be {@code null}
*/
protected <G,T> Gauge<T> createTableGauge(String name, String alias, String deprecated, Gauge<T> gauge,

Choose a reason for hiding this comment

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

Is there any caller of this new createTableGauge() overload where name and alias aren't identical.

protected <G,T> Gauge<T> createTableGauge(String name, String alias, String deprecated, Gauge<T> gauge,
Gauge<G> globalGauge)
{
assert deprecated != null;

Choose a reason for hiding this comment

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

nit: If this is a hard pre-condition, perhaps Guava Preconditions would be a better fit. (I can't remember if OSS allows disabling assertions...)

aliasFactory.createMetricName(alias),
factory.createMetricName(deprecated),
aliasFactory.createMetricName(deprecated));
if (register(name, alias, deprecated, cfGauge) && globalGauge != null)

Choose a reason for hiding this comment

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

Does any caller actually pass a null globalGauge? Perhaps this is also better off with a precondition and not a silent failure to register the globals.

return createTableTimer(name, alias, null, keyspaceTimer);
}

protected TableTimer createTableTimer(String name, String alias, String deprecated, Timer keyspaceTimer)

Choose a reason for hiding this comment

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

Another case here where I don't think name and alias are ever not identical, and the createTableTimer(String name, String alias, Timer keyspaceTimer) overload essentially should just go away.

}

private void releaseMetric(String metricName, String metricAlias)
private void releaseMetric(String metricName, String metricAlias, String metricDeprecated)

Choose a reason for hiding this comment

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

I'd like to rename these from String metricName, String metricAlias, String metricDeprecated to something like String tableMetricName, String cfMetricName, String tableMetricAlias. It would at least try to match the reality of where the three of them live.

allTableMetrics.get(metricName).remove(metric);
Metrics.remove(name, alias);

CassandraMetricsRegistry.MetricName[] aliases = null == metricDeprecated ? new CassandraMetricsRegistry.MetricName[1] : new CassandraMetricsRegistry.MetricName[3];

Choose a reason for hiding this comment

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

nit: I'd probably just make two calls to Metrics.remove() here rather than worry about array creation with a conditional size.

* @param deprecated the deprecated name for the metric which should be {@code null} if no deprecation is required
* @return true if first time metric with that name has been registered
*/
private boolean register(String name, String alias, String deprecated, Metric metric)

Choose a reason for hiding this comment

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

Same as below, I'd consider a naming scheme like String tableMetricName, String cfMetricName, String tableMetricAlias.

@maedhroz
Copy link

I know it would blow up the diff, but it would be really nice if we could name the MetricNameFactory instances around what they do. ex. Instead of factory and aliasFactory, tableFactory and cfFactory or something similar. The only reason I'd possibly avoid that and settle for some more focused method argument renaming is that I think we really need to consider removing the "ColumnFamily" name factory altogether, and with it the metrics with "ColumnFamily" rather than "Table" in their MBean paths.

@maedhroz
Copy link

@spmallette I've created apache#728, so you can close this if you like.

@spmallette spmallette closed this Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants