mirror of
https://github.com/standardnotes/server
synced 2026-01-16 20:04:32 -05:00
fix: opentelemetry instantiation
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AnalyticsWorker)
|
||||
sdk.start()
|
||||
|
||||
import { Logger } from 'winston'
|
||||
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
|
||||
import * as dayjs from 'dayjs'
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
DomainEventMessageHandlerInterface,
|
||||
DomainEventSubscriberFactoryInterface,
|
||||
} from '@standardnotes/domain-events'
|
||||
import { MapperInterface } from '@standardnotes/domain-core'
|
||||
import { MapperInterface, ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const Mixpanel = require('mixpanel')
|
||||
|
||||
@@ -17,7 +17,7 @@ import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
|
||||
import {
|
||||
SNSDomainEventPublisher,
|
||||
SQSDomainEventSubscriberFactory,
|
||||
SQSEventMessageHandler,
|
||||
SQSOpenTelemetryEventMessageHandler,
|
||||
} from '@standardnotes/domain-events-infra'
|
||||
import { Timer, TimerInterface } from '@standardnotes/time'
|
||||
import { PeriodKeyGeneratorInterface } from '../Domain/Time/PeriodKeyGeneratorInterface'
|
||||
@@ -243,7 +243,13 @@ export class ContainerConfigLoader {
|
||||
|
||||
container
|
||||
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
|
||||
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
|
||||
.toConstantValue(
|
||||
new SQSOpenTelemetryEventMessageHandler(
|
||||
ServiceIdentifier.NAMES.AnalyticsWorker,
|
||||
eventHandlers,
|
||||
container.get(TYPES.Logger),
|
||||
),
|
||||
)
|
||||
container
|
||||
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
|
||||
.toConstantValue(
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.ApiGateway)
|
||||
sdk.start()
|
||||
|
||||
import '../src/Controller/LegacyController'
|
||||
import '../src/Controller/HealthCheckController'
|
||||
|
||||
@@ -36,7 +42,6 @@ import { InversifyExpressServer } from 'inversify-express-utils'
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import { TYPES } from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
@@ -105,11 +110,6 @@ void container.load().then((container) => {
|
||||
|
||||
const serverInstance = server.build()
|
||||
|
||||
if (!container.get<boolean>(TYPES.ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.ApiGateway_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
}
|
||||
|
||||
serverInstance.listen(env.get('PORT'))
|
||||
|
||||
logger.info(`Server started on port ${process.env.PORT}`)
|
||||
|
||||
@@ -16,13 +16,12 @@ import { RedisCrossServiceTokenCache } from '../Infra/Redis/RedisCrossServiceTok
|
||||
import { WebSocketAuthMiddleware } from '../Controller/WebSocketAuthMiddleware'
|
||||
import { InMemoryCrossServiceTokenCache } from '../Infra/InMemory/InMemoryCrossServiceTokenCache'
|
||||
import { DirectCallServiceProxy } from '../Service/Proxy/DirectCallServiceProxy'
|
||||
import { ServiceContainerInterface, ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
import { ServiceContainerInterface } from '@standardnotes/domain-core'
|
||||
import { EndpointResolverInterface } from '../Service/Resolver/EndpointResolverInterface'
|
||||
import { EndpointResolver } from '../Service/Resolver/EndpointResolver'
|
||||
import { RequiredCrossServiceTokenMiddleware } from '../Controller/RequiredCrossServiceTokenMiddleware'
|
||||
import { OptionalCrossServiceTokenMiddleware } from '../Controller/OptionalCrossServiceTokenMiddleware'
|
||||
import { Transform } from 'stream'
|
||||
import { OpenTelemetrySDK, OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
async load(configuration?: {
|
||||
@@ -44,12 +43,6 @@ export class ContainerConfigLoader {
|
||||
.bind<boolean>(TYPES.ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)
|
||||
.toConstantValue(isConfiguredForHomeServerOrSelfHosting)
|
||||
|
||||
if (!isConfiguredForHomeServerOrSelfHosting) {
|
||||
container
|
||||
.bind<OpenTelemetrySDKInterface>(TYPES.ApiGateway_OpenTelemetrySDK)
|
||||
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.ApiGateway))
|
||||
}
|
||||
|
||||
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
||||
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
||||
await import('newrelic')
|
||||
|
||||
@@ -28,5 +28,4 @@ export const TYPES = {
|
||||
ApiGateway_CrossServiceTokenCache: Symbol.for('ApiGateway_CrossServiceTokenCache'),
|
||||
ApiGateway_Timer: Symbol.for('ApiGateway_Timer'),
|
||||
ApiGateway_EndpointResolver: Symbol.for('ApiGateway_EndpointResolver'),
|
||||
ApiGateway_OpenTelemetrySDK: Symbol.for('ApiGateway_OpenTelemetrySDK'),
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Auth)
|
||||
sdk.start()
|
||||
|
||||
import '../src/Infra/InversifyExpressUtils/AnnotatedAuthController'
|
||||
import '../src/Infra/InversifyExpressUtils/AnnotatedAuthenticatorsController'
|
||||
import '../src/Infra/InversifyExpressUtils/AnnotatedSessionsController'
|
||||
@@ -29,7 +35,6 @@ import { InversifyExpressServer } from 'inversify-express-utils'
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
@@ -67,11 +72,6 @@ void container.load().then((container) => {
|
||||
|
||||
const serverInstance = server.build()
|
||||
|
||||
if (!container.get<boolean>(TYPES.Auth_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Auth_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
}
|
||||
|
||||
serverInstance.listen(env.get('PORT'))
|
||||
|
||||
logger.info(`Server started on port ${process.env.PORT}`)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AuthWorker)
|
||||
sdk.start()
|
||||
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
@@ -8,7 +14,6 @@ import { Env } from '../src/Bootstrap/Env'
|
||||
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
|
||||
import * as dayjs from 'dayjs'
|
||||
import * as utc from 'dayjs/plugin/utc'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader('worker')
|
||||
void container.load().then((container) => {
|
||||
@@ -21,11 +26,6 @@ void container.load().then((container) => {
|
||||
|
||||
logger.info('Starting worker...')
|
||||
|
||||
if (!container.get<boolean>(TYPES.Auth_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Auth_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
}
|
||||
|
||||
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
|
||||
TYPES.Auth_DomainEventSubscriberFactory,
|
||||
)
|
||||
|
||||
@@ -89,8 +89,6 @@ import { ExtensionKeyGrantedEventHandler } from '../Domain/Handler/ExtensionKeyG
|
||||
import {
|
||||
DirectCallDomainEventPublisher,
|
||||
DirectCallEventMessageHandler,
|
||||
OpenTelemetrySDK,
|
||||
OpenTelemetrySDKInterface,
|
||||
SNSDomainEventPublisher,
|
||||
SQSDomainEventSubscriberFactory,
|
||||
SQSEventMessageHandler,
|
||||
@@ -331,16 +329,6 @@ export class ContainerConfigLoader {
|
||||
.bind<boolean>(TYPES.Auth_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)
|
||||
.toConstantValue(isConfiguredForHomeServerOrSelfHosting)
|
||||
|
||||
if (!isConfiguredForHomeServerOrSelfHosting) {
|
||||
container
|
||||
.bind<OpenTelemetrySDKInterface>(TYPES.Auth_OpenTelemetrySDK)
|
||||
.toConstantValue(
|
||||
new OpenTelemetrySDK(
|
||||
this.mode === 'server' ? ServiceIdentifier.NAMES.Auth : ServiceIdentifier.NAMES.AuthWorker,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
if (!isConfiguredForInMemoryCache) {
|
||||
const redisUrl = env.get('REDIS_URL')
|
||||
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
||||
|
||||
@@ -3,7 +3,6 @@ const TYPES = {
|
||||
Auth_Redis: Symbol.for('Auth_Redis'),
|
||||
Auth_SNS: Symbol.for('Auth_SNS'),
|
||||
Auth_SQS: Symbol.for('Auth_SQS'),
|
||||
Auth_OpenTelemetrySDK: Symbol.for('Auth_OpenTelemetrySDK'),
|
||||
// Mapping
|
||||
Auth_SessionTracePersistenceMapper: Symbol.for('Auth_SessionTracePersistenceMapper'),
|
||||
Auth_AuthenticatorChallengePersistenceMapper: Symbol.for('Auth_AuthenticatorChallengePersistenceMapper'),
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Files)
|
||||
sdk.start()
|
||||
|
||||
import * as busboy from 'connect-busboy'
|
||||
|
||||
import '../src/Infra/InversifyExpress/AnnotatedHealthCheckController'
|
||||
@@ -17,7 +23,6 @@ import { InversifyExpressServer } from 'inversify-express-utils'
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
@@ -91,11 +96,6 @@ void container.load().then((container) => {
|
||||
|
||||
const serverInstance = server.build()
|
||||
|
||||
if (!container.get<boolean>(TYPES.Files_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Files_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
}
|
||||
|
||||
serverInstance.listen(env.get('PORT'))
|
||||
|
||||
logger.info(`Server started on port ${process.env.PORT}`)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.FilesWorker)
|
||||
sdk.start()
|
||||
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
@@ -8,9 +14,8 @@ import { Env } from '../src/Bootstrap/Env'
|
||||
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
|
||||
import * as dayjs from 'dayjs'
|
||||
import * as utc from 'dayjs/plugin/utc'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader('worker')
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
dayjs.extend(utc)
|
||||
|
||||
@@ -21,11 +26,6 @@ void container.load().then((container) => {
|
||||
|
||||
logger.info('Starting worker...')
|
||||
|
||||
if (!container.get<boolean>(TYPES.Files_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Files_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
}
|
||||
|
||||
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
|
||||
TYPES.Files_DomainEventSubscriberFactory,
|
||||
)
|
||||
|
||||
@@ -16,8 +16,6 @@ import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
|
||||
import {
|
||||
DirectCallDomainEventPublisher,
|
||||
DirectCallEventMessageHandler,
|
||||
OpenTelemetrySDK,
|
||||
OpenTelemetrySDKInterface,
|
||||
SNSDomainEventPublisher,
|
||||
SQSDomainEventSubscriberFactory,
|
||||
SQSEventMessageHandler,
|
||||
@@ -58,8 +56,6 @@ import { SharedVaultValetTokenAuthMiddleware } from '../Infra/InversifyExpress/M
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
constructor(private mode: 'server' | 'worker' = 'server') {}
|
||||
|
||||
async load(configuration?: {
|
||||
directCallDomainEventPublisher?: DirectCallDomainEventPublisher
|
||||
logger?: Transform
|
||||
@@ -96,16 +92,6 @@ export class ContainerConfigLoader {
|
||||
.bind<boolean>(TYPES.Files_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)
|
||||
.toConstantValue(isConfiguredForHomeServerOrSelfHosting)
|
||||
|
||||
if (!isConfiguredForHomeServerOrSelfHosting) {
|
||||
container
|
||||
.bind<OpenTelemetrySDKInterface>(TYPES.Files_OpenTelemetrySDK)
|
||||
.toConstantValue(
|
||||
new OpenTelemetrySDK(
|
||||
this.mode === 'server' ? ServiceIdentifier.NAMES.Files : ServiceIdentifier.NAMES.FilesWorker,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
let logger: winston.Logger
|
||||
if (configuration?.logger) {
|
||||
logger = configuration.logger as winston.Logger
|
||||
|
||||
@@ -5,7 +5,6 @@ const TYPES = {
|
||||
Files_S3: Symbol.for('Files_S3'),
|
||||
Files_SNS: Symbol.for('Files_SNS'),
|
||||
Files_SQS: Symbol.for('Files_SQS'),
|
||||
Files_OpenTelemetrySDK: Symbol.for('Files_OpenTelemetrySDK'),
|
||||
|
||||
// use cases
|
||||
Files_UploadFileChunk: Symbol.for('Files_UploadFileChunk'),
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Revisions)
|
||||
sdk.start()
|
||||
|
||||
import * as cors from 'cors'
|
||||
import { urlencoded, json, Request, Response, NextFunction } from 'express'
|
||||
import * as winston from 'winston'
|
||||
@@ -11,7 +17,6 @@ import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
|
||||
import '../src/Infra/InversifyExpress/AnnotatedRevisionsController'
|
||||
import '../src/Infra/InversifyExpress/AnnotatedHealthCheckController'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
@@ -46,11 +51,6 @@ void container.load().then((container) => {
|
||||
|
||||
const serverInstance = server.build()
|
||||
|
||||
if (!container.get<boolean>(TYPES.Revisions_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Revisions_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
}
|
||||
|
||||
serverInstance.listen(env.get('PORT'))
|
||||
|
||||
logger.info(`Server started on port ${process.env.PORT}`)
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.RevisionsWorker)
|
||||
sdk.start()
|
||||
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader('worker')
|
||||
void container.load().then((container) => {
|
||||
@@ -17,11 +22,6 @@ void container.load().then((container) => {
|
||||
|
||||
logger.info('Starting worker...')
|
||||
|
||||
if (!container.get<boolean>(TYPES.Revisions_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Revisions_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
}
|
||||
|
||||
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
|
||||
TYPES.Revisions_DomainEventSubscriberFactory,
|
||||
)
|
||||
|
||||
@@ -40,8 +40,6 @@ import {
|
||||
DirectCallEventMessageHandler,
|
||||
DirectCallDomainEventPublisher,
|
||||
SNSDomainEventPublisher,
|
||||
OpenTelemetrySDKInterface,
|
||||
OpenTelemetrySDK,
|
||||
SQSOpenTelemetryEventMessageHandler,
|
||||
} from '@standardnotes/domain-events-infra'
|
||||
import { DumpRepositoryInterface } from '../Domain/Dump/DumpRepositoryInterface'
|
||||
@@ -159,16 +157,6 @@ export class ContainerConfigLoader {
|
||||
container.bind(TYPES.Revisions_NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true))
|
||||
container.bind(TYPES.Revisions_VERSION).toConstantValue(env.get('VERSION', true) ?? 'development')
|
||||
|
||||
if (!isConfiguredForHomeServerOrSelfHosting) {
|
||||
container
|
||||
.bind<OpenTelemetrySDKInterface>(TYPES.Revisions_OpenTelemetrySDK)
|
||||
.toConstantValue(
|
||||
new OpenTelemetrySDK(
|
||||
this.mode === 'server' ? ServiceIdentifier.NAMES.Revisions : ServiceIdentifier.NAMES.RevisionsWorker,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
if (!isConfiguredForHomeServer) {
|
||||
// env vars
|
||||
container.bind(TYPES.Revisions_SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN'))
|
||||
|
||||
@@ -5,7 +5,6 @@ const TYPES = {
|
||||
Revisions_SQS: Symbol.for('Revisions_SQS'),
|
||||
Revisions_SNS: Symbol.for('Revisions_SNS'),
|
||||
Revisions_S3: Symbol.for('Revisions_S3'),
|
||||
Revisions_OpenTelemetrySDK: Symbol.for('Revisions_OpenTelemetrySDK'),
|
||||
Revisions_Env: Symbol.for('Revisions_Env'),
|
||||
// Map
|
||||
Revisions_SQLLegacyRevisionMetadataPersistenceMapper: Symbol.for(
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.SchedulerWorker)
|
||||
sdk.start()
|
||||
|
||||
import { Logger } from 'winston'
|
||||
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
|
||||
import * as dayjs from 'dayjs'
|
||||
|
||||
@@ -16,7 +16,7 @@ import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
|
||||
import {
|
||||
SNSDomainEventPublisher,
|
||||
SQSDomainEventSubscriberFactory,
|
||||
SQSEventMessageHandler,
|
||||
SQSOpenTelemetryEventMessageHandler,
|
||||
} from '@standardnotes/domain-events-infra'
|
||||
import { Timer, TimerInterface } from '@standardnotes/time'
|
||||
import { PredicateRepositoryInterface } from '../Domain/Predicate/PredicateRepositoryInterface'
|
||||
@@ -34,6 +34,7 @@ import { VerifyPredicates } from '../Domain/UseCase/VerifyPredicates/VerifyPredi
|
||||
import { UserRegisteredEventHandler } from '../Domain/Handler/UserRegisteredEventHandler'
|
||||
import { SubscriptionCancelledEventHandler } from '../Domain/Handler/SubscriptionCancelledEventHandler'
|
||||
import { ExitDiscountAppliedEventHandler } from '../Domain/Handler/ExitDiscountAppliedEventHandler'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
async load(): Promise<Container> {
|
||||
@@ -153,7 +154,13 @@ export class ContainerConfigLoader {
|
||||
|
||||
container
|
||||
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
|
||||
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
|
||||
.toConstantValue(
|
||||
new SQSOpenTelemetryEventMessageHandler(
|
||||
ServiceIdentifier.NAMES.SchedulerWorker,
|
||||
eventHandlers,
|
||||
container.get(TYPES.Logger),
|
||||
),
|
||||
)
|
||||
container
|
||||
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
|
||||
.toConstantValue(
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Websockets)
|
||||
sdk.start()
|
||||
|
||||
import '../src/Infra/InversifyExpressUtils/AnnotatedHealthCheckController'
|
||||
import '../src/Infra/InversifyExpressUtils/AnnotatedWebSocketsController'
|
||||
|
||||
@@ -11,7 +17,6 @@ import { InversifyExpressServer } from 'inversify-express-utils'
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
@@ -47,9 +52,6 @@ void container.load().then((container) => {
|
||||
|
||||
const serverInstance = server.build()
|
||||
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.WebSockets_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
|
||||
serverInstance.listen(env.get('PORT'))
|
||||
|
||||
logger.info(`Server started on port ${process.env.PORT}`)
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.WebsocketsWorker)
|
||||
sdk.start()
|
||||
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
|
||||
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
void container.load().then((container) => {
|
||||
@@ -17,9 +22,6 @@ void container.load().then((container) => {
|
||||
|
||||
logger.info('Starting worker...')
|
||||
|
||||
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.WebSockets_OpenTelemetrySDK)
|
||||
openTelemetrySDK.start()
|
||||
|
||||
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(TYPES.DomainEventSubscriberFactory)
|
||||
subscriberFactory.create().start()
|
||||
})
|
||||
|
||||
@@ -19,8 +19,6 @@ import { AddWebSocketsConnection } from '../Domain/UseCase/AddWebSocketsConnecti
|
||||
import { RemoveWebSocketsConnection } from '../Domain/UseCase/RemoveWebSocketsConnection/RemoveWebSocketsConnection'
|
||||
import { WebSocketsClientMessenger } from '../Infra/WebSockets/WebSocketsClientMessenger'
|
||||
import {
|
||||
OpenTelemetrySDK,
|
||||
OpenTelemetrySDKInterface,
|
||||
SQSDomainEventSubscriberFactory,
|
||||
SQSOpenTelemetryEventMessageHandler,
|
||||
} from '@standardnotes/domain-events-infra'
|
||||
@@ -42,22 +40,12 @@ import { WebSocketMessageRequestedEventHandler } from '../Domain/Handler/WebSock
|
||||
import { ServiceIdentifier } from '@standardnotes/domain-core'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
constructor(private mode: 'server' | 'worker' = 'server') {}
|
||||
|
||||
async load(): Promise<Container> {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
|
||||
const container = new Container()
|
||||
|
||||
container
|
||||
.bind<OpenTelemetrySDKInterface>(TYPES.WebSockets_OpenTelemetrySDK)
|
||||
.toConstantValue(
|
||||
new OpenTelemetrySDK(
|
||||
this.mode === 'server' ? ServiceIdentifier.NAMES.Websockets : ServiceIdentifier.NAMES.WebsocketsWorker,
|
||||
),
|
||||
)
|
||||
|
||||
const redisUrl = env.get('REDIS_URL')
|
||||
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
||||
let redis
|
||||
|
||||
@@ -2,7 +2,6 @@ const TYPES = {
|
||||
Logger: Symbol.for('Logger'),
|
||||
Redis: Symbol.for('Redis'),
|
||||
SQS: Symbol.for('SQS'),
|
||||
WebSockets_OpenTelemetrySDK: Symbol.for('WebSockets_OpenTelemetrySDK'),
|
||||
WebSockets_ApiGatewayManagementApiClient: Symbol.for('WebSockets_ApiGatewayManagementApiClient'),
|
||||
// Controller
|
||||
WebSocketsController: Symbol.for('WebSocketsController'),
|
||||
|
||||
Reference in New Issue
Block a user