[APM] License feature tracking for service maps (#69455)
Use the license feature API to register the service maps feature and track its usage when the API endpoint is accessed. Fixes #64850.
This commit is contained in:
parent
789851eb1a
commit
2642d658c4
|
@ -70,3 +70,6 @@ export const APM_FEATURE = {
|
|||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const APM_SERVICE_MAPS_FEATURE_NAME = 'APM service maps';
|
||||
export const APM_SERVICE_MAPS_LICENSE_TYPE = 'platinum';
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { ObservabilityPluginSetup } from '../../observability/server';
|
||||
import { SecurityPluginSetup } from '../../security/public';
|
||||
import { SecurityPluginSetup } from '../../security/server';
|
||||
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
|
||||
import { TaskManagerSetupContract } from '../../task_manager/server';
|
||||
import { AlertingPlugin } from '../../alerts/server';
|
||||
|
@ -28,11 +28,19 @@ import { APMConfig, mergeConfigs, APMXPackConfig } from '.';
|
|||
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
|
||||
import { CloudSetup } from '../../cloud/server';
|
||||
import { getInternalSavedObjectsClient } from './lib/helpers/get_internal_saved_objects_client';
|
||||
import { LicensingPluginSetup } from '../../licensing/public';
|
||||
import {
|
||||
LicensingPluginSetup,
|
||||
LicensingPluginStart,
|
||||
} from '../../licensing/server';
|
||||
import { registerApmAlerts } from './lib/alerts/register_apm_alerts';
|
||||
import { createApmTelemetry } from './lib/apm_telemetry';
|
||||
|
||||
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
|
||||
import { APM_FEATURE } from './feature';
|
||||
import {
|
||||
APM_FEATURE,
|
||||
APM_SERVICE_MAPS_FEATURE_NAME,
|
||||
APM_SERVICE_MAPS_LICENSE_TYPE,
|
||||
} from './feature';
|
||||
import { apmIndices, apmTelemetry } from './saved_objects';
|
||||
import { createElasticCloudInstructions } from './tutorial/elastic_cloud';
|
||||
import { MlPluginSetup } from '../../ml/server';
|
||||
|
@ -120,16 +128,25 @@ export class APMPlugin implements Plugin<APMPluginSetup> {
|
|||
elasticCloud: createElasticCloudInstructions(plugins.cloud),
|
||||
};
|
||||
});
|
||||
plugins.features.registerFeature(APM_FEATURE);
|
||||
|
||||
createApmApi().init(core, {
|
||||
config$: mergedConfig$,
|
||||
logger: this.logger!,
|
||||
plugins: {
|
||||
observability: plugins.observability,
|
||||
security: plugins.security,
|
||||
ml: plugins.ml,
|
||||
},
|
||||
plugins.features.registerFeature(APM_FEATURE);
|
||||
plugins.licensing.featureUsage.register(
|
||||
APM_SERVICE_MAPS_FEATURE_NAME,
|
||||
APM_SERVICE_MAPS_LICENSE_TYPE
|
||||
);
|
||||
|
||||
core.getStartServices().then(([_coreStart, pluginsStart]) => {
|
||||
createApmApi().init(core, {
|
||||
config$: mergedConfig$,
|
||||
logger: this.logger!,
|
||||
plugins: {
|
||||
licensing: (pluginsStart as { licensing: LicensingPluginStart })
|
||||
.licensing,
|
||||
observability: plugins.observability,
|
||||
security: plugins.security,
|
||||
ml: plugins.ml,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
@ -9,6 +9,7 @@ import { CoreSetup, Logger } from 'src/core/server';
|
|||
import { Params } from '../typings';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { APMConfig } from '../..';
|
||||
import { LicensingPluginStart } from '../../../../licensing/server';
|
||||
|
||||
const getCoreMock = () => {
|
||||
const get = jest.fn();
|
||||
|
@ -40,7 +41,7 @@ const getCoreMock = () => {
|
|||
logger: ({
|
||||
error: jest.fn(),
|
||||
} as unknown) as Logger,
|
||||
plugins: {},
|
||||
plugins: { licensing: {} as LicensingPluginStart },
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@ import { getServiceMap } from '../lib/service_map/get_service_map';
|
|||
import { getServiceMapServiceNodeInfo } from '../lib/service_map/get_service_map_service_node_info';
|
||||
import { createRoute } from './create_route';
|
||||
import { rangeRt } from './default_api_types';
|
||||
import { APM_SERVICE_MAPS_FEATURE_NAME } from '../feature';
|
||||
|
||||
export const serviceMapRoute = createRoute(() => ({
|
||||
path: '/api/apm/service-map',
|
||||
|
@ -35,6 +36,10 @@ export const serviceMapRoute = createRoute(() => ({
|
|||
throw Boom.forbidden(invalidLicenseMessage);
|
||||
}
|
||||
|
||||
context.plugins.licensing.featureUsage.notifyUsage(
|
||||
APM_SERVICE_MAPS_FEATURE_NAME
|
||||
);
|
||||
|
||||
const setup = await setupRequest(context, request);
|
||||
const {
|
||||
query: { serviceName, environment },
|
||||
|
|
|
@ -14,10 +14,11 @@ import {
|
|||
import { PickByValue, Optional } from 'utility-types';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Server } from 'hapi';
|
||||
import { LicensingPluginStart } from '../../../licensing/server';
|
||||
import { ObservabilityPluginSetup } from '../../../observability/server';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { FetchOptions } from '../../public/services/rest/callApi';
|
||||
import { SecurityPluginSetup } from '../../../security/public';
|
||||
import { SecurityPluginSetup } from '../../../security/server';
|
||||
import { MlPluginSetup } from '../../../ml/server';
|
||||
import { APMConfig } from '..';
|
||||
|
||||
|
@ -66,6 +67,7 @@ export type APMRequestHandlerContext<
|
|||
config: APMConfig;
|
||||
logger: Logger;
|
||||
plugins: {
|
||||
licensing: LicensingPluginStart;
|
||||
observability?: ObservabilityPluginSetup;
|
||||
security?: SecurityPluginSetup;
|
||||
ml?: MlPluginSetup;
|
||||
|
@ -114,6 +116,7 @@ export interface ServerAPI<TRouteState extends RouteState> {
|
|||
config$: Observable<APMConfig>;
|
||||
logger: Logger;
|
||||
plugins: {
|
||||
licensing: LicensingPluginStart;
|
||||
observability?: ObservabilityPluginSetup;
|
||||
security?: SecurityPluginSetup;
|
||||
ml?: MlPluginSetup;
|
||||
|
|
Loading…
Reference in a new issue