clean up PR following review
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
This commit is contained in:
+4
-2
@@ -73,7 +73,9 @@ export class DefaultSystemMetadataService implements SystemMetadataService {
|
||||
return new DefaultSystemMetadataService(pluginEnv);
|
||||
}
|
||||
|
||||
async listInstances() {
|
||||
return this.instances;
|
||||
async introspect() {
|
||||
return {
|
||||
instances: this.instances,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -26,20 +26,24 @@ export async function createSystemMetadataRouter(options: {
|
||||
systemMetadata: SystemMetadataService;
|
||||
}) {
|
||||
const { logger, systemMetadata } = options;
|
||||
|
||||
async function getInstances() {
|
||||
const instances = await systemMetadata.introspect();
|
||||
return instances.instances;
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`Instances in this system: ${JSON.stringify(
|
||||
await systemMetadata.listInstances(),
|
||||
)}`,
|
||||
`Instances in this system: ${JSON.stringify(await getInstances())}`,
|
||||
);
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/instances', async (_, res) => {
|
||||
res.json(await systemMetadata.listInstances());
|
||||
res.json(await getInstances());
|
||||
});
|
||||
|
||||
router.get('/features/installed', async (_, res) => {
|
||||
const instances = await systemMetadata.listInstances();
|
||||
const instances = await getInstances();
|
||||
const featurePromises = await Promise.allSettled(
|
||||
instances.map(async instance => {
|
||||
const response = await fetch(
|
||||
|
||||
+1
-2
@@ -19,7 +19,6 @@ import {
|
||||
createServiceFactory,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { DefaultSystemMetadataService } from './lib/DefaultSystemMetadataService';
|
||||
import { systemMetadataServiceRef } from '@backstage/backend-plugin-api/alpha';
|
||||
import { createSystemMetadataRouter } from './lib/createSystemMetadataRouter';
|
||||
|
||||
/**
|
||||
@@ -28,7 +27,7 @@ import { createSystemMetadataRouter } from './lib/createSystemMetadataRouter';
|
||||
* @alpha
|
||||
*/
|
||||
export const systemMetadataServiceFactory = createServiceFactory({
|
||||
service: systemMetadataServiceRef,
|
||||
service: coreServices.systemMetadataServiceRef,
|
||||
deps: {
|
||||
logger: coreServices.rootLogger,
|
||||
config: coreServices.rootConfig,
|
||||
|
||||
@@ -26,17 +26,6 @@ export { actionsRegistryServiceRef, actionsServiceRef } from './refs';
|
||||
|
||||
import { createServiceRef } from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* EXPERIMENTAL: System metadata service.
|
||||
* @alpha
|
||||
*/
|
||||
export const systemMetadataServiceRef = createServiceRef<
|
||||
import('./services/definitions/SystemMetadataService').SystemMetadataService
|
||||
>({
|
||||
id: 'core.systemMetadata',
|
||||
scope: 'root',
|
||||
});
|
||||
|
||||
export type {
|
||||
BackstageInstance,
|
||||
SystemMetadataService,
|
||||
|
||||
@@ -26,5 +26,5 @@ export interface BackstageInstance {
|
||||
* @alpha
|
||||
*/
|
||||
export interface SystemMetadataService {
|
||||
listInstances(): Promise<BackstageInstance[]>;
|
||||
introspect(): Promise<{ instances: BackstageInstance[] }>;
|
||||
}
|
||||
|
||||
@@ -289,4 +289,15 @@ export namespace coreServices {
|
||||
id: 'core.rootInstanceMetadata',
|
||||
scope: 'root',
|
||||
});
|
||||
|
||||
/**
|
||||
* Read information about your current Backstage deployment.
|
||||
* @alpha
|
||||
*/
|
||||
export const systemMetadataServiceRef = createServiceRef<
|
||||
import('./SystemMetadataService').SystemMetadataService
|
||||
>({
|
||||
id: 'core.systemMetadata',
|
||||
scope: 'root',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
|
||||
@@ -1,8 +0,0 @@
|
||||
# example-backend
|
||||
|
||||
This package is an EXAMPLE of a Backstage backend using the [new backend system](https://backstage.io/docs/backend-system/).
|
||||
|
||||
The main purpose of this package is to provide a test bed for Backstage split deployment work. You can deploy both this package and the main `packages/backend` together by running the `start:split` command in both packages. This will run the following backends:
|
||||
|
||||
1. `packages/backend` running on `:7007` with the default plugins installed.
|
||||
2. `packages/backend-split` running on `:7008` with a subset of plugins installed for testing.
|
||||
@@ -1,14 +0,0 @@
|
||||
backend:
|
||||
baseUrl: http://localhost:7008
|
||||
listen:
|
||||
port: 7008
|
||||
|
||||
discovery:
|
||||
endpoints:
|
||||
- target: http://localhost:7007/api/{{pluginId}}
|
||||
plugins: [proxy]
|
||||
- target: http://localhost:7008/api/{{pluginId}}
|
||||
plugins: [catalog]
|
||||
instances:
|
||||
- baseUrl: http://localhost:7007
|
||||
- baseUrl: http://localhost:7008
|
||||
@@ -1,9 +0,0 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: example-backend-split
|
||||
title: example-backend-split
|
||||
spec:
|
||||
lifecycle: experimental
|
||||
type: backstage-backend
|
||||
owner: maintainers
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"name": "example-backend-split",
|
||||
"version": "0.0.1",
|
||||
"backstage": {
|
||||
"role": "backend"
|
||||
},
|
||||
"private": true,
|
||||
"keywords": [
|
||||
"backstage"
|
||||
],
|
||||
"homepage": "https://backstage.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/backstage/backstage",
|
||||
"directory": "packages/backend-split"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.cjs.js",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "backstage-cli package build",
|
||||
"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",
|
||||
"test": "backstage-cli package test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-defaults": "workspace:^",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/catalog-model": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend-module-backstage-openapi": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend-module-openapi": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^",
|
||||
"@backstage/plugin-permission-backend": "workspace:^",
|
||||
"@backstage/plugin-permission-backend-module-allow-all-policy": "workspace:^",
|
||||
"@backstage/plugin-permission-common": "workspace:^",
|
||||
"@backstage/plugin-permission-node": "workspace:^",
|
||||
"@opentelemetry/auto-instrumentations-node": "^0.54.0",
|
||||
"@opentelemetry/exporter-prometheus": "^0.54.0",
|
||||
"@opentelemetry/sdk-node": "^0.54.0",
|
||||
"example-app": "link:../app",
|
||||
"express-promise-router": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "workspace:^"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// Test requests for the split backend to test the system metadata service :)
|
||||
// The 2 below requests should return the same data.
|
||||
GET http://localhost:7007/.backstage/systemMetadata/v1/features/installed
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:7008/.backstage/systemMetadata/v1/features/installed
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 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 { createBackend } from '@backstage/backend-defaults';
|
||||
import { systemMetadataServiceFactory } from '@backstage/backend-defaults/alpha';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
backend.add(import('@backstage/plugin-catalog-backend-module-unprocessed'));
|
||||
backend.add(
|
||||
import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'),
|
||||
);
|
||||
backend.add(import('@backstage/plugin-catalog-backend'));
|
||||
|
||||
backend.add(
|
||||
import('@backstage/plugin-permission-backend-module-allow-all-policy'),
|
||||
);
|
||||
backend.add(import('@backstage/plugin-permission-backend'));
|
||||
|
||||
backend.add(systemMetadataServiceFactory);
|
||||
|
||||
backend.start();
|
||||
@@ -1,34 +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.
|
||||
*/
|
||||
|
||||
const { NodeSDK } = require('@opentelemetry/sdk-node');
|
||||
const {
|
||||
getNodeAutoInstrumentations,
|
||||
} = require('@opentelemetry/auto-instrumentations-node');
|
||||
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
|
||||
|
||||
// Expose opentelemetry metrics using a Prometheus exporter on
|
||||
// http://localhost:9464/metrics. See packages/backend/prometheus.yml for
|
||||
// more information on how to scrape it.
|
||||
const prometheus = new PrometheusExporter();
|
||||
|
||||
const sdk = new NodeSDK({
|
||||
// traceExporter: ...,
|
||||
metricReader: prometheus,
|
||||
instrumentations: [getNodeAutoInstrumentations()],
|
||||
});
|
||||
|
||||
sdk.start();
|
||||
@@ -1,11 +0,0 @@
|
||||
discovery:
|
||||
endpoints:
|
||||
- target: http://localhost:7007/api/{{pluginId}}
|
||||
plugins: [proxy]
|
||||
- target: http://localhost:7008/api/{{pluginId}}
|
||||
plugins: [catalog]
|
||||
instances:
|
||||
- baseUrl: http://localhost:7007
|
||||
- baseUrl:
|
||||
internal: http://localhost:7008
|
||||
external: http://127.0.0.1:7008
|
||||
@@ -27,7 +27,6 @@
|
||||
"lint": "backstage-cli package lint",
|
||||
"start": "backstage-cli package start --require ./src/instrumentation.js",
|
||||
"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": {
|
||||
|
||||
@@ -30233,12 +30233,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: soft
|
||||
|
||||
"example-app@link:../app::locator=example-backend-split%40workspace%3Apackages%2Fbackend-split":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "example-app@link:../app::locator=example-backend-split%40workspace%3Apackages%2Fbackend-split"
|
||||
languageName: node
|
||||
linkType: soft
|
||||
|
||||
"example-app@workspace:packages/app":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "example-app@workspace:packages/app"
|
||||
@@ -30307,31 +30301,6 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"example-backend-split@workspace:packages/backend-split":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "example-backend-split@workspace:packages/backend-split"
|
||||
dependencies:
|
||||
"@backstage/backend-defaults": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/catalog-model": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend-module-backstage-openapi": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend-module-openapi": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^"
|
||||
"@backstage/plugin-permission-backend": "workspace:^"
|
||||
"@backstage/plugin-permission-backend-module-allow-all-policy": "workspace:^"
|
||||
"@backstage/plugin-permission-common": "workspace:^"
|
||||
"@backstage/plugin-permission-node": "workspace:^"
|
||||
"@opentelemetry/auto-instrumentations-node": "npm:^0.54.0"
|
||||
"@opentelemetry/exporter-prometheus": "npm:^0.54.0"
|
||||
"@opentelemetry/sdk-node": "npm:^0.54.0"
|
||||
example-app: "link:../app"
|
||||
express-promise-router: "npm:^4.1.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"example-backend@workspace:packages/backend":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "example-backend@workspace:packages/backend"
|
||||
|
||||
Reference in New Issue
Block a user