Files
zCode-CLI-X/~/.npm-cache/@opentelemetry/sdk-metrics@2.6.1@@@1/build/esnext/exemplar/ExemplarReservoir.js
admin 875c7f9b91 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
2026-05-05 09:01:26 +00:00

79 lines
2.2 KiB
JavaScript

/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
import { isSpanContextValid, trace } from '@opentelemetry/api';
class ExemplarBucket {
value = 0;
attributes = {};
timestamp = [0, 0];
spanId;
traceId;
_offered = false;
offer(value, timestamp, attributes, ctx) {
this.value = value;
this.timestamp = timestamp;
this.attributes = attributes;
const spanContext = trace.getSpanContext(ctx);
if (spanContext && isSpanContextValid(spanContext)) {
this.spanId = spanContext.spanId;
this.traceId = spanContext.traceId;
}
this._offered = true;
}
collect(pointAttributes) {
if (!this._offered)
return null;
const currentAttributes = this.attributes;
// filter attributes
Object.keys(pointAttributes).forEach(key => {
if (pointAttributes[key] === currentAttributes[key]) {
delete currentAttributes[key];
}
});
const 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;
}
}
export class FixedSizeExemplarReservoirBase {
_reservoirStorage;
_size;
constructor(size) {
this._size = size;
this._reservoirStorage = new Array(size);
for (let i = 0; i < this._size; i++) {
this._reservoirStorage[i] = new ExemplarBucket();
}
}
maxSize() {
return this._size;
}
/**
* Resets the reservoir
*/
reset() { }
collect(pointAttributes) {
const exemplars = [];
this._reservoirStorage.forEach(storageItem => {
const res = storageItem.collect(pointAttributes);
if (res !== null) {
exemplars.push(res);
}
});
this.reset();
return exemplars;
}
}
//# sourceMappingURL=ExemplarReservoir.js.map