@dxos/client-services 0.1.55-main.8bdbdae → 0.1.55-main.afab830

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.
@@ -3738,7 +3738,7 @@ import { Event as Event7 } from "@dxos/async";
3738
3738
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
3739
3739
  import { getContextFromEntry, log as log14 } from "@dxos/log";
3740
3740
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
3741
- import { jsonify } from "@dxos/util";
3741
+ import { jsonify, numericalValues, tracer } from "@dxos/util";
3742
3742
  var LoggingServiceImpl = class {
3743
3743
  constructor() {
3744
3744
  this._logs = new Event7();
@@ -3753,6 +3753,46 @@ var LoggingServiceImpl = class {
3753
3753
  const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
3754
3754
  log14.runtimeConfig.processors.splice(index, 1);
3755
3755
  }
3756
+ async controlMetrics({ reset, record }) {
3757
+ if (reset) {
3758
+ tracer.clear();
3759
+ }
3760
+ if (record === true) {
3761
+ tracer.start();
3762
+ } else if (record === false) {
3763
+ tracer.stop();
3764
+ }
3765
+ return {
3766
+ recording: tracer.recording
3767
+ };
3768
+ }
3769
+ queryMetrics({ interval }) {
3770
+ const createNumericalValues = (key) => {
3771
+ var _a;
3772
+ const consume = (_a = tracer.get(key)) != null ? _a : [];
3773
+ return {
3774
+ key,
3775
+ stats: numericalValues(consume, "duration")
3776
+ };
3777
+ };
3778
+ return new Stream12(({ next }) => {
3779
+ const update = () => {
3780
+ const metrics = {
3781
+ timestamp: new Date(),
3782
+ values: [
3783
+ createNumericalValues("dxos.echo.pipeline.control"),
3784
+ createNumericalValues("dxos.echo.pipeline.data")
3785
+ ]
3786
+ };
3787
+ next(metrics);
3788
+ };
3789
+ update();
3790
+ const i = setInterval(update, interval);
3791
+ return () => {
3792
+ clearInterval(i);
3793
+ };
3794
+ });
3795
+ }
3756
3796
  queryLogs(request) {
3757
3797
  return new Stream12(({ ctx, next }) => {
3758
3798
  const handler = (entry2) => {
@@ -3858,7 +3898,8 @@ var SystemServiceImpl = class {
3858
3898
  async updateStatus({ status }) {
3859
3899
  await this._onUpdateStatus(status);
3860
3900
  }
3861
- queryStatus() {
3901
+ // TODO(burdon): Standardize interval option in stream request?
3902
+ queryStatus({ interval = 3e3 } = {}) {
3862
3903
  return new Stream14(({ next }) => {
3863
3904
  const update = () => {
3864
3905
  next({
@@ -3867,9 +3908,9 @@ var SystemServiceImpl = class {
3867
3908
  };
3868
3909
  update();
3869
3910
  const unsubscribe = this._statusUpdate.on(() => update());
3870
- const interval = setInterval(update, 3e3);
3911
+ const i = setInterval(update, interval);
3871
3912
  return () => {
3872
- clearInterval(interval);
3913
+ clearInterval(i);
3873
3914
  unsubscribe();
3874
3915
  };
3875
3916
  });
@@ -4166,4 +4207,4 @@ export {
4166
4207
  createDefaultModelFactory,
4167
4208
  ClientServicesHost
4168
4209
  };
4169
- //# sourceMappingURL=chunk-JW4TUGHP.mjs.map
4210
+ //# sourceMappingURL=chunk-CSJSC47N.mjs.map