Revert "fix: naming of segments for sqs handlers"
This reverts commit d244cc0d5f
.
This commit is contained in:
parent
d244cc0d5f
commit
8a00d159a6
6 changed files with 33 additions and 9 deletions
|
@ -190,6 +190,7 @@ import {
|
|||
ControllerContainer,
|
||||
ControllerContainerInterface,
|
||||
MapperInterface,
|
||||
ServiceIdentifier,
|
||||
SharedVaultUser,
|
||||
} from '@standardnotes/domain-core'
|
||||
import { SessionTracePersistenceMapper } from '../Mapping/SessionTracePersistenceMapper'
|
||||
|
@ -1235,7 +1236,11 @@ export class ContainerConfigLoader {
|
|||
.bind<DomainEventMessageHandlerInterface>(TYPES.Auth_DomainEventMessageHandler)
|
||||
.toConstantValue(
|
||||
isConfiguredForAWSProduction
|
||||
? new SQSXRayEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger))
|
||||
? new SQSXRayEventMessageHandler(
|
||||
ServiceIdentifier.NAMES.AuthWorker,
|
||||
eventHandlers,
|
||||
container.get(TYPES.Auth_Logger),
|
||||
)
|
||||
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger)),
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import {
|
|||
DomainEventSubscriberFactoryInterface,
|
||||
DomainEventSubscriberInterface,
|
||||
} from '@standardnotes/domain-events'
|
||||
import { Segment, captureAWSv3Client } from 'aws-xray-sdk'
|
||||
|
||||
export class SQSDomainEventSubscriberFactory implements DomainEventSubscriberFactoryInterface {
|
||||
constructor(
|
||||
|
@ -19,7 +18,7 @@ export class SQSDomainEventSubscriberFactory implements DomainEventSubscriberFac
|
|||
attributeNames: ['All'],
|
||||
messageAttributeNames: ['compression', 'event'],
|
||||
queueUrl: this.queueUrl,
|
||||
sqs: captureAWSv3Client(this.sqs, new Segment('test')),
|
||||
sqs: this.sqs,
|
||||
handleMessage:
|
||||
/* istanbul ignore next */
|
||||
async (message: Message) => await this.domainEventMessageHandler.handleMessage(<string>message.Body),
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
|
||||
export class SQSXRayEventMessageHandler implements DomainEventMessageHandlerInterface {
|
||||
constructor(
|
||||
private serviceName: string,
|
||||
private handlers: Map<string, DomainEventHandlerInterface>,
|
||||
private logger: Logger,
|
||||
) {}
|
||||
|
@ -32,14 +33,14 @@ export class SQSXRayEventMessageHandler implements DomainEventMessageHandlerInte
|
|||
|
||||
this.logger.debug(`Received event: ${domainEvent.type}`)
|
||||
|
||||
const xRaySegment = new Segment(domainEvent.type)
|
||||
const xRaySegment = new Segment(this.serviceName)
|
||||
|
||||
if (domainEvent.meta.correlation.userIdentifierType === 'uuid') {
|
||||
xRaySegment.setUser(domainEvent.meta.correlation.userIdentifier)
|
||||
}
|
||||
|
||||
await captureAsyncFunc(
|
||||
`${handler.constructor.name}.handle`,
|
||||
domainEvent.type,
|
||||
async (subsegment?: Subsegment) => {
|
||||
await handler.handle(domainEvent)
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ import { S3FileMover } from '../Infra/S3/S3FileMover'
|
|||
import { FSFileMover } from '../Infra/FS/FSFileMover'
|
||||
import { MoveFile } from '../Domain/UseCase/MoveFile/MoveFile'
|
||||
import { SharedVaultValetTokenAuthMiddleware } from '../Infra/InversifyExpress/Middleware/SharedVaultValetTokenAuthMiddleware'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
async load(configuration?: {
|
||||
|
@ -306,7 +307,11 @@ export class ContainerConfigLoader {
|
|||
.bind<DomainEventMessageHandlerInterface>(TYPES.Files_DomainEventMessageHandler)
|
||||
.toConstantValue(
|
||||
env.get('NEW_RELIC_ENABLED', true) === 'true'
|
||||
? new SQSXRayEventMessageHandler(eventHandlers, container.get(TYPES.Files_Logger))
|
||||
? new SQSXRayEventMessageHandler(
|
||||
ServiceIdentifier.NAMES.FilesWorker,
|
||||
eventHandlers,
|
||||
container.get(TYPES.Files_Logger),
|
||||
)
|
||||
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Files_Logger)),
|
||||
)
|
||||
container
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import { ControllerContainer, ControllerContainerInterface, MapperInterface } from '@standardnotes/domain-core'
|
||||
import {
|
||||
ControllerContainer,
|
||||
ControllerContainerInterface,
|
||||
MapperInterface,
|
||||
ServiceIdentifier,
|
||||
} from '@standardnotes/domain-core'
|
||||
import Redis from 'ioredis'
|
||||
import { Container, interfaces } from 'inversify'
|
||||
import { MongoRepository, Repository } from 'typeorm'
|
||||
|
@ -525,7 +530,11 @@ export class ContainerConfigLoader {
|
|||
.bind<DomainEventMessageHandlerInterface>(TYPES.Revisions_DomainEventMessageHandler)
|
||||
.toConstantValue(
|
||||
env.get('NEW_RELIC_ENABLED', true) === 'true'
|
||||
? new SQSXRayEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger))
|
||||
? new SQSXRayEventMessageHandler(
|
||||
ServiceIdentifier.NAMES.RevisionsWorker,
|
||||
eventHandlers,
|
||||
container.get(TYPES.Revisions_Logger),
|
||||
)
|
||||
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger)),
|
||||
)
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ import {
|
|||
ControllerContainer,
|
||||
ControllerContainerInterface,
|
||||
MapperInterface,
|
||||
ServiceIdentifier,
|
||||
SharedVaultUser,
|
||||
} from '@standardnotes/domain-core'
|
||||
import { BaseItemsController } from '../Infra/InversifyExpressUtils/Base/BaseItemsController'
|
||||
|
@ -1172,7 +1173,11 @@ export class ContainerConfigLoader {
|
|||
.bind<DomainEventMessageHandlerInterface>(TYPES.Sync_DomainEventMessageHandler)
|
||||
.toConstantValue(
|
||||
env.get('NEW_RELIC_ENABLED', true) === 'true'
|
||||
? new SQSXRayEventMessageHandler(eventHandlers, container.get(TYPES.Sync_Logger))
|
||||
? new SQSXRayEventMessageHandler(
|
||||
ServiceIdentifier.NAMES.SyncingServerWorker,
|
||||
eventHandlers,
|
||||
container.get(TYPES.Sync_Logger),
|
||||
)
|
||||
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Sync_Logger)),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue