Compare commits

...

16 Commits

Author SHA1 Message Date
standardci
4afe32650f chore(release): publish new version
- @standardnotes/analytics@2.28.8
 - @standardnotes/api-gateway@1.78.5
 - @standardnotes/auth-server@1.155.0
 - @standardnotes/domain-events-infra@1.16.4
 - @standardnotes/event-store@1.12.18
 - @standardnotes/files-server@1.28.4
 - @standardnotes/home-server@1.16.43
 - @standardnotes/revisions-server@1.43.0
 - @standardnotes/scheduler-server@1.22.8
 - @standardnotes/syncing-server@1.115.0
 - @standardnotes/websockets-server@1.14.4
2023-10-10 06:32:17 +00:00
Karol Sójko
c021bb3d7c fix(syncing-server): add option to define otel ratio 2023-10-10 08:16:00 +02:00
Karol Sójko
783fd9e2c6 feat: add more logs to transition 2023-10-10 08:16:00 +02:00
standardci
d789c67649 chore(release): publish new version
- @standardnotes/analytics@2.28.7
 - @standardnotes/api-gateway@1.78.4
 - @standardnotes/auth-server@1.154.3
 - @standardnotes/domain-events-infra@1.16.3
 - @standardnotes/event-store@1.12.17
 - @standardnotes/files-server@1.28.3
 - @standardnotes/home-server@1.16.42
 - @standardnotes/revisions-server@1.42.3
 - @standardnotes/scheduler-server@1.22.7
 - @standardnotes/syncing-server@1.114.3
 - @standardnotes/websockets-server@1.14.3
2023-10-09 18:10:27 +00:00
Karol Sójko
3ab29569db fix(syncing-server): add opentelemetry starting info in logs 2023-10-09 19:50:02 +02:00
Karol Sójko
099c6e10c6 fix(domain-events-infra): add parent context on internal span 2023-10-09 19:38:35 +02:00
Karol Sójko
76ae6f5a88 Revert "Revert "fix: setting parent span on workers""
This reverts commit 3fc07a5b60.
2023-10-09 19:13:43 +02:00
standardci
9bd2b0c953 chore(release): publish new version
- @standardnotes/analytics@2.28.6
 - @standardnotes/api-gateway@1.78.3
 - @standardnotes/auth-server@1.154.2
 - @standardnotes/domain-events-infra@1.16.2
 - @standardnotes/event-store@1.12.16
 - @standardnotes/files-server@1.28.2
 - @standardnotes/home-server@1.16.41
 - @standardnotes/revisions-server@1.42.2
 - @standardnotes/scheduler-server@1.22.6
 - @standardnotes/syncing-server@1.114.2
 - @standardnotes/websockets-server@1.14.2
2023-10-09 14:04:36 +00:00
Karol Sójko
3fc07a5b60 Revert "fix: setting parent span on workers"
This reverts commit 1c54d18c3c.
2023-10-09 15:46:10 +02:00
standardci
94e18ab36b chore(release): publish new version
- @standardnotes/analytics@2.28.5
 - @standardnotes/api-gateway@1.78.2
 - @standardnotes/auth-server@1.154.1
 - @standardnotes/domain-events-infra@1.16.1
 - @standardnotes/event-store@1.12.15
 - @standardnotes/files-server@1.28.1
 - @standardnotes/home-server@1.16.40
 - @standardnotes/revisions-server@1.42.1
 - @standardnotes/scheduler-server@1.22.5
 - @standardnotes/syncing-server@1.114.1
 - @standardnotes/websockets-server@1.14.1
2023-10-09 13:30:07 +00:00
Karol Sójko
1c54d18c3c fix: setting parent span on workers 2023-10-09 15:13:07 +02:00
standardci
d2efa73fd7 chore(release): publish new version
- @standardnotes/analytics@2.28.4
 - @standardnotes/api-gateway@1.78.1
 - @standardnotes/auth-server@1.154.0
 - @standardnotes/domain-events-infra@1.16.0
 - @standardnotes/event-store@1.12.14
 - @standardnotes/files-server@1.28.0
 - @standardnotes/home-server@1.16.39
 - @standardnotes/revisions-server@1.42.0
 - @standardnotes/scheduler-server@1.22.4
 - @standardnotes/syncing-server@1.114.0
 - @standardnotes/websockets-server@1.14.0
2023-10-09 12:49:25 +00:00
Karol Sójko
b47c80cccd feat(domain-events-infra): add express instrumentation 2023-10-09 14:30:51 +02:00
Karol Sójko
b72e515931 feat(domain-events-infra): add ioredis instrumentation 2023-10-09 14:22:24 +02:00
Karol Sójko
65fcc657a7 feat(domain-events-infra): add winston instrumentation 2023-10-09 14:16:25 +02:00
Karol Sójko
65ced2cc7b feat: add custom tracing on workers 2023-10-09 14:08:35 +02:00
47 changed files with 717 additions and 34 deletions

View File

@@ -38,10 +38,6 @@ jobs:
run: |
jq '(.containerDefinitions[] | select(.name=="${{ inputs.service_name }}-prod") | .environment[] | select(.name=="VERSION")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: Fill in the new package version in the Amazon ECS task definition
run: |
jq '(.containerDefinitions[] | select(.name=="${{ inputs.service_name }}-prod") | .environment[] | select(.name=="npm_package_version")).value = "${{ github.sha }}"' task-definition.json > tmp.json && mv tmp.json task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def-prod
uses: aws-actions/amazon-ecs-render-task-definition@v1

98
.pnp.cjs generated
View File

@@ -5159,6 +5159,32 @@ const RAW_RUNTIME_STATE =
"linkType": "HARD"\
}]\
]],\
["@opentelemetry/instrumentation-express", [\
["npm:0.33.1", {\
"packageLocation": "./.yarn/cache/@opentelemetry-instrumentation-express-npm-0.33.1-e22c0dd0d4-17dfb5ba50.zip/node_modules/@opentelemetry/instrumentation-express/",\
"packageDependencies": [\
["@opentelemetry/instrumentation-express", "npm:0.33.1"]\
],\
"linkType": "SOFT"\
}],\
["virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.33.1", {\
"packageLocation": "./.yarn/__virtual__/@opentelemetry-instrumentation-express-virtual-cc1a078a68/0/cache/@opentelemetry-instrumentation-express-npm-0.33.1-e22c0dd0d4-17dfb5ba50.zip/node_modules/@opentelemetry/instrumentation-express/",\
"packageDependencies": [\
["@opentelemetry/instrumentation-express", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.33.1"],\
["@opentelemetry/api", "npm:1.6.0"],\
["@opentelemetry/core", "virtual:d3c7bbf6a7f97a974e49c3267814e8607d9d8d839b4f62268d716ea7e832f7e3ded30c86e636fa7c95d6294ec5dc6ec07c16da5ffc14b141208d01acef9f1658#npm:1.17.0"],\
["@opentelemetry/instrumentation", "virtual:615937aa81839b05262fb17b9798d2b03176d47c4f8dad05d5bcb050f95f724786e9efd2e9f8e96aeb0f4f2bd3253509727df5e270ef87443598047e1192e3e9#npm:0.41.2"],\
["@opentelemetry/semantic-conventions", "npm:1.17.0"],\
["@types/express", "npm:4.17.17"],\
["@types/opentelemetry__api", null]\
],\
"packagePeers": [\
"@opentelemetry/api",\
"@types/opentelemetry__api"\
],\
"linkType": "HARD"\
}]\
]],\
["@opentelemetry/instrumentation-http", [\
["npm:0.43.0", {\
"packageLocation": "./.yarn/cache/@opentelemetry-instrumentation-http-npm-0.43.0-8e95b53fde-04f8be1648.zip/node_modules/@opentelemetry/instrumentation-http/",\
@@ -5185,6 +5211,58 @@ const RAW_RUNTIME_STATE =
"linkType": "HARD"\
}]\
]],\
["@opentelemetry/instrumentation-ioredis", [\
["npm:0.35.1", {\
"packageLocation": "./.yarn/cache/@opentelemetry-instrumentation-ioredis-npm-0.35.1-f1bfc45bc2-8345ef7567.zip/node_modules/@opentelemetry/instrumentation-ioredis/",\
"packageDependencies": [\
["@opentelemetry/instrumentation-ioredis", "npm:0.35.1"]\
],\
"linkType": "SOFT"\
}],\
["virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.35.1", {\
"packageLocation": "./.yarn/__virtual__/@opentelemetry-instrumentation-ioredis-virtual-cdfc31255d/0/cache/@opentelemetry-instrumentation-ioredis-npm-0.35.1-f1bfc45bc2-8345ef7567.zip/node_modules/@opentelemetry/instrumentation-ioredis/",\
"packageDependencies": [\
["@opentelemetry/instrumentation-ioredis", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.35.1"],\
["@opentelemetry/api", "npm:1.6.0"],\
["@opentelemetry/instrumentation", "virtual:615937aa81839b05262fb17b9798d2b03176d47c4f8dad05d5bcb050f95f724786e9efd2e9f8e96aeb0f4f2bd3253509727df5e270ef87443598047e1192e3e9#npm:0.41.2"],\
["@opentelemetry/redis-common", "npm:0.36.1"],\
["@opentelemetry/semantic-conventions", "npm:1.17.0"],\
["@types/ioredis4", [\
"@types/ioredis",\
"npm:4.28.10"\
]],\
["@types/opentelemetry__api", null]\
],\
"packagePeers": [\
"@opentelemetry/api",\
"@types/opentelemetry__api"\
],\
"linkType": "HARD"\
}]\
]],\
["@opentelemetry/instrumentation-winston", [\
["npm:0.32.1", {\
"packageLocation": "./.yarn/cache/@opentelemetry-instrumentation-winston-npm-0.32.1-4adcd85525-2292411336.zip/node_modules/@opentelemetry/instrumentation-winston/",\
"packageDependencies": [\
["@opentelemetry/instrumentation-winston", "npm:0.32.1"]\
],\
"linkType": "SOFT"\
}],\
["virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.32.1", {\
"packageLocation": "./.yarn/__virtual__/@opentelemetry-instrumentation-winston-virtual-6f270e74d1/0/cache/@opentelemetry-instrumentation-winston-npm-0.32.1-4adcd85525-2292411336.zip/node_modules/@opentelemetry/instrumentation-winston/",\
"packageDependencies": [\
["@opentelemetry/instrumentation-winston", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.32.1"],\
["@opentelemetry/api", "npm:1.6.0"],\
["@opentelemetry/instrumentation", "virtual:615937aa81839b05262fb17b9798d2b03176d47c4f8dad05d5bcb050f95f724786e9efd2e9f8e96aeb0f4f2bd3253509727df5e270ef87443598047e1192e3e9#npm:0.41.2"],\
["@types/opentelemetry__api", null]\
],\
"packagePeers": [\
"@opentelemetry/api",\
"@types/opentelemetry__api"\
],\
"linkType": "HARD"\
}]\
]],\
["@opentelemetry/otlp-exporter-base", [\
["npm:0.43.0", {\
"packageLocation": "./.yarn/cache/@opentelemetry-otlp-exporter-base-npm-0.43.0-f3aa808608-9565c55fed.zip/node_modules/@opentelemetry/otlp-exporter-base/",\
@@ -5378,6 +5456,15 @@ const RAW_RUNTIME_STATE =
"linkType": "HARD"\
}]\
]],\
["@opentelemetry/redis-common", [\
["npm:0.36.1", {\
"packageLocation": "./.yarn/cache/@opentelemetry-redis-common-npm-0.36.1-2ad15a6f4e-65962c6a9c.zip/node_modules/@opentelemetry/redis-common/",\
"packageDependencies": [\
["@opentelemetry/redis-common", "npm:0.36.1"]\
],\
"linkType": "HARD"\
}]\
]],\
["@opentelemetry/resource-detector-aws", [\
["npm:1.3.1", {\
"packageLocation": "./.yarn/cache/@opentelemetry-resource-detector-aws-npm-1.3.1-a531d502b9-05bcfda5a1.zip/node_modules/@opentelemetry/resource-detector-aws/",\
@@ -6732,7 +6819,10 @@ const RAW_RUNTIME_STATE =
["@opentelemetry/exporter-trace-otlp-grpc", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.43.0"],\
["@opentelemetry/id-generator-aws-xray", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:1.2.1"],\
["@opentelemetry/instrumentation-aws-sdk", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.36.0"],\
["@opentelemetry/instrumentation-express", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.33.1"],\
["@opentelemetry/instrumentation-http", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.43.0"],\
["@opentelemetry/instrumentation-ioredis", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.35.1"],\
["@opentelemetry/instrumentation-winston", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.32.1"],\
["@opentelemetry/propagator-aws-xray", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:1.3.1"],\
["@opentelemetry/resource-detector-aws", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:1.3.1"],\
["@opentelemetry/sdk-node", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.43.0"],\
@@ -7545,6 +7635,14 @@ const RAW_RUNTIME_STATE =
}]\
]],\
["@types/ioredis", [\
["npm:4.28.10", {\
"packageLocation": "./.yarn/cache/@types-ioredis-npm-4.28.10-4bdbe26a79-c160dccab1.zip/node_modules/@types/ioredis/",\
"packageDependencies": [\
["@types/ioredis", "npm:4.28.10"],\
["@types/node", "npm:20.2.5"]\
],\
"linkType": "HARD"\
}],\
["npm:5.0.0", {\
"packageLocation": "./.yarn/cache/@types-ioredis-npm-5.0.0-6efa70abfa-0d0c020c88.zip/node_modules/@types/ioredis/",\
"packageDependencies": [\

Binary file not shown.

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.28.8](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.7...@standardnotes/analytics@2.28.8) (2023-10-10)
**Note:** Version bump only for package @standardnotes/analytics
## [2.28.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.6...@standardnotes/analytics@2.28.7) (2023-10-09)
**Note:** Version bump only for package @standardnotes/analytics
## [2.28.6](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.5...@standardnotes/analytics@2.28.6) (2023-10-09)
**Note:** Version bump only for package @standardnotes/analytics
## [2.28.5](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.4...@standardnotes/analytics@2.28.5) (2023-10-09)
**Note:** Version bump only for package @standardnotes/analytics
## [2.28.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.3...@standardnotes/analytics@2.28.4) (2023-10-09)
**Note:** Version bump only for package @standardnotes/analytics
## [2.28.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.2...@standardnotes/analytics@2.28.3) (2023-10-09)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.28.3",
"version": "2.28.8",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.78.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.78.4...@standardnotes/api-gateway@1.78.5) (2023-10-10)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.78.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.78.3...@standardnotes/api-gateway@1.78.4) (2023-10-09)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.78.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.78.2...@standardnotes/api-gateway@1.78.3) (2023-10-09)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.78.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.78.1...@standardnotes/api-gateway@1.78.2) (2023-10-09)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.78.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.78.0...@standardnotes/api-gateway@1.78.1) (2023-10-09)
**Note:** Version bump only for package @standardnotes/api-gateway
# [1.78.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.77.2...@standardnotes/api-gateway@1.78.0) (2023-10-09)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.78.0",
"version": "1.78.5",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,36 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.155.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.154.3...@standardnotes/auth-server@1.155.0) (2023-10-10)
### Features
* add more logs to transition ([783fd9e](https://github.com/standardnotes/server/commit/783fd9e2c6350a7f0f1e8d009d01a3328564aca0))
## [1.154.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.154.2...@standardnotes/auth-server@1.154.3) (2023-10-09)
### Reverts
* Revert "Revert "fix: setting parent span on workers"" ([76ae6f5](https://github.com/standardnotes/server/commit/76ae6f5a882a82ab5f635452e3bc7b2b16709531))
## [1.154.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.154.1...@standardnotes/auth-server@1.154.2) (2023-10-09)
### Reverts
* Revert "fix: setting parent span on workers" ([3fc07a5](https://github.com/standardnotes/server/commit/3fc07a5b60c26b583efd88e8a80d4c4321e71efb))
## [1.154.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.154.0...@standardnotes/auth-server@1.154.1) (2023-10-09)
### Bug Fixes
* setting parent span on workers ([1c54d18](https://github.com/standardnotes/server/commit/1c54d18c3ca75353701ba921492a5ecfaa2e3572))
# [1.154.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.153.0...@standardnotes/auth-server@1.154.0) (2023-10-09)
### Features
* add custom tracing on workers ([65ced2c](https://github.com/standardnotes/server/commit/65ced2cc7b0686dc8af5cdad499412fc8fd29d1d))
# [1.153.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.152.2...@standardnotes/auth-server@1.153.0) (2023-10-09)
### Features

View File

@@ -17,6 +17,7 @@ import { RoleName, TransitionStatus } from '@standardnotes/domain-core'
const inputArgs = process.argv.slice(2)
const startDateString = inputArgs[0]
const endDateString = inputArgs[1]
const forceRunParam = inputArgs[2]
const requestTransition = async (
transitionStatusRepository: TransitionStatusRepositoryInterface,
@@ -38,6 +39,7 @@ const requestTransition = async (
)
let usersTriggered = 0
const forceRun = forceRunParam === 'true'
for (const user of users) {
const itemsTransitionStatus = await transitionStatusRepository.getStatus(user.uuid, 'items')
const revisionsTransitionStatus = await transitionStatusRepository.getStatus(user.uuid, 'revisions')
@@ -55,7 +57,11 @@ const requestTransition = async (
let wasTransitionRequested = false
if (itemsTransitionStatus === null || itemsTransitionStatus.value === TransitionStatus.STATUSES.Failed) {
if (
itemsTransitionStatus === null ||
itemsTransitionStatus.value === TransitionStatus.STATUSES.Failed ||
(itemsTransitionStatus.value === TransitionStatus.STATUSES.InProgress && forceRun)
) {
wasTransitionRequested = true
await transitionStatusRepository.remove(user.uuid, 'items')
@@ -68,7 +74,11 @@ const requestTransition = async (
)
}
if (revisionsTransitionStatus === null || revisionsTransitionStatus.value === TransitionStatus.STATUSES.Failed) {
if (
revisionsTransitionStatus === null ||
revisionsTransitionStatus.value === TransitionStatus.STATUSES.Failed ||
(revisionsTransitionStatus.value === TransitionStatus.STATUSES.InProgress && forceRun)
) {
wasTransitionRequested = true
await transitionStatusRepository.remove(user.uuid, 'revisions')

View File

@@ -8,6 +8,7 @@ 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) => {
@@ -20,6 +21,11 @@ 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,
)

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.153.0",
"version": "1.155.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -94,6 +94,7 @@ import {
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSOpenTelemetryEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { GetUserSubscription } from '../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { ChangeCredentials } from '../Domain/UseCase/ChangeCredentials/ChangeCredentials'
@@ -333,7 +334,11 @@ export class ContainerConfigLoader {
if (!isConfiguredForHomeServerOrSelfHosting) {
container
.bind<OpenTelemetrySDKInterface>(TYPES.Auth_OpenTelemetrySDK)
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.Auth))
.toConstantValue(
new OpenTelemetrySDK(
this.mode === 'server' ? ServiceIdentifier.NAMES.Auth : ServiceIdentifier.NAMES.AuthWorker,
),
)
}
if (!isConfiguredForInMemoryCache) {
@@ -1238,7 +1243,15 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Auth_DomainEventMessageHandler)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger)))
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.AuthWorker,
eventHandlers,
container.get(TYPES.Auth_Logger),
),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Auth_DomainEventSubscriberFactory)

View File

@@ -3,6 +3,43 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.16.4](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.16.3...@standardnotes/domain-events-infra@1.16.4) (2023-10-10)
### Bug Fixes
* **syncing-server:** add option to define otel ratio ([c021bb3](https://github.com/standardnotes/server/commit/c021bb3d7ca90179292e7c75f5a84bf2b941ce86))
## [1.16.3](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.16.2...@standardnotes/domain-events-infra@1.16.3) (2023-10-09)
### Bug Fixes
* **domain-events-infra:** add parent context on internal span ([099c6e1](https://github.com/standardnotes/server/commit/099c6e10c69b6b81006f59bcdb35325b545ab39c))
### Reverts
* Revert "Revert "fix: setting parent span on workers"" ([76ae6f5](https://github.com/standardnotes/server/commit/76ae6f5a882a82ab5f635452e3bc7b2b16709531))
## [1.16.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.16.1...@standardnotes/domain-events-infra@1.16.2) (2023-10-09)
### Reverts
* Revert "fix: setting parent span on workers" ([3fc07a5](https://github.com/standardnotes/server/commit/3fc07a5b60c26b583efd88e8a80d4c4321e71efb))
## [1.16.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.16.0...@standardnotes/domain-events-infra@1.16.1) (2023-10-09)
### Bug Fixes
* setting parent span on workers ([1c54d18](https://github.com/standardnotes/server/commit/1c54d18c3ca75353701ba921492a5ecfaa2e3572))
# [1.16.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.15.0...@standardnotes/domain-events-infra@1.16.0) (2023-10-09)
### Features
* add custom tracing on workers ([65ced2c](https://github.com/standardnotes/server/commit/65ced2cc7b0686dc8af5cdad499412fc8fd29d1d))
* **domain-events-infra:** add express instrumentation ([b47c80c](https://github.com/standardnotes/server/commit/b47c80cccd23af5d2ad375ef535a38f57362b8d0))
* **domain-events-infra:** add ioredis instrumentation ([b72e515](https://github.com/standardnotes/server/commit/b72e515931f5ea874494fa88be7dcee7ad693b3f))
* **domain-events-infra:** add winston instrumentation ([65fcc65](https://github.com/standardnotes/server/commit/65fcc657a77790c7f1b9b4a872ff59152e56bbc7))
# [1.15.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.14.9...@standardnotes/domain-events-infra@1.15.0) (2023-10-09)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events-infra",
"version": "1.15.0",
"version": "1.16.4",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -31,7 +31,10 @@
"@opentelemetry/exporter-trace-otlp-grpc": "^0.43.0",
"@opentelemetry/id-generator-aws-xray": "^1.2.1",
"@opentelemetry/instrumentation-aws-sdk": "^0.36.0",
"@opentelemetry/instrumentation-express": "^0.33.1",
"@opentelemetry/instrumentation-http": "^0.43.0",
"@opentelemetry/instrumentation-ioredis": "^0.35.1",
"@opentelemetry/instrumentation-winston": "^0.32.1",
"@opentelemetry/propagator-aws-xray": "^1.3.1",
"@opentelemetry/resource-detector-aws": "^1.3.1",
"@opentelemetry/sdk-node": "^0.43.0",

View File

@@ -8,13 +8,19 @@ import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray'
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'
import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk'
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto'
import { WinstonInstrumentation } from '@opentelemetry/instrumentation-winston'
import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis'
import { OpenTelemetrySDKInterface } from './OpenTelemetrySDKInterface'
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'
export class OpenTelemetrySDK implements OpenTelemetrySDKInterface {
private declare sdk: OpenTelemetrySDKNode.NodeSDK
constructor(private serviceName: string) {
constructor(
private serviceName: string,
private spanRatio?: number,
) {
this.build()
}
@@ -31,15 +37,33 @@ export class OpenTelemetrySDK implements OpenTelemetrySDKInterface {
exporter: new OTLPMetricExporter(),
})
const serviceName = this.serviceName
const winstonInstrumentation = new WinstonInstrumentation({
logHook: (_span, record) => {
record['resource.service.name'] = serviceName
},
})
const ratio = this.spanRatio ?? 0.01
this.sdk = new OpenTelemetrySDKNode.NodeSDK({
sampler: new OpenTelemetrySDKNode.tracing.TraceIdRatioBasedSampler(0.01),
sampler: new OpenTelemetrySDKNode.tracing.TraceIdRatioBasedSampler(ratio),
textMapPropagator: new AWSXRayPropagator(),
instrumentations: [
new HttpInstrumentation(),
new HttpInstrumentation({
ignoreIncomingRequestHook: (request) => {
const isHealthCheckUrl = !!request.url?.match(/\/healthcheck/)
return isHealthCheckUrl
},
}),
new ExpressInstrumentation(),
new AwsInstrumentation({
suppressInternalInstrumentation: true,
}),
new TypeormInstrumentation(),
winstonInstrumentation,
new IORedisInstrumentation(),
],
metricReader: metricReader,
resource: otResource,

View File

@@ -0,0 +1,69 @@
import { Logger } from 'winston'
import * as zlib from 'zlib'
import * as OpenTelemetryApi from '@opentelemetry/api'
import {
DomainEventHandlerInterface,
DomainEventInterface,
DomainEventMessageHandlerInterface,
} from '@standardnotes/domain-events'
export class SQSOpenTelemetryEventMessageHandler implements DomainEventMessageHandlerInterface {
private currentSpan: OpenTelemetryApi.Span | undefined
private internalSpan: OpenTelemetryApi.Span | undefined
constructor(
private serviceName: string,
private handlers: Map<string, DomainEventHandlerInterface>,
private logger: Logger,
) {}
async handleMessage(message: string): Promise<void> {
const messageParsed = JSON.parse(message)
const domainEventJson = zlib.unzipSync(Buffer.from(messageParsed.Message, 'base64')).toString()
const domainEvent: DomainEventInterface = JSON.parse(domainEventJson)
domainEvent.createdAt = new Date(domainEvent.createdAt)
const handler = this.handlers.get(domainEvent.type)
if (!handler) {
this.logger.debug(`Event handler for event type ${domainEvent.type} does not exist`)
return
}
this.logger.debug(`Received event: ${domainEvent.type}`)
const tracer = OpenTelemetryApi.trace.getTracer('sqs-handler')
this.currentSpan = tracer.startSpan(this.serviceName, { kind: OpenTelemetryApi.SpanKind.CONSUMER })
const ctx = OpenTelemetryApi.trace.setSpan(OpenTelemetryApi.context.active(), this.currentSpan)
this.internalSpan = tracer.startSpan(domainEvent.type, { kind: OpenTelemetryApi.SpanKind.INTERNAL }, ctx)
await handler.handle(domainEvent)
this.internalSpan.end()
this.currentSpan.end()
this.internalSpan = undefined
this.currentSpan = undefined
}
async handleError(error: Error): Promise<void> {
if (this.internalSpan) {
this.internalSpan.recordException(error)
this.internalSpan.end()
this.internalSpan = undefined
}
if (this.currentSpan) {
this.currentSpan.end()
this.currentSpan = undefined
}
this.logger.error('Error occured while handling SQS message: %O', error)
}
}

View File

@@ -15,3 +15,4 @@ export * from './SQS/SQSNewRelicBounceNotificiationHandler'
export * from './SQS/SQSDomainEventSubscriberFactory'
export * from './SQS/SQSEventMessageHandler'
export * from './SQS/SQSNewRelicEventMessageHandler'
export * from './SQS/SQSOpenTelemetryEventMessageHandler'

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.12.18](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.12.17...@standardnotes/event-store@1.12.18) (2023-10-10)
**Note:** Version bump only for package @standardnotes/event-store
## [1.12.17](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.12.16...@standardnotes/event-store@1.12.17) (2023-10-09)
**Note:** Version bump only for package @standardnotes/event-store
## [1.12.16](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.12.15...@standardnotes/event-store@1.12.16) (2023-10-09)
**Note:** Version bump only for package @standardnotes/event-store
## [1.12.15](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.12.14...@standardnotes/event-store@1.12.15) (2023-10-09)
**Note:** Version bump only for package @standardnotes/event-store
## [1.12.14](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.12.13...@standardnotes/event-store@1.12.14) (2023-10-09)
**Note:** Version bump only for package @standardnotes/event-store
## [1.12.13](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.12.12...@standardnotes/event-store@1.12.13) (2023-10-09)
**Note:** Version bump only for package @standardnotes/event-store

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/event-store",
"version": "1.12.13",
"version": "1.12.18",
"description": "Event Store Service",
"private": true,
"main": "dist/src/index.js",

View File

@@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.28.4](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.28.3...@standardnotes/files-server@1.28.4) (2023-10-10)
**Note:** Version bump only for package @standardnotes/files-server
## [1.28.3](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.28.2...@standardnotes/files-server@1.28.3) (2023-10-09)
### Reverts
* Revert "Revert "fix: setting parent span on workers"" ([76ae6f5](https://github.com/standardnotes/files/commit/76ae6f5a882a82ab5f635452e3bc7b2b16709531))
## [1.28.2](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.28.1...@standardnotes/files-server@1.28.2) (2023-10-09)
### Reverts
* Revert "fix: setting parent span on workers" ([3fc07a5](https://github.com/standardnotes/files/commit/3fc07a5b60c26b583efd88e8a80d4c4321e71efb))
## [1.28.1](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.28.0...@standardnotes/files-server@1.28.1) (2023-10-09)
### Bug Fixes
* setting parent span on workers ([1c54d18](https://github.com/standardnotes/files/commit/1c54d18c3ca75353701ba921492a5ecfaa2e3572))
# [1.28.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.27.0...@standardnotes/files-server@1.28.0) (2023-10-09)
### Features
* add custom tracing on workers ([65ced2c](https://github.com/standardnotes/files/commit/65ced2cc7b0686dc8af5cdad499412fc8fd29d1d))
# [1.27.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.26.4...@standardnotes/files-server@1.27.0) (2023-10-09)
### Features

View File

@@ -8,8 +8,9 @@ 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()
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
dayjs.extend(utc)
@@ -20,6 +21,11 @@ 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,
)

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.27.0",
"version": "1.28.4",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -21,6 +21,7 @@ import {
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSOpenTelemetryEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { StreamDownloadFile } from '../Domain/UseCase/StreamDownloadFile/StreamDownloadFile'
import { FileDownloaderInterface } from '../Domain/Services/FileDownloaderInterface'
@@ -57,6 +58,8 @@ 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,7 +99,11 @@ export class ContainerConfigLoader {
if (!isConfiguredForHomeServerOrSelfHosting) {
container
.bind<OpenTelemetrySDKInterface>(TYPES.Files_OpenTelemetrySDK)
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.Files))
.toConstantValue(
new OpenTelemetrySDK(
this.mode === 'server' ? ServiceIdentifier.NAMES.Files : ServiceIdentifier.NAMES.FilesWorker,
),
)
}
let logger: winston.Logger
@@ -306,7 +313,15 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Files_DomainEventMessageHandler)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Files_Logger)))
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Files_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.FilesWorker,
eventHandlers,
container.get(TYPES.Files_Logger),
),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Files_DomainEventSubscriberFactory)
.toConstantValue(

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.16.43](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.42...@standardnotes/home-server@1.16.43) (2023-10-10)
**Note:** Version bump only for package @standardnotes/home-server
## [1.16.42](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.41...@standardnotes/home-server@1.16.42) (2023-10-09)
**Note:** Version bump only for package @standardnotes/home-server
## [1.16.41](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.40...@standardnotes/home-server@1.16.41) (2023-10-09)
**Note:** Version bump only for package @standardnotes/home-server
## [1.16.40](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.39...@standardnotes/home-server@1.16.40) (2023-10-09)
**Note:** Version bump only for package @standardnotes/home-server
## [1.16.39](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.38...@standardnotes/home-server@1.16.39) (2023-10-09)
**Note:** Version bump only for package @standardnotes/home-server
## [1.16.38](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.16.37...@standardnotes/home-server@1.16.38) (2023-10-09)
**Note:** Version bump only for package @standardnotes/home-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/home-server",
"version": "1.16.38",
"version": "1.16.43",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,36 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.43.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.42.3...@standardnotes/revisions-server@1.43.0) (2023-10-10)
### Features
* add more logs to transition ([783fd9e](https://github.com/standardnotes/server/commit/783fd9e2c6350a7f0f1e8d009d01a3328564aca0))
## [1.42.3](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.42.2...@standardnotes/revisions-server@1.42.3) (2023-10-09)
### Reverts
* Revert "Revert "fix: setting parent span on workers"" ([76ae6f5](https://github.com/standardnotes/server/commit/76ae6f5a882a82ab5f635452e3bc7b2b16709531))
## [1.42.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.42.1...@standardnotes/revisions-server@1.42.2) (2023-10-09)
### Reverts
* Revert "fix: setting parent span on workers" ([3fc07a5](https://github.com/standardnotes/server/commit/3fc07a5b60c26b583efd88e8a80d4c4321e71efb))
## [1.42.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.42.0...@standardnotes/revisions-server@1.42.1) (2023-10-09)
### Bug Fixes
* setting parent span on workers ([1c54d18](https://github.com/standardnotes/server/commit/1c54d18c3ca75353701ba921492a5ecfaa2e3572))
# [1.42.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.41.0...@standardnotes/revisions-server@1.42.0) (2023-10-09)
### Features
* add custom tracing on workers ([65ced2c](https://github.com/standardnotes/server/commit/65ced2cc7b0686dc8af5cdad499412fc8fd29d1d))
# [1.41.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.40.4...@standardnotes/revisions-server@1.41.0) (2023-10-09)
### Bug Fixes

View File

@@ -6,6 +6,7 @@ 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) => {
@@ -16,6 +17,11 @@ 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,
)

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.41.0",
"version": "1.43.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -42,6 +42,7 @@ import {
SNSDomainEventPublisher,
OpenTelemetrySDKInterface,
OpenTelemetrySDK,
SQSOpenTelemetryEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { DumpRepositoryInterface } from '../Domain/Dump/DumpRepositoryInterface'
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
@@ -161,7 +162,11 @@ export class ContainerConfigLoader {
if (!isConfiguredForHomeServerOrSelfHosting) {
container
.bind<OpenTelemetrySDKInterface>(TYPES.Revisions_OpenTelemetrySDK)
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.Revisions))
.toConstantValue(
new OpenTelemetrySDK(
this.mode === 'server' ? ServiceIdentifier.NAMES.Revisions : ServiceIdentifier.NAMES.RevisionsWorker,
),
)
}
if (!isConfiguredForHomeServer) {
@@ -525,7 +530,15 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Revisions_DomainEventMessageHandler)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger)))
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.RevisionsWorker,
eventHandlers,
container.get(TYPES.Revisions_Logger),
),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Revisions_DomainEventSubscriberFactory)

View File

@@ -112,7 +112,11 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
const totalRevisionsCountForUser = await (
this.secondRevisionsRepository as RevisionRepositoryInterface
).countByUserUuid(userUuid)
this.logger.info(`[${userUuid.value}] Total revisions count for user: ${totalRevisionsCountForUser}`)
const totalPages = Math.ceil(totalRevisionsCountForUser / this.pageSize)
this.logger.info(`[${userUuid.value}] Total pages: ${totalPages}`)
let insertedRevisionsCount = 0
let skippedRevisionsCount = 0
for (let currentPage = initialPage; currentPage <= totalPages; currentPage++) {
const isPageInEvery10Percent = currentPage % Math.ceil(totalPages / 10) === 0
if (isPageInEvery10Percent) {
@@ -121,6 +125,9 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
(currentPage / totalPages) * 100,
)}% completed`,
)
this.logger.info(
`[${userUuid.value}] Inserted ${insertedRevisionsCount} revisions so far. Skipped ${skippedRevisionsCount} revisions so far.`,
)
await this.updateTransitionStatus(userUuid, TransitionStatus.STATUSES.InProgress, timestamp)
}
@@ -151,10 +158,13 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
userUuid.value
}] Revision ${revision.id.toString()} is older in secondary than revision in primary database`,
)
skippedRevisionsCount++
continue
}
if (revisionInPrimary.isIdenticalTo(revision)) {
skippedRevisionsCount++
continue
}
@@ -174,6 +184,8 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
const didSave = await this.primaryRevisionsRepository.insert(revision)
if (!didSave) {
this.logger.error(`Failed to save revision ${revision.id.toString()} to primary database`)
} else {
insertedRevisionsCount++
}
} catch (error) {
this.logger.error(
@@ -183,6 +195,10 @@ export class TransitionRevisionsFromPrimaryToSecondaryDatabaseForUser implements
}
}
this.logger.info(
`[${userUuid.value}] Inserted ${insertedRevisionsCount} revisions. Skipped ${skippedRevisionsCount} revisions.`,
)
return Result.ok()
} catch (error) {
return Result.fail(`Errored when migrating revisions for user ${userUuid.value}: ${(error as Error).message}`)

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.8](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.22.7...@standardnotes/scheduler-server@1.22.8) (2023-10-10)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.22.7](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.22.6...@standardnotes/scheduler-server@1.22.7) (2023-10-09)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.22.6](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.22.5...@standardnotes/scheduler-server@1.22.6) (2023-10-09)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.22.5](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.22.4...@standardnotes/scheduler-server@1.22.5) (2023-10-09)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.22.4](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.22.3...@standardnotes/scheduler-server@1.22.4) (2023-10-09)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.22.3](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.22.2...@standardnotes/scheduler-server@1.22.3) (2023-10-09)
**Note:** Version bump only for package @standardnotes/scheduler-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.22.3",
"version": "1.22.8",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,44 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.115.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.114.3...@standardnotes/syncing-server@1.115.0) (2023-10-10)
### Bug Fixes
* **syncing-server:** add option to define otel ratio ([c021bb3](https://github.com/standardnotes/syncing-server-js/commit/c021bb3d7ca90179292e7c75f5a84bf2b941ce86))
### Features
* add more logs to transition ([783fd9e](https://github.com/standardnotes/syncing-server-js/commit/783fd9e2c6350a7f0f1e8d009d01a3328564aca0))
## [1.114.3](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.114.2...@standardnotes/syncing-server@1.114.3) (2023-10-09)
### Bug Fixes
* **syncing-server:** add opentelemetry starting info in logs ([3ab2956](https://github.com/standardnotes/syncing-server-js/commit/3ab29569dbe23e9d546136c336b39ee1accb513f))
### Reverts
* Revert "Revert "fix: setting parent span on workers"" ([76ae6f5](https://github.com/standardnotes/syncing-server-js/commit/76ae6f5a882a82ab5f635452e3bc7b2b16709531))
## [1.114.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.114.1...@standardnotes/syncing-server@1.114.2) (2023-10-09)
### Reverts
* Revert "fix: setting parent span on workers" ([3fc07a5](https://github.com/standardnotes/syncing-server-js/commit/3fc07a5b60c26b583efd88e8a80d4c4321e71efb))
## [1.114.1](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.114.0...@standardnotes/syncing-server@1.114.1) (2023-10-09)
### Bug Fixes
* setting parent span on workers ([1c54d18](https://github.com/standardnotes/syncing-server-js/commit/1c54d18c3ca75353701ba921492a5ecfaa2e3572))
# [1.114.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.113.0...@standardnotes/syncing-server@1.114.0) (2023-10-09)
### Features
* add custom tracing on workers ([65ced2c](https://github.com/standardnotes/syncing-server-js/commit/65ced2cc7b0686dc8af5cdad499412fc8fd29d1d))
# [1.113.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.112.4...@standardnotes/syncing-server@1.113.0) (2023-10-09)
### Features

View File

@@ -75,6 +75,7 @@ void container.load().then((container) => {
const serverInstance = server.build()
if (!container.get<boolean>(TYPES.Sync_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
logger.info('Starting OpenTelemetry SDK...')
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Sync_OpenTelemetrySDK)
openTelemetrySDK.start()
}

View File

@@ -6,6 +6,7 @@ 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) => {
@@ -14,10 +15,17 @@ void container.load().then((container) => {
const logger: Logger = container.get(TYPES.Sync_Logger)
logger.info('Starting worker...')
if (!container.get<boolean>(TYPES.Sync_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
logger.info('Starting OpenTelemetry SDK...')
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Sync_OpenTelemetrySDK)
openTelemetrySDK.start()
}
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
TYPES.Sync_DomainEventSubscriberFactory,
)
logger.info('Starting worker...')
subscriberFactory.create().start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.113.0",
"version": "1.115.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -18,6 +18,7 @@ import {
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSOpenTelemetryEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { DomainEventFactoryInterface } from '../Domain/Event/DomainEventFactoryInterface'
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
@@ -236,6 +237,7 @@ export class ContainerConfigLoader {
const isConfiguredForHomeServerOrSelfHosting = isConfiguredForHomeServer || isConfiguredForSelfHosting
const isSecondaryDatabaseEnabled = env.get('SECONDARY_DB_ENABLED', true) === 'true'
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
const openTelemetryRatio = env.get('OTEL_SPAN_RATIO', true) ? +env.get('OTEL_SPAN_RATIO', true) : 0.01
container
.bind<boolean>(TYPES.Sync_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)
@@ -244,7 +246,14 @@ export class ContainerConfigLoader {
if (!isConfiguredForHomeServerOrSelfHosting) {
container
.bind<OpenTelemetrySDKInterface>(TYPES.Sync_OpenTelemetrySDK)
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.SyncingServer))
.toConstantValue(
new OpenTelemetrySDK(
this.mode === 'server'
? ServiceIdentifier.NAMES.SyncingServer
: ServiceIdentifier.NAMES.SyncingServerWorker,
openTelemetryRatio,
),
)
}
if (!isConfiguredForInMemoryCache) {
@@ -1168,7 +1177,15 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Sync_DomainEventMessageHandler)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Sync_Logger)))
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Sync_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.SyncingServerWorker,
eventHandlers,
container.get(TYPES.Sync_Logger),
),
)
}
container

View File

@@ -114,13 +114,20 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
const totalItemsCountForUser = await (this.secondaryItemRepository as ItemRepositoryInterface).countAll({
userUuid: userUuid.value,
})
this.logger.info(`[${userUuid.value}] Total items count for user: ${totalItemsCountForUser}`)
const totalPages = Math.ceil(totalItemsCountForUser / this.pageSize)
this.logger.info(`[${userUuid.value}] Total pages: ${totalPages}`)
let insertedItemsCount = 0
let skippedItemsCount = 0
for (let currentPage = initialPage; currentPage <= totalPages; currentPage++) {
const isPageInEvery10Percent = currentPage % Math.ceil(totalPages / 10) === 0
if (isPageInEvery10Percent) {
this.logger.info(
`[${userUuid.value}] Migrating items for user: ${Math.round((currentPage / totalPages) * 100)}% completed`,
)
this.logger.info(
`[${userUuid.value}] Inserted items count: ${insertedItemsCount}. Skipped items count: ${skippedItemsCount}`,
)
await this.updateTransitionStatus(userUuid, TransitionStatus.STATUSES.InProgress, timestamp)
}
@@ -148,10 +155,13 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
this.logger.info(
`[${userUuid.value}] Item ${item.uuid.value} is older in secondary than item in primary database`,
)
skippedItemsCount++
continue
}
if (itemInPrimary.isIdenticalTo(item)) {
skippedItemsCount++
continue
}
@@ -165,6 +175,8 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
}
await this.primaryItemRepository.save(item)
insertedItemsCount++
} catch (error) {
this.logger.error(
`Errored when saving item ${item.uuid.value} to primary database: ${(error as Error).message}`,
@@ -173,6 +185,10 @@ export class TransitionItemsFromPrimaryToSecondaryDatabaseForUser implements Use
}
}
this.logger.info(
`[${userUuid.value}] Inserted items count: ${insertedItemsCount}. Skipped items count: ${skippedItemsCount}`,
)
return Result.ok()
} catch (error) {
return Result.fail((error as Error).message)

View File

@@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.14.4](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.14.3...@standardnotes/websockets-server@1.14.4) (2023-10-10)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.14.3](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.14.2...@standardnotes/websockets-server@1.14.3) (2023-10-09)
### Reverts
* Revert "Revert "fix: setting parent span on workers"" ([76ae6f5](https://github.com/standardnotes/server/commit/76ae6f5a882a82ab5f635452e3bc7b2b16709531))
## [1.14.2](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.14.1...@standardnotes/websockets-server@1.14.2) (2023-10-09)
### Reverts
* Revert "fix: setting parent span on workers" ([3fc07a5](https://github.com/standardnotes/server/commit/3fc07a5b60c26b583efd88e8a80d4c4321e71efb))
## [1.14.1](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.14.0...@standardnotes/websockets-server@1.14.1) (2023-10-09)
### Bug Fixes
* setting parent span on workers ([1c54d18](https://github.com/standardnotes/server/commit/1c54d18c3ca75353701ba921492a5ecfaa2e3572))
# [1.14.0](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.13.0...@standardnotes/websockets-server@1.14.0) (2023-10-09)
### Features
* add custom tracing on workers ([65ced2c](https://github.com/standardnotes/server/commit/65ced2cc7b0686dc8af5cdad499412fc8fd29d1d))
# [1.13.0](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.12.1...@standardnotes/websockets-server@1.13.0) (2023-10-09)
### Features

View File

@@ -6,6 +6,7 @@ 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) => {
@@ -16,6 +17,9 @@ 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()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/websockets-server",
"version": "1.13.0",
"version": "1.14.4",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -22,7 +22,7 @@ import {
OpenTelemetrySDK,
OpenTelemetrySDKInterface,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSOpenTelemetryEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { ApiGatewayAuthMiddleware } from '../Controller/ApiGatewayAuthMiddleware'
@@ -42,6 +42,8 @@ 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()
@@ -50,7 +52,11 @@ export class ContainerConfigLoader {
container
.bind<OpenTelemetrySDKInterface>(TYPES.WebSockets_OpenTelemetrySDK)
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.Websockets))
.toConstantValue(
new OpenTelemetrySDK(
this.mode === 'server' ? ServiceIdentifier.NAMES.Websockets : ServiceIdentifier.NAMES.WebsocketsWorker,
),
)
const redisUrl = env.get('REDIS_URL')
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
@@ -158,7 +164,13 @@ export class ContainerConfigLoader {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
.toConstantValue(
new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.WebsocketsWorker,
eventHandlers,
container.get(TYPES.Logger),
),
)
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(

View File

@@ -4355,6 +4355,20 @@ __metadata:
languageName: node
linkType: hard
"@opentelemetry/instrumentation-express@npm:^0.33.1":
version: 0.33.1
resolution: "@opentelemetry/instrumentation-express@npm:0.33.1"
dependencies:
"@opentelemetry/core": "npm:^1.8.0"
"@opentelemetry/instrumentation": "npm:^0.41.2"
"@opentelemetry/semantic-conventions": "npm:^1.0.0"
"@types/express": "npm:4.17.17"
peerDependencies:
"@opentelemetry/api": ^1.3.0
checksum: 17dfb5ba508380a855a136553b5cc1f0abbe0220b272e358b6753870cd979bad5e1b7c45dad36b2d3b6e04247687f3d54cb295d3fb8e62b1f82c6947e70f4caf
languageName: node
linkType: hard
"@opentelemetry/instrumentation-http@npm:^0.43.0":
version: 0.43.0
resolution: "@opentelemetry/instrumentation-http@npm:0.43.0"
@@ -4369,6 +4383,31 @@ __metadata:
languageName: node
linkType: hard
"@opentelemetry/instrumentation-ioredis@npm:^0.35.1":
version: 0.35.1
resolution: "@opentelemetry/instrumentation-ioredis@npm:0.35.1"
dependencies:
"@opentelemetry/instrumentation": "npm:^0.41.2"
"@opentelemetry/redis-common": "npm:^0.36.1"
"@opentelemetry/semantic-conventions": "npm:^1.0.0"
"@types/ioredis4": "npm:@types/ioredis@^4.28.10"
peerDependencies:
"@opentelemetry/api": ^1.3.0
checksum: 8345ef7567128d674a1262ed64c03e6b7f7442564622ce680a98ebea038822209b1e829134df07eadf0cfdd3a368880e43ea7e3c9117980fc378c31a4bc044fd
languageName: node
linkType: hard
"@opentelemetry/instrumentation-winston@npm:^0.32.1":
version: 0.32.1
resolution: "@opentelemetry/instrumentation-winston@npm:0.32.1"
dependencies:
"@opentelemetry/instrumentation": "npm:^0.41.2"
peerDependencies:
"@opentelemetry/api": ^1.3.0
checksum: 2292411336811689815165a2299d4c2cc1fb77c7f9b8d044ff77fb17a29d0be850472c7a9d4be4c6bee2f4c2bd49a66d34cde1875d0c59f7727a0480e6f1143c
languageName: node
linkType: hard
"@opentelemetry/instrumentation@npm:0.43.0":
version: 0.43.0
resolution: "@opentelemetry/instrumentation@npm:0.43.0"
@@ -4495,6 +4534,13 @@ __metadata:
languageName: node
linkType: hard
"@opentelemetry/redis-common@npm:^0.36.1":
version: 0.36.1
resolution: "@opentelemetry/redis-common@npm:0.36.1"
checksum: 65962c6a9cbcd77e653eb42dc00deecf4988cec4c20de4fa15b3817214147f92531c46e803aedcd561c016d777d015f750eeebe081741d39bbb9d23fcb886f3f
languageName: node
linkType: hard
"@opentelemetry/resource-detector-aws@npm:^1.3.1":
version: 1.3.1
resolution: "@opentelemetry/resource-detector-aws@npm:1.3.1"
@@ -5991,7 +6037,10 @@ __metadata:
"@opentelemetry/exporter-trace-otlp-grpc": "npm:^0.43.0"
"@opentelemetry/id-generator-aws-xray": "npm:^1.2.1"
"@opentelemetry/instrumentation-aws-sdk": "npm:^0.36.0"
"@opentelemetry/instrumentation-express": "npm:^0.33.1"
"@opentelemetry/instrumentation-http": "npm:^0.43.0"
"@opentelemetry/instrumentation-ioredis": "npm:^0.35.1"
"@opentelemetry/instrumentation-winston": "npm:^0.32.1"
"@opentelemetry/propagator-aws-xray": "npm:^1.3.1"
"@opentelemetry/resource-detector-aws": "npm:^1.3.1"
"@opentelemetry/sdk-node": "npm:^0.43.0"
@@ -6773,7 +6822,7 @@ __metadata:
languageName: node
linkType: hard
"@types/express@npm:*, @types/express@npm:^4.17.14":
"@types/express@npm:*, @types/express@npm:4.17.17, @types/express@npm:^4.17.14":
version: 4.17.17
resolution: "@types/express@npm:4.17.17"
dependencies:
@@ -6803,6 +6852,15 @@ __metadata:
languageName: node
linkType: hard
"@types/ioredis4@npm:@types/ioredis@^4.28.10":
version: 4.28.10
resolution: "@types/ioredis@npm:4.28.10"
dependencies:
"@types/node": "npm:*"
checksum: c160dccab11b9bdc49e753a8fb4c18ccd0dd97c9b5aa966514cdc3f3fb6cd007e421f1de6044565446acd59059b18c8d8f6ae878c013d623a24ed196adead6f3
languageName: node
linkType: hard
"@types/ioredis@npm:^5.0.0":
version: 5.0.0
resolution: "@types/ioredis@npm:5.0.0"