Skip to content

Commit

Permalink
Disable agent via configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
adunkman committed Sep 2, 2021
1 parent e5b8715 commit a4b7323
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# NEW_RELIC_LICENSE_KEY=c1C2c1C2c1C2c1C2c1C2c1C2c1C2c1C2c1C2c1C2
# NEW_RELIC_APP_NAME=inclusion-bot-prod
# NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
# NEW_RELIC_ENABLED=true
#
SLACK_SIGNING_SECRET=a1A2a1A2a1A2a1A2a1A2a1A2a1A2a1A2
SLACK_CLIENT_ID=1111111111111.2222222222222
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.vscode
coverage
node_modules
newrelic_agent.log
4 changes: 2 additions & 2 deletions bot/actions/closeMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import newrelic from "newrelic";
import { incrementMetric } from "newrelic";
import { AllMiddlewareArgs, BlockAction, ButtonAction, SlackActionMiddlewareArgs } from "@slack/bolt";

export const CLOSE_MESSAGE_ACTION_ID = "close_ephemeral_message";
Expand All @@ -7,7 +7,7 @@ export async function handleMessageClose(event: SlackActionMiddlewareArgs<BlockA
// We must acknowledge this event, or it will show as a UI error.
event.ack();

newrelic.incrementMetric("Actions/messageClose");
incrementMetric("Actions/messageClose");

await event.respond({
delete_original: true
Expand Down
4 changes: 2 additions & 2 deletions bot/actions/menuClick.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import newrelic from "newrelic";
import { incrementMetric } from "newrelic";
import { AllMiddlewareArgs, BlockAction, OverflowAction, SlackActionMiddlewareArgs } from "@slack/bolt";

export const OVERFLOW_MENU_CLICK_ACTION_ID = "overflow_menu_click";
Expand All @@ -7,5 +7,5 @@ export async function handleMenuClick(event: SlackActionMiddlewareArgs<BlockActi
// We must acknowledge this event, or it will show as a UI error.
await event.ack();

newrelic.incrementMetric("Actions/menuClick");
incrementMetric("Actions/menuClick");
}
6 changes: 3 additions & 3 deletions bot/actions/message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import newrelic from "newrelic";
import { incrementMetric } from "newrelic";
import { AllMiddlewareArgs, GenericMessageEvent, SlackEventMiddlewareArgs } from "@slack/bolt";
import { WebAPICallResult } from "@slack/web-api";
import { capitalize } from "../helpers/capitalize";
Expand All @@ -21,7 +21,7 @@ export async function handleMessage(event: SlackEventMiddlewareArgs<'message'> &

if (matches.length === 0) {
// This message contains only ignored items.
newrelic.incrementMetric("Actions/message/ignoredTerm");
incrementMetric("Actions/message/ignoredTerm");
return;
}

Expand All @@ -36,7 +36,7 @@ export async function handleMessage(event: SlackEventMiddlewareArgs<'message'> &
const random = Math.floor(Math.random() * trigger.alternatives.length);
const alternative = trigger.alternatives[random];
const why = (trigger.why || '').replace(/:TERM:/gi, capitalize(text));
newrelic.incrementMetric(`Actions/message/term/${text.toLowerCase()}`);
incrementMetric(`Actions/message/term/${text.toLowerCase()}`);
return `Instead of saying “${text.toLowerCase()},” how about *${alternative}*? You may be able to edit your message. ${why}`;
});

Expand Down
4 changes: 2 additions & 2 deletions bot/actions/messageEdited.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import newrelic from "newrelic";
import { incrementMetric } from "newrelic";
import { AllMiddlewareArgs, GenericMessageEvent, MessageChangedEvent, SlackEventMiddlewareArgs } from "@slack/bolt";
import { config } from "../triggers/triggers";

Expand Down Expand Up @@ -43,7 +43,7 @@ export async function handleMessageEdited(event: SlackEventMiddlewareArgs<'messa
if (!message.text.match(config.allTriggersRegExp)) {
// The user has adjusted their language and it no longer matches our
// triggers.
newrelic.incrementMetric("Actions/messageEdited/termRemoved");
incrementMetric("Actions/messageEdited/termRemoved");
await event.client.reactions.remove({
name: config.emoji,
channel: messageChanged.channel,
Expand Down
8 changes: 4 additions & 4 deletions bot/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import newrelic from "newrelic";
import { incrementMetric } from "newrelic";
import { App, ExpressReceiver, Installation as InstallationType, LogLevel, subtype } from "@slack/bolt";
import { Sequelize } from "sequelize";
import { InstallationFactory } from "./models/installation";
Expand Down Expand Up @@ -38,7 +38,7 @@ const receiver = new ExpressReceiver({
logLevel: LogLevel.INFO,
installationStore: {
storeInstallation: async (installation) => {
newrelic.incrementMetric("InstallationStore/storeInstallation");
incrementMetric("InstallationStore/storeInstallation");

await Installation.create({
id: installation.isEnterpriseInstall
Expand All @@ -49,7 +49,7 @@ const receiver = new ExpressReceiver({
});
},
fetchInstallation: async (query) => {
newrelic.incrementMetric("InstallationStore/fetchInstallation");
incrementMetric("InstallationStore/fetchInstallation");

const installation = await Installation.findByPk(
query.isEnterpriseInstall ? query.enterpriseId : query.teamId
Expand All @@ -58,7 +58,7 @@ const receiver = new ExpressReceiver({
return installation.installationObject as InstallationType;
},
deleteInstallation: async (query) => {
newrelic.incrementMetric("InstallationStore/deleteInstallation");
incrementMetric("InstallationStore/deleteInstallation");

const installation = await Installation.findByPk(
query.isEnterpriseInstall ? query.enterpriseId : query.teamId
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
SLACK_CLIENT_SECRET: $SLACK_CLIENT_SECRET
APP_STATE_SECRET: $APP_STATE_SECRET
DATABASE_URL: postgres://postgres:${LOCAL_POSTGRES_PASSWORD}@db:5432/postgres
NEW_RELIC_ENABLED: "false"

adminer:
image: adminer:4.8.1-standalone
Expand Down

0 comments on commit a4b7323

Please sign in to comment.