feat: Complete zCode CLI X with Telegram bot integration

- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

View File

@@ -0,0 +1,14 @@
import { Context, HrTime, Attributes } from '@opentelemetry/api';
import { FixedSizeExemplarReservoirBase } from './ExemplarReservoir';
/**
* AlignedHistogramBucketExemplarReservoir takes the same boundaries
* configuration of a Histogram. This algorithm keeps the last seen measurement
* that falls within a histogram bucket.
*/
export declare class AlignedHistogramBucketExemplarReservoir extends FixedSizeExemplarReservoirBase {
private _boundaries;
constructor(boundaries: number[]);
private _findBucketIndex;
offer(value: number, timestamp: HrTime, attributes: Attributes, ctx: Context): void;
}
//# sourceMappingURL=AlignedHistogramBucketExemplarReservoir.d.ts.map

View File

@@ -0,0 +1,59 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { FixedSizeExemplarReservoirBase } from './ExemplarReservoir';
/**
* AlignedHistogramBucketExemplarReservoir takes the same boundaries
* configuration of a Histogram. This algorithm keeps the last seen measurement
* that falls within a histogram bucket.
*/
var AlignedHistogramBucketExemplarReservoir = /** @class */ (function (_super) {
__extends(AlignedHistogramBucketExemplarReservoir, _super);
function AlignedHistogramBucketExemplarReservoir(boundaries) {
var _this = _super.call(this, boundaries.length + 1) || this;
_this._boundaries = boundaries;
return _this;
}
AlignedHistogramBucketExemplarReservoir.prototype._findBucketIndex = function (value, _timestamp, _attributes, _ctx) {
for (var i = 0; i < this._boundaries.length; i++) {
if (value <= this._boundaries[i]) {
return i;
}
}
return this._boundaries.length;
};
AlignedHistogramBucketExemplarReservoir.prototype.offer = function (value, timestamp, attributes, ctx) {
var index = this._findBucketIndex(value, timestamp, attributes, ctx);
this._reservoirStorage[index].offer(value, timestamp, attributes, ctx);
};
return AlignedHistogramBucketExemplarReservoir;
}(FixedSizeExemplarReservoirBase));
export { AlignedHistogramBucketExemplarReservoir };
//# sourceMappingURL=AlignedHistogramBucketExemplarReservoir.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AlignedHistogramBucketExemplarReservoir.js","sourceRoot":"","sources":["../../../src/exemplar/AlignedHistogramBucketExemplarReservoir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAErE;;;;GAIG;AACH;IAA6D,2DAA8B;IAEzF,iDAAY,UAAoB;QAAhC,YACE,kBAAM,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,SAE7B;QADC,KAAI,CAAC,WAAW,GAAG,UAAU,CAAC;;IAChC,CAAC;IAEO,kEAAgB,GAAxB,UACE,KAAa,EACb,UAAkB,EAClB,WAAuB,EACvB,IAAa;QAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAChD,IAAI,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;gBAChC,OAAO,CAAC,CAAC;aACV;SACF;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,uDAAK,GAAL,UACE,KAAa,EACb,SAAiB,EACjB,UAAsB,EACtB,GAAY;QAEZ,IAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACvE,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACzE,CAAC;IACH,8CAAC;AAAD,CAAC,AA9BD,CAA6D,8BAA8B,GA8B1F","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, HrTime, Attributes } from '@opentelemetry/api';\nimport { FixedSizeExemplarReservoirBase } from './ExemplarReservoir';\n\n/**\n * AlignedHistogramBucketExemplarReservoir takes the same boundaries\n * configuration of a Histogram. This algorithm keeps the last seen measurement\n * that falls within a histogram bucket.\n */\nexport class AlignedHistogramBucketExemplarReservoir extends FixedSizeExemplarReservoirBase {\n private _boundaries: number[];\n constructor(boundaries: number[]) {\n super(boundaries.length + 1);\n this._boundaries = boundaries;\n }\n\n private _findBucketIndex(\n value: number,\n _timestamp: HrTime,\n _attributes: Attributes,\n _ctx: Context\n ) {\n for (let i = 0; i < this._boundaries.length; i++) {\n if (value <= this._boundaries[i]) {\n return i;\n }\n }\n return this._boundaries.length;\n }\n\n offer(\n value: number,\n timestamp: HrTime,\n attributes: Attributes,\n ctx: Context\n ): void {\n const index = this._findBucketIndex(value, timestamp, attributes, ctx);\n this._reservoirStorage[index].offer(value, timestamp, attributes, ctx);\n }\n}\n"]}

View File

@@ -0,0 +1,6 @@
import { Context, HrTime, Attributes } from '@opentelemetry/api';
import { ExemplarFilter } from './ExemplarFilter';
export declare class AlwaysSampleExemplarFilter implements ExemplarFilter {
shouldSample(_value: number, _timestamp: HrTime, _attributes: Attributes, _ctx: Context): boolean;
}
//# sourceMappingURL=AlwaysSampleExemplarFilter.d.ts.map

View File

@@ -0,0 +1,25 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var AlwaysSampleExemplarFilter = /** @class */ (function () {
function AlwaysSampleExemplarFilter() {
}
AlwaysSampleExemplarFilter.prototype.shouldSample = function (_value, _timestamp, _attributes, _ctx) {
return true;
};
return AlwaysSampleExemplarFilter;
}());
export { AlwaysSampleExemplarFilter };
//# sourceMappingURL=AlwaysSampleExemplarFilter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AlwaysSampleExemplarFilter.js","sourceRoot":"","sources":["../../../src/exemplar/AlwaysSampleExemplarFilter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH;IAAA;IASA,CAAC;IARC,iDAAY,GAAZ,UACE,MAAc,EACd,UAAkB,EAClB,WAAuB,EACvB,IAAa;QAEb,OAAO,IAAI,CAAC;IACd,CAAC;IACH,iCAAC;AAAD,CAAC,AATD,IASC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, HrTime, Attributes } from '@opentelemetry/api';\nimport { ExemplarFilter } from './ExemplarFilter';\n\nexport class AlwaysSampleExemplarFilter implements ExemplarFilter {\n shouldSample(\n _value: number,\n _timestamp: HrTime,\n _attributes: Attributes,\n _ctx: Context\n ): boolean {\n return true;\n }\n}\n"]}

View File

@@ -0,0 +1,15 @@
import { HrTime, Attributes } from '@opentelemetry/api';
/**
* A representation of an exemplar, which is a sample input measurement.
* Exemplars also hold information about the environment when the measurement
* was recorded, for example the span and trace ID of the active span when the
* exemplar was recorded.
*/
export declare type Exemplar = {
filteredAttributes: Attributes;
value: number;
timestamp: HrTime;
spanId?: string;
traceId?: string;
};
//# sourceMappingURL=Exemplar.d.ts.map

View File

@@ -0,0 +1,17 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};
//# sourceMappingURL=Exemplar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Exemplar.js","sourceRoot":"","sources":["../../../src/exemplar/Exemplar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { HrTime, Attributes } from '@opentelemetry/api';\n\n/**\n * A representation of an exemplar, which is a sample input measurement.\n * Exemplars also hold information about the environment when the measurement\n * was recorded, for example the span and trace ID of the active span when the\n * exemplar was recorded.\n */\nexport type Exemplar = {\n // The set of key/value pairs that were filtered out by the aggregator, but\n // recorded alongside the original measurement. Only key/value pairs that were\n // filtered out by the aggregator should be included\n filteredAttributes: Attributes;\n\n // The value of the measurement that was recorded.\n value: number;\n\n // timestamp is the exact time when this exemplar was recorded\n timestamp: HrTime;\n\n // (Optional) Span ID of the exemplar trace.\n // span_id may be missing if the measurement is not recorded inside a trace\n // or if the trace is not sampled.\n spanId?: string;\n\n // (Optional) Trace ID of the exemplar trace.\n // trace_id may be missing if the measurement is not recorded inside a trace\n // or if the trace is not sampled.\n traceId?: string;\n};\n"]}

View File

@@ -0,0 +1,18 @@
import { Context, HrTime, Attributes } from '@opentelemetry/api';
/**
* This interface represents a ExemplarFilter. Exemplar filters are
* used to filter measurements before attempting to store them in a
* reservoir.
*/
export interface ExemplarFilter {
/**
* Returns whether or not a reservoir should attempt to filter a measurement.
*
* @param value The value of the measurement
* @param timestamp A timestamp that best represents when the measurement was taken
* @param attributes The complete set of Attributes of the measurement
* @param ctx The Context of the measurement
*/
shouldSample(value: number, timestamp: HrTime, attributes: Attributes, ctx: Context): boolean;
}
//# sourceMappingURL=ExemplarFilter.d.ts.map

View File

@@ -0,0 +1,17 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};
//# sourceMappingURL=ExemplarFilter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExemplarFilter.js","sourceRoot":"","sources":["../../../src/exemplar/ExemplarFilter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, HrTime, Attributes } from '@opentelemetry/api';\n\n/**\n * This interface represents a ExemplarFilter. Exemplar filters are\n * used to filter measurements before attempting to store them in a\n * reservoir.\n */\nexport interface ExemplarFilter {\n /**\n * Returns whether or not a reservoir should attempt to filter a measurement.\n *\n * @param value The value of the measurement\n * @param timestamp A timestamp that best represents when the measurement was taken\n * @param attributes The complete set of Attributes of the measurement\n * @param ctx The Context of the measurement\n */\n shouldSample(\n value: number,\n timestamp: HrTime,\n attributes: Attributes,\n ctx: Context\n ): boolean;\n}\n"]}

View File

@@ -0,0 +1,43 @@
import { Context, HrTime, Attributes } from '@opentelemetry/api';
import { Exemplar } from './Exemplar';
/**
* An interface for an exemplar reservoir of samples.
*/
export interface ExemplarReservoir {
/** Offers a measurement to be sampled. */
offer(value: number, timestamp: HrTime, attributes: Attributes, ctx: Context): void;
/**
* Returns accumulated Exemplars and also resets the reservoir
* for the next sampling period
*
* @param pointAttributes The attributes associated with metric point.
*
* @returns a list of {@link Exemplar}s. Returned exemplars contain the attributes that were filtered out by the
* aggregator, but recorded alongside the original measurement.
*/
collect(pointAttributes: Attributes): Exemplar[];
}
declare class ExemplarBucket {
private value;
private attributes;
private timestamp;
private spanId?;
private traceId?;
private _offered;
offer(value: number, timestamp: HrTime, attributes: Attributes, ctx: Context): void;
collect(pointAttributes: Attributes): Exemplar | null;
}
export declare abstract class FixedSizeExemplarReservoirBase implements ExemplarReservoir {
protected _reservoirStorage: ExemplarBucket[];
protected _size: number;
constructor(size: number);
abstract offer(value: number, timestamp: HrTime, attributes: Attributes, ctx: Context): void;
maxSize(): number;
/**
* Resets the reservoir
*/
protected reset(): void;
collect(pointAttributes: Attributes): Exemplar[];
}
export {};
//# sourceMappingURL=ExemplarReservoir.d.ts.map

View File

@@ -0,0 +1,91 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { isSpanContextValid, trace, } from '@opentelemetry/api';
var ExemplarBucket = /** @class */ (function () {
function ExemplarBucket() {
this.value = 0;
this.attributes = {};
this.timestamp = [0, 0];
this._offered = false;
}
ExemplarBucket.prototype.offer = function (value, timestamp, attributes, ctx) {
this.value = value;
this.timestamp = timestamp;
this.attributes = attributes;
var spanContext = trace.getSpanContext(ctx);
if (spanContext && isSpanContextValid(spanContext)) {
this.spanId = spanContext.spanId;
this.traceId = spanContext.traceId;
}
this._offered = true;
};
ExemplarBucket.prototype.collect = function (pointAttributes) {
if (!this._offered)
return null;
var currentAttributes = this.attributes;
// filter attributes
Object.keys(pointAttributes).forEach(function (key) {
if (pointAttributes[key] === currentAttributes[key]) {
delete currentAttributes[key];
}
});
var retVal = {
filteredAttributes: currentAttributes,
value: this.value,
timestamp: this.timestamp,
spanId: this.spanId,
traceId: this.traceId,
};
this.attributes = {};
this.value = 0;
this.timestamp = [0, 0];
this.spanId = undefined;
this.traceId = undefined;
this._offered = false;
return retVal;
};
return ExemplarBucket;
}());
var FixedSizeExemplarReservoirBase = /** @class */ (function () {
function FixedSizeExemplarReservoirBase(size) {
this._size = size;
this._reservoirStorage = new Array(size);
for (var i = 0; i < this._size; i++) {
this._reservoirStorage[i] = new ExemplarBucket();
}
}
FixedSizeExemplarReservoirBase.prototype.maxSize = function () {
return this._size;
};
/**
* Resets the reservoir
*/
FixedSizeExemplarReservoirBase.prototype.reset = function () { };
FixedSizeExemplarReservoirBase.prototype.collect = function (pointAttributes) {
var exemplars = [];
this._reservoirStorage.forEach(function (storageItem) {
var res = storageItem.collect(pointAttributes);
if (res !== null) {
exemplars.push(res);
}
});
this.reset();
return exemplars;
};
return FixedSizeExemplarReservoirBase;
}());
export { FixedSizeExemplarReservoirBase };
//# sourceMappingURL=ExemplarReservoir.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
import { Context, HrTime, Attributes } from '@opentelemetry/api';
import { ExemplarFilter } from './ExemplarFilter';
export declare class NeverSampleExemplarFilter implements ExemplarFilter {
shouldSample(_value: number, _timestamp: HrTime, _attributes: Attributes, _ctx: Context): boolean;
}
//# sourceMappingURL=NeverSampleExemplarFilter.d.ts.map

View File

@@ -0,0 +1,25 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var NeverSampleExemplarFilter = /** @class */ (function () {
function NeverSampleExemplarFilter() {
}
NeverSampleExemplarFilter.prototype.shouldSample = function (_value, _timestamp, _attributes, _ctx) {
return false;
};
return NeverSampleExemplarFilter;
}());
export { NeverSampleExemplarFilter };
//# sourceMappingURL=NeverSampleExemplarFilter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NeverSampleExemplarFilter.js","sourceRoot":"","sources":["../../../src/exemplar/NeverSampleExemplarFilter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH;IAAA;IASA,CAAC;IARC,gDAAY,GAAZ,UACE,MAAc,EACd,UAAkB,EAClB,WAAuB,EACvB,IAAa;QAEb,OAAO,KAAK,CAAC;IACf,CAAC;IACH,gCAAC;AAAD,CAAC,AATD,IASC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, HrTime, Attributes } from '@opentelemetry/api';\nimport { ExemplarFilter } from './ExemplarFilter';\n\nexport class NeverSampleExemplarFilter implements ExemplarFilter {\n shouldSample(\n _value: number,\n _timestamp: HrTime,\n _attributes: Attributes,\n _ctx: Context\n ): boolean {\n return false;\n }\n}\n"]}

View File

@@ -0,0 +1,16 @@
import { Context, HrTime, Attributes } from '@opentelemetry/api';
import { FixedSizeExemplarReservoirBase } from './ExemplarReservoir';
/**
* Fixed size reservoir that uses equivalent of naive reservoir sampling
* algorithm to accept measurements.
*
*/
export declare class SimpleFixedSizeExemplarReservoir extends FixedSizeExemplarReservoirBase {
private _numMeasurementsSeen;
constructor(size: number);
private getRandomInt;
private _findBucketIndex;
offer(value: number, timestamp: HrTime, attributes: Attributes, ctx: Context): void;
reset(): void;
}
//# sourceMappingURL=SimpleFixedSizeExemplarReservoir.d.ts.map

View File

@@ -0,0 +1,66 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { FixedSizeExemplarReservoirBase } from './ExemplarReservoir';
/**
* Fixed size reservoir that uses equivalent of naive reservoir sampling
* algorithm to accept measurements.
*
*/
var SimpleFixedSizeExemplarReservoir = /** @class */ (function (_super) {
__extends(SimpleFixedSizeExemplarReservoir, _super);
function SimpleFixedSizeExemplarReservoir(size) {
var _this = _super.call(this, size) || this;
_this._numMeasurementsSeen = 0;
return _this;
}
SimpleFixedSizeExemplarReservoir.prototype.getRandomInt = function (min, max) {
//[min, max)
return Math.floor(Math.random() * (max - min) + min);
};
SimpleFixedSizeExemplarReservoir.prototype._findBucketIndex = function (_value, _timestamp, _attributes, _ctx) {
if (this._numMeasurementsSeen < this._size)
return this._numMeasurementsSeen++;
var index = this.getRandomInt(0, ++this._numMeasurementsSeen);
return index < this._size ? index : -1;
};
SimpleFixedSizeExemplarReservoir.prototype.offer = function (value, timestamp, attributes, ctx) {
var index = this._findBucketIndex(value, timestamp, attributes, ctx);
if (index !== -1) {
this._reservoirStorage[index].offer(value, timestamp, attributes, ctx);
}
};
SimpleFixedSizeExemplarReservoir.prototype.reset = function () {
this._numMeasurementsSeen = 0;
};
return SimpleFixedSizeExemplarReservoir;
}(FixedSizeExemplarReservoirBase));
export { SimpleFixedSizeExemplarReservoir };
//# sourceMappingURL=SimpleFixedSizeExemplarReservoir.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimpleFixedSizeExemplarReservoir.js","sourceRoot":"","sources":["../../../src/exemplar/SimpleFixedSizeExemplarReservoir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAErE;;;;GAIG;AACH;IAAsD,oDAA8B;IAElF,0CAAY,IAAY;QAAxB,YACE,kBAAM,IAAI,CAAC,SAEZ;QADC,KAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;;IAChC,CAAC;IAEO,uDAAY,GAApB,UAAqB,GAAW,EAAE,GAAW;QAC3C,YAAY;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;IACvD,CAAC;IAEO,2DAAgB,GAAxB,UACE,MAAc,EACd,UAAkB,EAClB,WAAuB,EACvB,IAAa;QAEb,IAAI,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,KAAK;YACxC,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACrC,IAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAChE,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,gDAAK,GAAL,UACE,KAAa,EACb,SAAiB,EACjB,UAAsB,EACtB,GAAY;QAEZ,IAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACvE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;SACxE;IACH,CAAC;IAEQ,gDAAK,GAAd;QACE,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;IAChC,CAAC;IACH,uCAAC;AAAD,CAAC,AAvCD,CAAsD,8BAA8B,GAuCnF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, HrTime, Attributes } from '@opentelemetry/api';\nimport { FixedSizeExemplarReservoirBase } from './ExemplarReservoir';\n\n/**\n * Fixed size reservoir that uses equivalent of naive reservoir sampling\n * algorithm to accept measurements.\n *\n */\nexport class SimpleFixedSizeExemplarReservoir extends FixedSizeExemplarReservoirBase {\n private _numMeasurementsSeen: number;\n constructor(size: number) {\n super(size);\n this._numMeasurementsSeen = 0;\n }\n\n private getRandomInt(min: number, max: number) {\n //[min, max)\n return Math.floor(Math.random() * (max - min) + min);\n }\n\n private _findBucketIndex(\n _value: number,\n _timestamp: HrTime,\n _attributes: Attributes,\n _ctx: Context\n ) {\n if (this._numMeasurementsSeen < this._size)\n return this._numMeasurementsSeen++;\n const index = this.getRandomInt(0, ++this._numMeasurementsSeen);\n return index < this._size ? index : -1;\n }\n\n offer(\n value: number,\n timestamp: HrTime,\n attributes: Attributes,\n ctx: Context\n ): void {\n const index = this._findBucketIndex(value, timestamp, attributes, ctx);\n if (index !== -1) {\n this._reservoirStorage[index].offer(value, timestamp, attributes, ctx);\n }\n }\n\n override reset() {\n this._numMeasurementsSeen = 0;\n }\n}\n"]}

View File

@@ -0,0 +1,6 @@
import { Context, HrTime, Attributes } from '@opentelemetry/api';
import { ExemplarFilter } from './ExemplarFilter';
export declare class WithTraceExemplarFilter implements ExemplarFilter {
shouldSample(value: number, timestamp: HrTime, attributes: Attributes, ctx: Context): boolean;
}
//# sourceMappingURL=WithTraceExemplarFilter.d.ts.map

View File

@@ -0,0 +1,29 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { isSpanContextValid, trace, TraceFlags, } from '@opentelemetry/api';
var WithTraceExemplarFilter = /** @class */ (function () {
function WithTraceExemplarFilter() {
}
WithTraceExemplarFilter.prototype.shouldSample = function (value, timestamp, attributes, ctx) {
var spanContext = trace.getSpanContext(ctx);
if (!spanContext || !isSpanContextValid(spanContext))
return false;
return spanContext.traceFlags & TraceFlags.SAMPLED ? true : false;
};
return WithTraceExemplarFilter;
}());
export { WithTraceExemplarFilter };
//# sourceMappingURL=WithTraceExemplarFilter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"WithTraceExemplarFilter.js","sourceRoot":"","sources":["../../../src/exemplar/WithTraceExemplarFilter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,kBAAkB,EAClB,KAAK,EACL,UAAU,GAEX,MAAM,oBAAoB,CAAC;AAG5B;IAAA;IAWA,CAAC;IAVC,8CAAY,GAAZ,UACE,KAAa,EACb,SAAiB,EACjB,UAAsB,EACtB,GAAY;QAEZ,IAAM,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAC;QACnE,OAAO,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACpE,CAAC;IACH,8BAAC;AAAD,CAAC,AAXD,IAWC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Context,\n HrTime,\n isSpanContextValid,\n trace,\n TraceFlags,\n Attributes,\n} from '@opentelemetry/api';\nimport { ExemplarFilter } from './ExemplarFilter';\n\nexport class WithTraceExemplarFilter implements ExemplarFilter {\n shouldSample(\n value: number,\n timestamp: HrTime,\n attributes: Attributes,\n ctx: Context\n ): boolean {\n const spanContext = trace.getSpanContext(ctx);\n if (!spanContext || !isSpanContextValid(spanContext)) return false;\n return spanContext.traceFlags & TraceFlags.SAMPLED ? true : false;\n }\n}\n"]}

View File

@@ -0,0 +1,9 @@
export { Exemplar } from './Exemplar';
export { ExemplarFilter } from './ExemplarFilter';
export { AlwaysSampleExemplarFilter } from './AlwaysSampleExemplarFilter';
export { NeverSampleExemplarFilter } from './NeverSampleExemplarFilter';
export { WithTraceExemplarFilter } from './WithTraceExemplarFilter';
export { ExemplarReservoir, FixedSizeExemplarReservoirBase, } from './ExemplarReservoir';
export { AlignedHistogramBucketExemplarReservoir } from './AlignedHistogramBucketExemplarReservoir';
export { SimpleFixedSizeExemplarReservoir } from './SimpleFixedSizeExemplarReservoir';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,22 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { AlwaysSampleExemplarFilter } from './AlwaysSampleExemplarFilter';
export { NeverSampleExemplarFilter } from './NeverSampleExemplarFilter';
export { WithTraceExemplarFilter } from './WithTraceExemplarFilter';
export { FixedSizeExemplarReservoirBase, } from './ExemplarReservoir';
export { AlignedHistogramBucketExemplarReservoir } from './AlignedHistogramBucketExemplarReservoir';
export { SimpleFixedSizeExemplarReservoir } from './SimpleFixedSizeExemplarReservoir';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exemplar/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAEL,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { Exemplar } from './Exemplar';\nexport { ExemplarFilter } from './ExemplarFilter';\nexport { AlwaysSampleExemplarFilter } from './AlwaysSampleExemplarFilter';\nexport { NeverSampleExemplarFilter } from './NeverSampleExemplarFilter';\nexport { WithTraceExemplarFilter } from './WithTraceExemplarFilter';\nexport {\n ExemplarReservoir,\n FixedSizeExemplarReservoirBase,\n} from './ExemplarReservoir';\nexport { AlignedHistogramBucketExemplarReservoir } from './AlignedHistogramBucketExemplarReservoir';\nexport { SimpleFixedSizeExemplarReservoir } from './SimpleFixedSizeExemplarReservoir';\n"]}