Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Associate logs with traces #9444

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/server/billing/helpers/adjustUserCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import handleEnterpriseOrgQuantityChanges from './handleEnterpriseOrgQuantityCha
import handleTeamOrgQuantityChanges from './handleTeamOrgQuantityChanges'
import {getUserById} from '../../postgres/queries/getUsersByIds'
import {DataLoaderWorker} from '../../graphql/graphql'
import {Logger} from '../../utils/Logger'

const maybeUpdateOrganizationActiveDomain = async (
orgId: string,
Expand Down Expand Up @@ -170,5 +171,5 @@ export default async function adjustUserCount(
.run()

handleEnterpriseOrgQuantityChanges(paidOrgs, dataLoader).catch()
handleTeamOrgQuantityChanges(paidOrgs).catch(console.error)
handleTeamOrgQuantityChanges(paidOrgs).catch(Logger.error)
}
3 changes: 2 additions & 1 deletion packages/server/billing/helpers/terminateSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import getRethink from '../../database/rethinkDriver'
import Organization from '../../database/types/Organization'
import {Logger} from '../../utils/Logger'
import {getStripeManager} from '../../utils/stripe'

const terminateSubscription = async (orgId: string) => {
Expand Down Expand Up @@ -30,7 +31,7 @@ const terminateSubscription = async (orgId: string) => {
try {
await manager.deleteSubscription(stripeSubscriptionId)
} catch (e) {
console.error(`cannot delete subscription ${stripeSubscriptionId}`, e)
Logger.error(`cannot delete subscription ${stripeSubscriptionId}`, e)
}
}
return stripeSubscriptionId
Expand Down
15 changes: 8 additions & 7 deletions packages/server/dataloader/azureDevOpsLoaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import AzureDevOpsServerManager, {
TeamProjectReference,
WorkItem
} from '../utils/AzureDevOpsServerManager'
import {Logger} from '../utils/Logger'
import sendToSentry from '../utils/sendToSentry'
import RootDataLoader from './RootDataLoader'

Expand Down Expand Up @@ -215,7 +216,7 @@ export const azureDevOpsAllWorkItems = (

const {error, workItems} = restResult
if (error !== undefined || workItems === undefined) {
console.log(error)
Logger.log(error)
return [] as AzureDevOpsWorkItem[]
}

Expand Down Expand Up @@ -264,7 +265,7 @@ export const azureDevUserInfo = (
const restResult = await manager.getMe()
const {error, azureDevOpsUser} = restResult
if (error !== undefined || azureDevOpsUser === undefined) {
console.log(error)
Logger.log(error)
return undefined
}
return {
Expand Down Expand Up @@ -303,7 +304,7 @@ export const allAzureDevOpsAccessibleOrgs = (
const results = await manager.getAccessibleOrgs(id)
const {error, accessibleOrgs} = results
// handle error if defined
console.log(error)
Logger.log(error)
return accessibleOrgs.map((resource) => ({
...resource
}))
Expand Down Expand Up @@ -340,7 +341,7 @@ export const allAzureDevOpsProjects = (
)
const {error, projects} = await manager.getAllUserProjects()
if (error !== undefined) {
console.log(error)
Logger.log(error)
return []
}
if (projects !== null) resultReferences.push(...projects)
Expand Down Expand Up @@ -383,7 +384,7 @@ export const azureDevOpsProject = (
)
const projectRes = await manager.getProject(instanceId, projectId)
if (projectRes instanceof Error) {
console.log(projectRes)
Logger.log(projectRes)
return null
}
return {
Expand Down Expand Up @@ -475,7 +476,7 @@ export const azureDevOpsUserStory = (
const restResult = await manager.getWorkItemData(instanceId, workItemIds)
const {error, workItems} = restResult
if (error !== undefined || workItems.length !== 1 || !workItems[0]) {
console.log(error)
Logger.log(error)
return null
} else {
const returnedWorkItem: WorkItem = workItems[0]
Expand Down Expand Up @@ -637,7 +638,7 @@ export const azureDevOpsWorkItems = (
const workItemData = await manager.getWorkItemData(instanceId, workItemIds)
const {error: workItemDataError, workItems: returnedWorkItems} = workItemData
if (workItemDataError !== undefined) {
console.log(error)
Logger.log(error)
return []
}

Expand Down
3 changes: 2 additions & 1 deletion packages/server/fileStorage/GCSManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {sign} from 'jsonwebtoken'
import mime from 'mime-types'
import path from 'path'
import {Logger} from '../utils/Logger'
import FileStoreManager from './FileStoreManager'

interface CloudKey {
Expand Down Expand Up @@ -132,7 +133,7 @@ export default class GCSManager extends FileStoreManager {
// https://github.com/nodejs/undici/issues/583#issuecomment-1577475664
// GCS will cause undici to error randomly with `SocketError: other side closed` `code: 'UND_ERR_SOCKET'`
if ((e as any).cause?.code === 'UND_ERR_SOCKET') {
console.log(' Retrying GCS Post:', fullPath)
Logger.log(' Retrying GCS Post:', fullPath)
await this.putFile(file, fullPath)
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/server/graphql/mutations/endCheckIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import removeSuggestedAction from '../../safeMutations/removeSuggestedAction'
import {analytics} from '../../utils/analytics/analytics'
import {getUserId, isTeamMember} from '../../utils/authorization'
import getPhase from '../../utils/getPhase'
import {Logger} from '../../utils/Logger'
import publish from '../../utils/publish'
import standardError from '../../utils/standardError'
import {DataLoaderWorker, GQLContext} from '../graphql'
Expand Down Expand Up @@ -230,7 +231,7 @@ export default {
const updatedTaskIds = (result && result.updatedTaskIds) || []

analytics.checkInEnd(completedCheckIn, meetingMembers, team, dataLoader)
sendNewMeetingSummary(completedCheckIn, context).catch(console.log)
sendNewMeetingSummary(completedCheckIn, context).catch(Logger.log)
checkTeamsLimit(team.orgId, dataLoader)

const events = teamMembers.map(
Expand Down
3 changes: 2 additions & 1 deletion packages/server/graphql/mutations/endSprintPoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import sendNewMeetingSummary from './helpers/endMeeting/sendNewMeetingSummary'
import {IntegrationNotifier} from './helpers/notifications/IntegrationNotifier'
import removeEmptyTasks from './helpers/removeEmptyTasks'
import updateTeamInsights from './helpers/updateTeamInsights'
import {Logger} from '../../utils/Logger'

export default {
type: new GraphQLNonNull(EndSprintPokerPayload),
Expand Down Expand Up @@ -114,7 +115,7 @@ export default {
analytics.sprintPokerEnd(completedMeeting, meetingMembers, template, dataLoader)
const isKill = !!(phase && phase.phaseType !== 'ESTIMATE')
if (!isKill) {
sendNewMeetingSummary(completedMeeting, context).catch(console.log)
sendNewMeetingSummary(completedMeeting, context).catch(Logger.log)
checkTeamsLimit(team.orgId, dataLoader)
}
const events = teamMembers.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ms from 'ms'
import getRethink from '../../../database/rethinkDriver'
import SlackServerManager from '../../../utils/SlackServerManager'
import {upsertNotifications} from '../addSlackAuth'
import {Logger} from '../../../utils/Logger'

const activatePrevSlackAuth = async (userId: string, teamId: string) => {
const r = await getRethink()
Expand Down Expand Up @@ -29,7 +30,7 @@ const activatePrevSlackAuth = async (userId: string, teamId: string) => {
const manager = new SlackServerManager(botAccessToken)
const authRes = await manager.isValidAuthToken(botAccessToken)
if (!authRes.ok) {
console.error(authRes.error)
Logger.error(authRes.error)
return
}

Expand Down
5 changes: 3 additions & 2 deletions packages/server/graphql/mutations/helpers/generateGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {AutogroupReflectionGroupType} from '../../../database/types/MeetingRetro
import {SubscriptionChannel} from '../../../../client/types/constEnums'
import publish from '../../../utils/publish'
import {analytics} from '../../../utils/analytics/analytics'
import {Logger} from '../../../utils/Logger'

const generateGroups = async (
reflections: Reflection[],
Expand All @@ -24,13 +25,13 @@ const generateGroups = async (

const themes = await manager.generateThemes(groupReflectionsInput)
if (!themes) {
console.warn('ChatGPT was unable to generate themes')
Logger.warn('ChatGPT was unable to generate themes')
return
}
const groupedReflections = await manager.groupReflections(groupReflectionsInput, themes)

if (!groupedReflections) {
console.warn('ChatGPT was unable to group the reflections')
Logger.warn('ChatGPT was unable to group the reflections')
return
}
const autogroupReflectionGroups: AutogroupReflectionGroupType[] = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Stripe from 'stripe'
import {getStripeManager} from '../../../utils/stripe'
import {stripeCardToDBCard} from './stripeCardToDBCard'
import {Logger} from '../../../utils/Logger'

export default async function getCCFromCustomer(
customer: Stripe.Customer | Stripe.DeletedCustomer
Expand All @@ -16,7 +17,7 @@ export default async function getCCFromCustomer(
// customers that used Stripe Elements have default_payment_method: https://stripe.com/docs/payments/payment-methods/transitioning?locale=en-GB
const cardRes = await manager.retrieveDefaultCardDetails(customer.id)
if (cardRes instanceof Error) {
console.error(cardRes)
Logger.error(cardRes)
return undefined
}
return stripeCardToDBCard(cardRes)
Expand Down
3 changes: 2 additions & 1 deletion packages/server/graphql/mutations/helpers/removeFromOrg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {DataLoaderWorker} from '../../graphql'
import removeTeamMember from './removeTeamMember'
import resolveDowngradeToStarter from './resolveDowngradeToStarter'
import {RDatum} from '../../../database/stricterR'
import {Logger} from '../../../utils/Logger'

const removeFromOrg = async (
userId: string,
Expand Down Expand Up @@ -93,7 +94,7 @@ const removeFromOrg = async (
try {
await adjustUserCount(userId, orgId, InvoiceItemType.REMOVE_USER, dataLoader)
} catch (e) {
console.log(e)
Logger.log(e)
}
await setUserTierForUserIds([userId])
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Organization from '../../../database/types/Organization'
import getKysely from '../../../postgres/getKysely'
import updateTeamByOrgId from '../../../postgres/queries/updateTeamByOrgId'
import {analytics} from '../../../utils/analytics/analytics'
import {Logger} from '../../../utils/Logger'
import setTierForOrgUsers from '../../../utils/setTierForOrgUsers'
import setUserTierForOrgId from '../../../utils/setUserTierForOrgId'
import {getStripeManager} from '../../../utils/stripe'
Expand All @@ -22,7 +23,7 @@ const resolveDowngradeToStarter = async (
try {
await manager.deleteSubscription(stripeSubscriptionId)
} catch (e) {
console.log(e)
Logger.log(e)
}

const [org] = await Promise.all([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import removeEmptyTasks from './removeEmptyTasks'
import updateQualAIMeetingsCount from './updateQualAIMeetingsCount'
import gatherInsights from './gatherInsights'
import NotificationMentioned from '../../../database/types/NotificationMentioned'
import {Logger} from '../../../utils/Logger'

const getTranscription = async (recallBotId?: string | null) => {
if (!recallBotId) return
Expand Down Expand Up @@ -245,7 +246,7 @@ const summarizeRetroMeeting = async (meeting: MeetingRetrospective, context: Int

dataLoader.get('newMeetings').clear(meetingId)
// wait for whole meeting summary to be generated before sending summary email and updating qualAIMeetingCount
sendNewMeetingSummary(meeting, context).catch(console.log)
sendNewMeetingSummary(meeting, context).catch(Logger.log)
updateQualAIMeetingsCount(meetingId, teamId, dataLoader)
// wait for meeting stats to be generated before sending Slack notification
IntegrationNotifier.endMeeting(dataLoader, meetingId, teamId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import updateTeamInsights from './updateTeamInsights'
import generateStandupMeetingSummary from './generateStandupMeetingSummary'
import updateQualAIMeetingsCount from './updateQualAIMeetingsCount'
import gatherInsights from './gatherInsights'
import {Logger} from '../../../utils/Logger'

const summarizeTeamPrompt = async (meeting: MeetingTeamPrompt, context: InternalContext) => {
const {dataLoader} = context
Expand All @@ -31,7 +32,7 @@ const summarizeTeamPrompt = async (meeting: MeetingTeamPrompt, context: Internal

dataLoader.get('newMeetings').clear(meeting.id)
// wait for whole meeting summary to be generated before sending summary email and updating qualAIMeetingCount
sendNewMeetingSummary(meeting, context).catch(console.log)
sendNewMeetingSummary(meeting, context).catch(Logger.log)
updateQualAIMeetingsCount(meeting.id, meeting.teamId, dataLoader)
// wait for meeting stats to be generated before sending Slack notification
IntegrationNotifier.endMeeting(dataLoader, meeting.id, meeting.teamId)
Expand Down
3 changes: 2 additions & 1 deletion packages/server/graphql/mutations/moveTeamToOrg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import standardError from '../../utils/standardError'
import {DataLoaderWorker, GQLContext} from '../graphql'
import isValid from '../isValid'
import getKysely from '../../postgres/getKysely'
import {Logger} from '../../utils/Logger'

const MAX_NUM_TEAMS = 40

Expand Down Expand Up @@ -168,7 +169,7 @@ export default {
const successes = results.filter((result) => typeof result === 'string')
const failures = results.filter((result) => typeof result !== 'string')
const successStr = successes.join('\n')
console.error('failures', failures)
Logger.error('failures', failures)
return successStr
}
}
3 changes: 2 additions & 1 deletion packages/server/graphql/mutations/navigateMeeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {GQLContext} from '../graphql'
import NavigateMeetingPayload from '../types/NavigateMeetingPayload'
import handleCompletedStage from './helpers/handleCompletedStage'
import removeScheduledJobs from './helpers/removeScheduledJobs'
import {Logger} from '../../utils/Logger'

export default {
type: new GraphQLNonNull(NavigateMeetingPayload),
Expand Down Expand Up @@ -84,7 +85,7 @@ export default {
phaseCompleteData = await handleCompletedStage(stage, meeting, dataLoader)
if (stage.scheduledEndTime) {
// not critical, no await needed
removeScheduledJobs(stage.scheduledEndTime, {meetingId}).catch(console.error)
removeScheduledJobs(stage.scheduledEndTime, {meetingId}).catch(Logger.error)
stage.scheduledEndTime = null
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/server/graphql/mutations/selectTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import standardError from '../../utils/standardError'
import {GQLContext} from '../graphql'
import SelectTemplatePayload from '../types/SelectTemplatePayload'
import {getFeatureTier} from '../types/helpers/getFeatureTier'
import {Logger} from '../../utils/Logger'

const selectTemplate = {
description: 'Set the selected template for the upcoming retro meeting',
Expand Down Expand Up @@ -37,7 +38,7 @@ const selectTemplate = {
])

if (!template || !template.isActive) {
console.log('no template', selectedTemplateId, template)
Logger.log('no template', selectedTemplateId, template)
return standardError(new Error('Template not found'), {userId: viewerId})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import upsertAzureDevOpsDimensionFieldMap, {
AzureDevOpsFieldMapProps
} from '../../postgres/queries/upsertAzureDevOpsDimensionFieldMap'
import {isTeamMember} from '../../utils/authorization'
import {Logger} from '../../utils/Logger'
import publish from '../../utils/publish'
import {GQLContext} from '../graphql'
import UpdateAzureDevOpsDimensionFieldPayload from '../types/UpdateAzureDevOpsDimensionFieldPayload'
Expand Down Expand Up @@ -57,7 +58,7 @@ const updateAzureDevOpsDimensionField = {
},
{authToken, dataLoader, socketId: mutatorId}: GQLContext
) => {
//console.log(`Inside updateAzureDevOpsDimensionField`)
//Logger.log(`Inside updateAzureDevOpsDimensionField`)
const operationId = dataLoader.share()
const subOptions = {mutatorId, operationId}

Expand Down Expand Up @@ -91,7 +92,7 @@ const updateAzureDevOpsDimensionField = {
} as AzureDevOpsFieldMapProps
await upsertAzureDevOpsDimensionFieldMap(props)
} catch (e) {
console.log(e)
Logger.log(e)
}

const data = {teamId, meetingId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {SubscriptionChannel} from 'parabol-client/types/constEnums'
import MeetingPoker from '../../database/types/MeetingPoker'
import upsertGitHubDimensionFieldMap from '../../postgres/queries/upsertGitHubDimensionFieldMap'
import {isTeamMember} from '../../utils/authorization'
import {Logger} from '../../utils/Logger'
import publish from '../../utils/publish'
import {GQLContext} from '../graphql'
import UpdateGitHubDimensionFieldPayload from '../types/UpdateGitHubDimensionFieldPayload'
Expand Down Expand Up @@ -66,7 +67,7 @@ const updateGitHubDimensionField = {
try {
await upsertGitHubDimensionFieldMap(teamId, dimensionName, nameWithOwner, labelTemplate)
} catch (e) {
console.log(e)
Logger.log(e)
}

const data = {meetingId, teamId}
Expand Down
3 changes: 2 additions & 1 deletion packages/server/graphql/private/mutations/autopauseUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import adjustUserCount from '../../../billing/helpers/adjustUserCount'
import getRethink from '../../../database/rethinkDriver'
import getUserIdsToPause from '../../../postgres/queries/getUserIdsToPause'
import {MutationResolvers} from '../resolverTypes'
import {Logger} from '../../../utils/Logger'

const autopauseUsers: MutationResolvers['autopauseUsers'] = async (
_source,
Expand Down Expand Up @@ -32,7 +33,7 @@ const autopauseUsers: MutationResolvers['autopauseUsers'] = async (
try {
return await adjustUserCount(userId, orgIds, InvoiceItemType.AUTO_PAUSE_USER, dataLoader)
} catch (e) {
console.warn(`Error adjusting user count`)
Logger.warn(`Error adjusting user count`)
}
return undefined
})
Expand Down
Loading
Loading