-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Support "on-by-config" features in usage tracking #65345
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
Support "on-by-config" features in usage tracking #65345
Conversation
The existing FeatureUsage API tracks the last time that a feature was used. This is useful for most features, but some features like security realms are on by virtue of being configured on the node, and their use is not tracked by events but simply by being turned on. This change modifies the feature tracking to support turning a feature on permanently, so that the last used time is always returned as "now". It also supports having identifiers for such "always on" features, so that callers can understand what entity in elasticsearch cause the feature to be tracked as on (e.g. the name of the security realm).
|
Pinging @elastic/es-security (Team:Security) |
|
This is just the tracking side of the change - it doesn't actually enable it for any licensed features. @rjernst I opted to go with an explicit method call, rather than a defined list of features for a couple of reasons:
|
ywangd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments/discussion points.
| public FeatureUsage(Feature feature, long lastUsed, Set<String> identifiers) { | ||
| this.feature = feature; | ||
| this.lastUsed = lastUsed; | ||
| this.identifiers = Objects.requireNonNull(identifiers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, most feature usages have no identifier. Would it be better to allow null for identifiers, which in turn can be skipped in the final response returned to users instead of cluttering the response with "identifiers": []?
| return isAllowedByLicense(minimumMode, true); | ||
| } | ||
|
|
||
| public static class FeatureUsage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class has no explicit info about whether the feature is "on-by-default". Does it matter? Or it's more of a documentation issue?
| public synchronized boolean setFeatureActive(Feature feature, String... identifiers) { | ||
| boolean allowed = checkFeature(feature); | ||
| if (allowed && isTrackableFeature(feature)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few interesting points here:
- Do we need a pairing
unsetmethod? This could be useful if we have any "on-by-configuration" features that can turned on and off on the fly? Or if the license expires or gets deleted or is somehow downgraded, I assume it's the caller's responsibility to call theunsetmethod so it's removed from the tracking? Or should unlicensed features be filtered out atgetFeatureUsagetime? - If the feature is not trackable, should we throw an
asserterror to notify the developer that license is not configured correctly? - How can we ensure that every "on-by-default" feature (past and future) is indeed registered with this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could simplify this a bit by not needing to distinguish between "always on" and tracked features within code, but just in the storage of the tracked values and in the output of the feature usage response.
The general idea would be to continue to use the feature -> long map, but set the value to -1 if the feature is "always on" (defined in the Feature enum). Then in serialization, the lastUsedTime becomes an optional, and if it is null, we do not output it. One advantage to this approach is the license checking methods do not need to change, and how it is tracked continues to be an implementation detail relevant to the particular feature.
|
I think we could do something to remove the need to store 2 feature maps if we wanted. However, attempting to do this transparently creates an issue of the identifiers part of the change. So, at the very least we'd need something like: That doesn't have to turn the feature "on", but the calling code isn't made any simpler, shorter or less-entangled in licensing by taking that approach. |
|
I concede the point about identifiers necessitating a new way to mark the feature as used. However, I would rather do this through an overload of checkFeature. I see the value in using two maps for that purpose, but I don't think we need a separate concept naming wise, just an assertion that the identifier variant is used with a persistent feature (which can still be noted in the Feature enum values). |
|
I've dropped the |
|
Closing this PR. We're taking a different direction. |
The existing FeatureUsage API tracks the last time that a feature was
used. This is useful for most features, but some features like
security realms are on by virtue of being configured on the node, and
their use is not tracked by events but simply by being turned on.
This change modifies the feature tracking to support turning a feature
on permanently, so that the last used time is always returned as
"now".
It also supports having identifiers for such "always on" features, so
that callers can understand what entity in elasticsearch caused the
feature to be tracked as on (e.g. the name of the security realm).