@sentio/runtime 3.0.0-rc.9 → 3.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/lib/{chunk-MV6JXS2P.js → chunk-I45UXGDM.js} +1 -7
  2. package/lib/{chunk-4FNYVNIX.js → chunk-KVGBPLGJ.js} +76 -16
  3. package/lib/{chunk-4FNYVNIX.js.map → chunk-KVGBPLGJ.js.map} +1 -1
  4. package/lib/{chunk-CPJKSHSV.js → chunk-PCB4OKW7.js} +1 -2
  5. package/lib/{getMachineId-bsd-ZJR2OQTA.js → getMachineId-bsd-QYFPRONP.js} +2 -2
  6. package/lib/{getMachineId-darwin-OW6SYINH.js → getMachineId-darwin-XC67FIUW.js} +2 -2
  7. package/lib/{getMachineId-linux-L5XPRJBN.js → getMachineId-linux-4G7ZY7LQ.js} +2 -2
  8. package/lib/{getMachineId-unsupported-B3NMIOO3.js → getMachineId-unsupported-5IH5IW7P.js} +2 -2
  9. package/lib/{getMachineId-win-TT64F63B.js → getMachineId-win-WSA3TUKL.js} +2 -2
  10. package/lib/index.js +2 -2
  11. package/lib/processor-runner.js +14433 -27568
  12. package/lib/processor-runner.js.map +1 -1
  13. package/lib/service-worker.js +5 -5
  14. package/package.json +1 -1
  15. package/src/db-context.ts +0 -1
  16. package/src/otlp.ts +20 -12
  17. package/src/processor-runner.ts +3 -3
  18. package/src/service-v3.ts +11 -18
  19. /package/lib/{chunk-MV6JXS2P.js.map → chunk-I45UXGDM.js.map} +0 -0
  20. /package/lib/{chunk-CPJKSHSV.js.map → chunk-PCB4OKW7.js.map} +0 -0
  21. /package/lib/{getMachineId-bsd-ZJR2OQTA.js.map → getMachineId-bsd-QYFPRONP.js.map} +0 -0
  22. /package/lib/{getMachineId-darwin-OW6SYINH.js.map → getMachineId-darwin-XC67FIUW.js.map} +0 -0
  23. /package/lib/{getMachineId-linux-L5XPRJBN.js.map → getMachineId-linux-4G7ZY7LQ.js.map} +0 -0
  24. /package/lib/{getMachineId-unsupported-B3NMIOO3.js.map → getMachineId-unsupported-5IH5IW7P.js.map} +0 -0
  25. /package/lib/{getMachineId-win-TT64F63B.js.map → getMachineId-win-WSA3TUKL.js.map} +0 -0
@@ -1,18 +1,18 @@
1
1
  import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
2
2
  import {
3
3
  setupLogger
4
- } from "./chunk-CPJKSHSV.js";
4
+ } from "./chunk-PCB4OKW7.js";
5
5
  import {
6
6
  ProcessorServiceImpl,
7
7
  configureEndpoints,
8
8
  errorString,
9
9
  freezeGlobalConfig,
10
10
  require_cjs,
11
- require_lib3 as require_lib,
12
- require_lib4 as require_lib2
13
- } from "./chunk-4FNYVNIX.js";
11
+ require_lib2 as require_lib,
12
+ require_lib3 as require_lib2
13
+ } from "./chunk-KVGBPLGJ.js";
14
14
  import "./chunk-ROBPWJIE.js";
15
- import "./chunk-MV6JXS2P.js";
15
+ import "./chunk-I45UXGDM.js";
16
16
  import {
17
17
  __toESM
18
18
  } from "./chunk-KVSDPGUI.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "3.0.0-rc.9",
3
+ "version": "3.0.1-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
package/src/db-context.ts CHANGED
@@ -281,7 +281,6 @@ export class DataBindingContext extends AbstractStoreContext implements IDataBin
281
281
  }
282
282
 
283
283
  doSend(resp: DeepPartial<ProcessStreamResponseV3>) {
284
- console.debug('sending db request, processId ', this.processId, 'opId', resp.dbRequest?.opId)
285
284
  this.subject.next({
286
285
  ...resp,
287
286
  processId: this.processId
package/src/otlp.ts CHANGED
@@ -1,32 +1,40 @@
1
- import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'
1
+ import { IMetricReader, MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'
2
2
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc'
3
3
  import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'
4
- import { NodeSDK } from '@opentelemetry/sdk-node'
5
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'
6
4
  import { diag, DiagConsoleLogger, DiagLogLevel, metrics } from '@opentelemetry/api'
7
5
 
8
6
  export async function setupOTLP(debug?: boolean) {
7
+ console.log('Setting up OTLP metrics, debug=', !!debug)
9
8
  if (debug) {
10
9
  diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG)
11
10
  }
12
11
 
13
- const sdk = new NodeSDK({
14
- autoDetectResources: true,
15
- traceExporter: new OTLPTraceExporter(),
16
- metricReaders: [
17
- new PeriodicExportingMetricReader({
18
- exporter: new OTLPMetricExporter()
19
- }),
12
+ const readers: IMetricReader[] = [
13
+ new PeriodicExportingMetricReader({
14
+ exporter: new OTLPMetricExporter(),
15
+ exportIntervalMillis: 60000
16
+ })
17
+ ]
18
+ if (debug) {
19
+ readers.push(
20
20
  new PrometheusExporter({
21
21
  host: '0.0.0.0',
22
22
  port: 4041
23
23
  })
24
+ )
25
+ }
26
+ const meterProvider = new MeterProvider({
27
+ readers: [
28
+ new PeriodicExportingMetricReader({
29
+ exporter: new OTLPMetricExporter(),
30
+ exportIntervalMillis: 60000
31
+ })
24
32
  ]
25
33
  })
26
34
 
27
- sdk.start()
35
+ metrics.setGlobalMeterProvider(meterProvider)
28
36
  ;['SIGINT', 'SIGTERM'].forEach((signal) => {
29
- process.on(signal as any, () => sdk.shutdown().catch(console.error))
37
+ process.on(signal as any, () => meterProvider.forceFlush().catch(console.error))
30
38
  })
31
39
 
32
40
  metrics.getMeter('processor').createGauge('up').record(1)
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import fs from 'fs-extra'
4
-
4
+ // import { compressionAlgorithms } from '@grpc/grpc-js'
5
5
  import { createServer } from 'nice-grpc'
6
6
  import { errorDetailsServerMiddleware } from 'nice-grpc-error-details'
7
7
  // import { registry as niceGrpcRegistry } from 'nice-grpc-prometheus'
8
- import { openTelemetryServerMiddleware } from 'nice-grpc-opentelemetry'
8
+ // import { openTelemetryServerMiddleware } from 'nice-grpc-opentelemetry'
9
9
  import http from 'http'
10
10
  // @ts-ignore inspector promises is not included in @type/node
11
11
  import { Session } from 'node:inspector/promises'
@@ -61,7 +61,7 @@ if (options.startActionServer) {
61
61
  // 'grpc.default_compression_algorithm': compressionAlgorithms.gzip
62
62
  })
63
63
  // .use(prometheusServerMiddleware())
64
- .use(openTelemetryServerMiddleware())
64
+ // .use(openTelemetryServerMiddleware())
65
65
  .use(errorDetailsServerMiddleware)
66
66
 
67
67
  if (options.worker > 1) {
package/src/service-v3.ts CHANGED
@@ -29,6 +29,9 @@ import { ProcessorRuntimeOptions } from 'processor-runner-program.js'
29
29
 
30
30
  const { process_binding_count, process_binding_time, process_binding_error } = processMetrics
31
31
 
32
+ const WRITE_V2_EVENT_LOGS = process.env.WRITE_V2_EVENT_LOGS !== 'false'
33
+ const TIME_SERIES_RESULT_BATCH_SIZE = 1000
34
+
32
35
  export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation {
33
36
  readonly enablePartition: boolean
34
37
  private readonly loader: () => Promise<any>
@@ -165,35 +168,26 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
165
168
  ) {
166
169
  const context = this.contexts.new(processId, subject)
167
170
  const start = Date.now()
168
- console.debug('process binding', processId)
169
171
  PluginManager.INSTANCE.processBinding(binding, undefined, context)
170
172
  .then(async (result) => {
171
- console.debug(`process binding ${processId} done`)
172
173
  await context.awaitPendings()
173
174
  const { timeseriesResult, ...otherResults } = result
174
- console.debug('sending ts data length:', result.timeseriesResult.length)
175
- for (const ts of timeseriesResult) {
175
+ for (let i = 0; i < timeseriesResult.length; i += TIME_SERIES_RESULT_BATCH_SIZE) {
176
+ const batch = timeseriesResult.slice(i, i + TIME_SERIES_RESULT_BATCH_SIZE)
176
177
  subject.next({
177
178
  processId,
178
179
  tsRequest: {
179
- data: [ts]
180
+ data: batch
180
181
  }
181
182
  })
182
183
  }
183
184
 
184
- /* if (result.states?.configUpdated) {
185
- console.debug('sending tpl updates:')
186
- subject.next({
187
- processId,
188
- tplRequest: {
189
- templates: TemplateInstanceState.INSTANCE.getValues()
190
- }
191
- })
192
- }*/
193
-
194
- console.debug('sending binding result', processId)
195
185
  subject.next({
196
- result: otherResults,
186
+ result: WRITE_V2_EVENT_LOGS
187
+ ? otherResults
188
+ : {
189
+ states: otherResults.states
190
+ },
197
191
  processId: processId
198
192
  })
199
193
  recordRuntimeInfo(result, binding.handlerType)
@@ -207,7 +201,6 @@ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation
207
201
  const cost = Date.now() - start
208
202
  process_binding_time.add(cost)
209
203
  this.contexts.delete(processId)
210
- console.debug('process binding done', processId)
211
204
  })
212
205
  }
213
206