@@ -464,6 +464,3 @@ apacheAirflow:
|
||||
|
||||
gocd:
|
||||
baseUrl: https://your.gocd.instance.com
|
||||
|
||||
airbrake:
|
||||
apiKey: ${AIRBRAKE_API_KEY}
|
||||
|
||||
@@ -10,8 +10,19 @@ See the [Airbrake plugin instructions](../airbrake/README.md#how-to-use).
|
||||
|
||||
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads.
|
||||
|
||||
1. Set the environment variable `AIRBRAKE_API_KEY` with your [API key](https://airbrake.io/docs/api/#authentication).
|
||||
2. Run this plugin in standalone mode by running `yarn start`. The configuration is already setup in the root [`app-config.yaml`](../../app-config.yaml) to pick up your API key from the environment variable above.
|
||||
1. Add the required config to your `app-config.local.yaml`:
|
||||
|
||||
```yaml
|
||||
airbrake:
|
||||
apiKey: ${AIRBRAKE_API_KEY}
|
||||
```
|
||||
|
||||
2. Set the environment variable `AIRBRAKE_API_KEY` with your [API
|
||||
key](https://airbrake.io/docs/api/#authentication). You can also write it
|
||||
directly into the config file above for convenience - but beware of
|
||||
accidentally leaking the key.
|
||||
|
||||
3. Go into the plugin's directory and run it in standalone mode by running `yarn start`.
|
||||
|
||||
Access it from http://localhost:7007/api/airbrake. Or use the Airbrake plugin which will talk to it automatically.
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import { Config } from '@backstage/config';
|
||||
import express from 'express';
|
||||
import { Logger as Logger_2 } from 'winston';
|
||||
import * as winston from 'winston';
|
||||
|
||||
// @public
|
||||
export interface AirbrakeConfig {
|
||||
@@ -17,10 +16,7 @@ export interface AirbrakeConfig {
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
// @public
|
||||
export function extractAirbrakeConfig(
|
||||
config: Config,
|
||||
logger: winston.Logger,
|
||||
): AirbrakeConfig;
|
||||
export function extractAirbrakeConfig(config: Config): AirbrakeConfig;
|
||||
|
||||
// @public
|
||||
export interface RouterOptions {
|
||||
|
||||
Vendored
+3
-1
@@ -18,7 +18,9 @@ export interface Config {
|
||||
/** Configuration options for the Airbrake plugin */
|
||||
airbrake?: {
|
||||
/**
|
||||
* The API Key to authenticate requests. More details on how to get this here: https://airbrake.io/docs/api/#authentication
|
||||
* The API Key to authenticate requests. More details on how to get this
|
||||
* here: https://airbrake.io/docs/api/#authentication
|
||||
*
|
||||
* @visibility secret
|
||||
*/
|
||||
apiKey: string;
|
||||
|
||||
@@ -13,20 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { extractAirbrakeConfig } from './ExtractAirbrakeConfig';
|
||||
import * as winston from 'winston';
|
||||
|
||||
describe('ExtractAirbrakeConfig', () => {
|
||||
let oldProcessEnv: NodeJS.ProcessEnv;
|
||||
let voidLogger: winston.Logger;
|
||||
|
||||
beforeEach(() => {
|
||||
oldProcessEnv = process.env;
|
||||
voidLogger = getVoidLogger();
|
||||
});
|
||||
|
||||
it('gets the API key', () => {
|
||||
const config = new ConfigReader({
|
||||
airbrake: {
|
||||
@@ -34,34 +25,14 @@ describe('ExtractAirbrakeConfig', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const airbrakeConfig = extractAirbrakeConfig(config, voidLogger);
|
||||
const airbrakeConfig = extractAirbrakeConfig(config);
|
||||
expect(airbrakeConfig.apiKey).toStrictEqual('fakeApiKey');
|
||||
});
|
||||
|
||||
it('does not fail in development', () => {
|
||||
process.env = {
|
||||
...oldProcessEnv,
|
||||
NODE_ENV: 'development',
|
||||
};
|
||||
|
||||
const config = new ConfigReader({});
|
||||
|
||||
expect(() => extractAirbrakeConfig(config, voidLogger)).not.toThrow();
|
||||
const airbrakeConfig = extractAirbrakeConfig(config, voidLogger);
|
||||
expect(airbrakeConfig.apiKey).toStrictEqual('');
|
||||
});
|
||||
|
||||
it('fails in production', () => {
|
||||
process.env = {
|
||||
...oldProcessEnv,
|
||||
NODE_ENV: 'production',
|
||||
};
|
||||
|
||||
const config = new ConfigReader({});
|
||||
expect(() => extractAirbrakeConfig(config, voidLogger)).toThrow();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = { ...oldProcessEnv };
|
||||
it('fails for missing keys', () => {
|
||||
expect(() => extractAirbrakeConfig(new ConfigReader({}))).toThrow();
|
||||
expect(() =>
|
||||
extractAirbrakeConfig(new ConfigReader({ airbrake: {} })),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Config } from '@backstage/config';
|
||||
import * as winston from 'winston';
|
||||
|
||||
/**
|
||||
* The configuration needed for the airbrake-backend plugin
|
||||
@@ -34,27 +34,9 @@ export interface AirbrakeConfig {
|
||||
* @public
|
||||
*
|
||||
* @param config - The config object to extract from
|
||||
* @param logger - THe logger object
|
||||
*/
|
||||
export function extractAirbrakeConfig(
|
||||
config: Config,
|
||||
logger: winston.Logger,
|
||||
): AirbrakeConfig {
|
||||
try {
|
||||
return {
|
||||
apiKey: config.getString('airbrake.apiKey'),
|
||||
};
|
||||
} catch (e) {
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
throw e;
|
||||
} else {
|
||||
logger.warn(
|
||||
'Airbrake config missing, Airbrake plugin will probably not work',
|
||||
e,
|
||||
);
|
||||
return {
|
||||
apiKey: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
export function extractAirbrakeConfig(config: Config): AirbrakeConfig {
|
||||
return {
|
||||
apiKey: config.getString('airbrake.apiKey'),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('createRouter', () => {
|
||||
apiKey: 'fakeApiKey',
|
||||
},
|
||||
});
|
||||
airbrakeConfig = extractAirbrakeConfig(config, voidLogger);
|
||||
airbrakeConfig = extractAirbrakeConfig(config);
|
||||
|
||||
const router = await createRouter({
|
||||
logger: voidLogger,
|
||||
|
||||
@@ -34,7 +34,7 @@ export async function startStandaloneServer(
|
||||
): Promise<Server> {
|
||||
const logger = options.logger.child({ service: 'airbrake-backend' });
|
||||
const config = await loadBackendConfig({ logger, argv: process.argv });
|
||||
const airbrakeConfig = extractAirbrakeConfig(config, logger);
|
||||
const airbrakeConfig = extractAirbrakeConfig(config);
|
||||
logger.debug('Starting application server...');
|
||||
const router = await createRouter({
|
||||
logger,
|
||||
|
||||
@@ -68,7 +68,7 @@ The Airbrake plugin provides connectivity between Backstage and Airbrake (https:
|
||||
|
||||
## Local Development
|
||||
|
||||
Start this plugin in standalone mode by running `yarn start`. This method of serving the plugin provides quicker
|
||||
Start this plugin in standalone mode by running `yarn start` inside the plugin directory. This method of serving the plugin provides quicker
|
||||
iteration speed and a faster startup and hot reloads. It is only meant for local development, and the setup for it can
|
||||
be found inside the [/dev](./dev) directory.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user