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
Enable Universal Profiling as Enterprise feature #100333
Merged
danielmitterdorfer
merged 11 commits into
elastic:main
from
danielmitterdorfer:profiling-enterprise-license
Oct 9, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d930fc5
Enable Universal Profiling as Enterprise feature
danielmitterdorfer 80d7c4c
Update docs/changelog/100333.yaml
danielmitterdorfer 10b1db4
Add Universal Profiling in xpack info / usage API tests
danielmitterdorfer 2896896
Remove trailing comma
danielmitterdorfer a37dc3e
Remove custom flag from status API again
danielmitterdorfer af6234b
Use correct transport version
danielmitterdorfer 78e3bd5
Add missing operator constants
danielmitterdorfer b0df8cc
Merge remote-tracking branch 'origin/main' into profiling-enterprise-…
danielmitterdorfer 8ef3b35
Merge branch 'main' into profiling-enterprise-license
elasticmachine 1518e35
Register ProfilingUsage as named writeable
danielmitterdorfer 1167501
Merge remote-tracking branch 'origin/main' into profiling-enterprise-…
danielmitterdorfer File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 100333 | ||
summary: Enable Universal Profiling as Enterprise feature | ||
area: Application | ||
type: enhancement | ||
issues: [] |
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
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
31 changes: 31 additions & 0 deletions
31
...ck/plugin/core/src/main/java/org/elasticsearch/xpack/core/application/ProfilingUsage.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,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.application; | ||
|
||
import org.elasticsearch.TransportVersion; | ||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.xpack.core.XPackFeatureSet; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
|
||
import java.io.IOException; | ||
|
||
public class ProfilingUsage extends XPackFeatureSet.Usage { | ||
public ProfilingUsage(StreamInput input) throws IOException { | ||
super(input); | ||
} | ||
|
||
public ProfilingUsage(boolean available, boolean enabled) { | ||
super(XPackField.UNIVERSAL_PROFILING, available, enabled); | ||
} | ||
|
||
@Override | ||
public TransportVersion getMinimalSupportedVersion() { | ||
return TransportVersions.UNIVERSAL_PROFILING_LICENSE_ADDED; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...nalClusterTest/java/org/elasticsearch/xpack/profiling/LocalStateProfilingXPackPlugin.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,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.profiling; | ||
|
||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; | ||
|
||
import java.nio.file.Path; | ||
|
||
public class LocalStateProfilingXPackPlugin extends LocalStateCompositeXPackPlugin { | ||
public LocalStateProfilingXPackPlugin(final Settings settings, final Path configPath) { | ||
super(settings, configPath); | ||
plugins.add(new ProfilingPlugin(settings) { | ||
@Override | ||
protected ProfilingLicenseChecker createLicenseChecker() { | ||
return new ProfilingLicenseChecker(LocalStateProfilingXPackPlugin.this::getLicenseState); | ||
} | ||
}); | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
...ofiling/src/main/java/org/elasticsearch/xpack/profiling/ProfilingInfoTransportAction.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,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.profiling; | ||
|
||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
import org.elasticsearch.xpack.core.XPackSettings; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; | ||
|
||
public class ProfilingInfoTransportAction extends XPackInfoFeatureTransportAction { | ||
private final boolean enabled; | ||
private final ProfilingLicenseChecker licenseChecker; | ||
|
||
@Inject | ||
public ProfilingInfoTransportAction( | ||
TransportService transportService, | ||
ActionFilters actionFilters, | ||
Settings settings, | ||
ProfilingLicenseChecker licenseChecker | ||
) { | ||
super(XPackInfoFeatureAction.UNIVERSAL_PROFILING.name(), transportService, actionFilters); | ||
this.enabled = XPackSettings.PROFILING_ENABLED.get(settings); | ||
this.licenseChecker = licenseChecker; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return XPackField.UNIVERSAL_PROFILING; | ||
} | ||
|
||
@Override | ||
public boolean available() { | ||
return licenseChecker.isSupportedLicense(); | ||
} | ||
|
||
@Override | ||
public boolean enabled() { | ||
return enabled; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...in/profiling/src/main/java/org/elasticsearch/xpack/profiling/ProfilingLicenseChecker.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,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.profiling; | ||
|
||
import org.elasticsearch.license.License; | ||
import org.elasticsearch.license.LicenseUtils; | ||
import org.elasticsearch.license.LicensedFeature; | ||
import org.elasticsearch.license.XPackLicenseState; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public final class ProfilingLicenseChecker { | ||
private static final LicensedFeature.Momentary UNIVERSAL_PROFILING_FEATURE = LicensedFeature.momentary( | ||
null, | ||
"universal_profiling", | ||
License.OperationMode.ENTERPRISE | ||
); | ||
|
||
private final Supplier<XPackLicenseState> licenseStateResolver; | ||
|
||
public ProfilingLicenseChecker(Supplier<XPackLicenseState> licenseStateResolver) { | ||
this.licenseStateResolver = licenseStateResolver; | ||
} | ||
|
||
public boolean isSupportedLicense() { | ||
return UNIVERSAL_PROFILING_FEATURE.checkWithoutTracking(licenseStateResolver.get()); | ||
} | ||
|
||
public void requireSupportedLicense() { | ||
if (UNIVERSAL_PROFILING_FEATURE.check(licenseStateResolver.get()) == false) { | ||
throw LicenseUtils.newComplianceException(UNIVERSAL_PROFILING_FEATURE.getName()); | ||
} | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
...filing/src/main/java/org/elasticsearch/xpack/profiling/ProfilingUsageTransportAction.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,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.profiling; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.protocol.xpack.XPackUsageRequest; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.XPackSettings; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; | ||
import org.elasticsearch.xpack.core.application.ProfilingUsage; | ||
|
||
public class ProfilingUsageTransportAction extends XPackUsageFeatureTransportAction { | ||
private final ProfilingLicenseChecker licenseChecker; | ||
|
||
private final boolean enabled; | ||
|
||
@Inject | ||
public ProfilingUsageTransportAction( | ||
TransportService transportService, | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
ActionFilters actionFilters, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
ProfilingLicenseChecker licenseChecker, | ||
Settings settings | ||
) { | ||
super( | ||
XPackUsageFeatureAction.UNIVERSAL_PROFILING.name(), | ||
transportService, | ||
clusterService, | ||
threadPool, | ||
actionFilters, | ||
indexNameExpressionResolver | ||
); | ||
this.licenseChecker = licenseChecker; | ||
this.enabled = XPackSettings.PROFILING_ENABLED.get(settings); | ||
} | ||
|
||
@Override | ||
protected void masterOperation( | ||
Task task, | ||
XPackUsageRequest request, | ||
ClusterState state, | ||
ActionListener<XPackUsageFeatureResponse> listener | ||
) { | ||
ProfilingUsage profilingUsage = new ProfilingUsage(licenseChecker.isSupportedLicense(), enabled); | ||
listener.onResponse(new XPackUsageFeatureResponse(profilingUsage)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
See #97546 (comment) for context on why we are returning the license checker in all cases (but no other components).