remove duplicate custom plugins
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
This commit is contained in:
@@ -26,8 +26,8 @@
|
||||
"clean": "backstage-cli package clean",
|
||||
"lint": "backstage-cli package lint",
|
||||
"start": "backstage-cli package start --require ./src/instrumentation.js",
|
||||
"start:split": "backstage-cli package start --require ./src/instrumentation.js --config ../../app-config.yaml --config app-config.split.yaml",
|
||||
"start:prometheus": "docker run --mount type=bind,source=./prometheus.yml,destination=/etc/prometheus/prometheus.yml --publish published=9090,target=9090,protocol=tcp prom/prometheus",
|
||||
"start:split": "backstage-cli package start --require ./src/instrumentation.js --config ../../app-config.yaml --config app-config.split.yaml",
|
||||
"test": "backstage-cli package test"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -70,8 +70,7 @@
|
||||
"@opentelemetry/auto-instrumentations-node": "^0.61.0",
|
||||
"@opentelemetry/exporter-prometheus": "^0.54.0",
|
||||
"@opentelemetry/sdk-node": "^0.54.0",
|
||||
"example-app": "link:../app",
|
||||
"express-promise-router": "^4.1.0"
|
||||
"example-app": "link:../app"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "workspace:^"
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
coreServices,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { instanceMetadataServiceRef } from '@backstage/backend-plugin-api/alpha';
|
||||
import Router from 'express-promise-router';
|
||||
|
||||
// Example usage of the instance metadata service to log the installed features.
|
||||
export default createBackendPlugin({
|
||||
pluginId: 'instance-metadata-logging',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
instanceMetadata: instanceMetadataServiceRef,
|
||||
logger: coreServices.logger,
|
||||
httpRouter: coreServices.rootHttpRouter,
|
||||
},
|
||||
async init({ instanceMetadata, logger, httpRouter }) {
|
||||
logger.info(
|
||||
`Installed features on this instance: ${JSON.stringify(
|
||||
instanceMetadata.getInstalledFeatures(),
|
||||
)}`,
|
||||
);
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/features/installed', (_, res) => {
|
||||
res.json({ items: instanceMetadata.getInstalledFeatures() });
|
||||
});
|
||||
|
||||
httpRouter.use('/.backstage/instanceInfo', router);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
coreServices,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import {
|
||||
BackendFeatureMeta,
|
||||
systemMetadataServiceRef,
|
||||
} from '@backstage/backend-plugin-api/alpha';
|
||||
import Router from 'express-promise-router';
|
||||
|
||||
// Example usage of the instance metadata service to log the installed features.
|
||||
export default createBackendPlugin({
|
||||
pluginId: 'system-metadata-logging',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
systemMetadata: systemMetadataServiceRef,
|
||||
logger: coreServices.logger,
|
||||
httpRouter: coreServices.rootHttpRouter,
|
||||
},
|
||||
async init({ systemMetadata, logger, httpRouter }) {
|
||||
logger.info(
|
||||
`Instances in this system: ${JSON.stringify(
|
||||
await systemMetadata.listInstances(),
|
||||
)}`,
|
||||
);
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/instances', async (_, res) => {
|
||||
res.json(await systemMetadata.listInstances());
|
||||
});
|
||||
|
||||
router.get('/features/installed', async (_, res) => {
|
||||
const instances = await systemMetadata.listInstances();
|
||||
const featurePromises = await Promise.allSettled(
|
||||
instances.map(async instance => {
|
||||
const response = await fetch(
|
||||
`${instance.url}/.backstage/instanceInfo/features/installed`,
|
||||
);
|
||||
if (response.ok) {
|
||||
return { instance, response: await response.json() };
|
||||
}
|
||||
throw new Error(
|
||||
`Failed to fetch installed features from ${instance.url}`,
|
||||
);
|
||||
}),
|
||||
);
|
||||
const pluginByInstance: Record<string, string[]> = {};
|
||||
for (const result of featurePromises) {
|
||||
if (result.status !== 'fulfilled') {
|
||||
logger.error(
|
||||
`Failed to fetch installed features: ${result.reason}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const instance = result.value.instance;
|
||||
const installedFeatures = result.value.response
|
||||
.items as BackendFeatureMeta[];
|
||||
for (const feature of installedFeatures) {
|
||||
if (feature.type === 'plugin') {
|
||||
if (!pluginByInstance[feature.pluginId]) {
|
||||
pluginByInstance[feature.pluginId] = [];
|
||||
}
|
||||
pluginByInstance[feature.pluginId].push(
|
||||
`${instance.url}/api/${feature.pluginId}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
res.json(pluginByInstance);
|
||||
});
|
||||
|
||||
httpRouter.use('/.backstage/systemInfo', router);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -70,8 +70,6 @@ backend.add(searchLoader);
|
||||
backend.add(import('@backstage/plugin-techdocs-backend'));
|
||||
backend.add(import('@backstage/plugin-signals-backend'));
|
||||
backend.add(import('@backstage/plugin-notifications-backend'));
|
||||
backend.add(import('./experimental/instanceMetadata'));
|
||||
backend.add(import('./experimental/systemMetadata'));
|
||||
backend.add(systemMetadataServiceFactory);
|
||||
|
||||
backend.add(import('@backstage/plugin-events-backend-module-google-pubsub'));
|
||||
|
||||
Reference in New Issue
Block a user