Skip to content

Commit

Permalink
clean up otel poc
Browse files Browse the repository at this point in the history
  • Loading branch information
crespocarlos committed Jul 11, 2022
1 parent d911a31 commit 2638cbb
Show file tree
Hide file tree
Showing 26 changed files with 223 additions and 556 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
"@mapbox/vector-tile": "1.3.1",
"@opentelemetry/api-metrics": "0.29.2",
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.29.2",
"@opentelemetry/exporter-prometheus": "^0.29.2",
"@opentelemetry/exporter-prometheus": "^0.30.0",
"@opentelemetry/resources": "^1.3.1",
"@opentelemetry/sdk-metrics-base": "^0.29.2",
"@opentelemetry/semantic-conventions": "^1.3.1",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/alerting/server/monitoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ export { registerNodeCollector } from './register_node_collector';
export { registerClusterCollector } from './register_cluster_collector';
export * from './types';
export * from './in_memory_metrics';
export * from './metrics';
22 changes: 0 additions & 22 deletions x-pack/plugins/alerting/server/monitoring/metrics.ts

This file was deleted.

11 changes: 1 addition & 10 deletions x-pack/plugins/alerting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
import { PluginStartContract as FeaturesPluginStart } from '@kbn/features-plugin/server';
import { PluginStart as DataPluginStart } from '@kbn/data-plugin/server';
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
import { metrics } from '@opentelemetry/api-metrics';
import { RuleTypeRegistry } from './rule_type_registry';
import { TaskRunnerFactory } from './task_runner';
import { RulesClientFactory } from './rules_client_factory';
Expand Down Expand Up @@ -78,12 +77,7 @@ import { getHealth } from './health/get_health';
import { AlertingAuthorizationClientFactory } from './alerting_authorization_client_factory';
import { AlertingAuthorization } from './authorization';
import { getSecurityHealth, SecurityHealth } from './lib/get_security_health';
import {
registerNodeCollector,
registerClusterCollector,
InMemoryMetrics,
Metrics,
} from './monitoring';
import { registerNodeCollector, registerClusterCollector, InMemoryMetrics } from './monitoring';
import { getRuleTaskTimeout } from './lib/get_rule_task_timeout';
import { getActionsConfigMap } from './lib/get_actions_config_map';

Expand Down Expand Up @@ -179,7 +173,6 @@ export class AlertingPlugin {
private kibanaBaseUrl: string | undefined;
private usageCounter: UsageCounter | undefined;
private inMemoryMetrics: InMemoryMetrics;
private metrics: Metrics;

constructor(initializerContext: PluginInitializerContext) {
this.config = initializerContext.config.get();
Expand All @@ -190,7 +183,6 @@ export class AlertingPlugin {
this.telemetryLogger = initializerContext.logger.get('usage');
this.kibanaVersion = initializerContext.env.packageInfo.version;
this.inMemoryMetrics = new InMemoryMetrics(initializerContext.logger.get('in_memory_metrics'));
this.metrics = new Metrics(metrics.getMeter('kibana.alerting'));
}

public setup(
Expand Down Expand Up @@ -235,7 +227,6 @@ export class AlertingPlugin {
licensing: plugins.licensing,
minimumScheduleInterval: this.config.rules.minimumScheduleInterval,
inMemoryMetrics: this.inMemoryMetrics,
metrics: this.metrics,
});
this.ruleTypeRegistry = ruleTypeRegistry;

Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/alerting/server/rule_type_registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import { licenseStateMock } from './lib/license_state.mock';
import { licensingMock } from '@kbn/licensing-plugin/server/mocks';
import { loggingSystemMock } from '@kbn/core/server/mocks';
import { inMemoryMetricsMock } from './monitoring/in_memory_metrics.mock';
import { metricsMock } from './monitoring/metrics.mock';

const logger = loggingSystemMock.create().get();
let mockedLicenseState: jest.Mocked<ILicenseState>;
let ruleTypeRegistryParams: ConstructorOptions;

const taskManager = taskManagerMock.createSetup();
const inMemoryMetrics = inMemoryMetricsMock.create();
const metrics = metricsMock.create();

beforeEach(() => {
jest.resetAllMocks();
Expand All @@ -35,7 +33,6 @@ beforeEach(() => {
licensing: licensingMock.createSetup(),
minimumScheduleInterval: { value: '1m', enforce: false },
inMemoryMetrics,
metrics,
};
});

Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/alerting/server/rule_type_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '../common';
import { ILicenseState } from './lib/license_state';
import { getRuleTypeFeatureUsageName } from './lib/get_rule_type_feature_usage_name';
import { InMemoryMetrics, Metrics } from './monitoring';
import { InMemoryMetrics } from './monitoring';
import { AlertingRulesConfig } from '.';

export interface ConstructorOptions {
Expand All @@ -42,7 +42,6 @@ export interface ConstructorOptions {
licensing: LicensingPluginSetup;
minimumScheduleInterval: AlertingRulesConfig['minimumScheduleInterval'];
inMemoryMetrics: InMemoryMetrics;
metrics: Metrics;
}

export interface RegistryRuleType
Expand Down Expand Up @@ -140,7 +139,6 @@ export class RuleTypeRegistry {
private readonly minimumScheduleInterval: AlertingRulesConfig['minimumScheduleInterval'];
private readonly licensing: LicensingPluginSetup;
private readonly inMemoryMetrics: InMemoryMetrics;
private readonly metrics: Metrics;

constructor({
logger,
Expand All @@ -150,7 +148,6 @@ export class RuleTypeRegistry {
licensing,
minimumScheduleInterval,
inMemoryMetrics,
metrics,
}: ConstructorOptions) {
this.logger = logger;
this.taskManager = taskManager;
Expand All @@ -159,7 +156,6 @@ export class RuleTypeRegistry {
this.licensing = licensing;
this.minimumScheduleInterval = minimumScheduleInterval;
this.inMemoryMetrics = inMemoryMetrics;
this.metrics = metrics;
}

public has(id: string) {
Expand Down Expand Up @@ -278,7 +274,7 @@ export class RuleTypeRegistry {
InstanceContext,
ActionGroupIds,
RecoveryActionGroupId | RecoveredActionGroupId
>(normalizedRuleType, context, this.inMemoryMetrics, this.metrics),
>(normalizedRuleType, context, this.inMemoryMetrics),
},
});
// No need to notify usage on basic alert types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ import { licensingMock } from '@kbn/licensing-plugin/server/mocks';
import { isRuleExportable } from './is_rule_exportable';
import { inMemoryMetricsMock } from '../monitoring/in_memory_metrics.mock';
import { loggingSystemMock } from '@kbn/core/server/mocks';
import { metricsMock } from '../monitoring/metrics.mock';

let ruleTypeRegistryParams: ConstructorOptions;
let logger: MockedLogger;
let mockedLicenseState: jest.Mocked<ILicenseState>;
const taskManager = taskManagerMock.createSetup();
const inMemoryMetrics = inMemoryMetricsMock.create();
const metrics = metricsMock.create();

beforeEach(() => {
jest.resetAllMocks();
Expand All @@ -36,7 +34,6 @@ beforeEach(() => {
licensing: licensingMock.createSetup(),
minimumScheduleInterval: { value: '1m', enforce: false },
inMemoryMetrics,
metrics,
};
});

Expand Down
Loading

0 comments on commit 2638cbb

Please sign in to comment.