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,2 @@
export declare function hexToBinary(hexStr: string): Uint8Array;
//# sourceMappingURL=hex-to-binary.d.ts.map

View File

@@ -0,0 +1,27 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
function intValue(charCode) {
// 0-9
if (charCode >= 48 && charCode <= 57) {
return charCode - 48;
}
// a-f
if (charCode >= 97 && charCode <= 102) {
return charCode - 87;
}
// A-F
return charCode - 55;
}
export function hexToBinary(hexStr) {
const buf = new Uint8Array(hexStr.length / 2);
let offset = 0;
for (let i = 0; i < hexStr.length; i += 2) {
const hi = intValue(hexStr.charCodeAt(i));
const lo = intValue(hexStr.charCodeAt(i + 1));
buf[offset++] = (hi << 4) | lo;
}
return buf;
}
//# sourceMappingURL=hex-to-binary.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hex-to-binary.js","sourceRoot":"","sources":["../../../src/common/hex-to-binary.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,SAAS,QAAQ,CAAC,QAAgB;IAChC,MAAM;IACN,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,EAAE;QACpC,OAAO,QAAQ,GAAG,EAAE,CAAC;KACtB;IAED,MAAM;IACN,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,GAAG,EAAE;QACrC,OAAO,QAAQ,GAAG,EAAE,CAAC;KACtB;IAED,MAAM;IACN,OAAO,QAAQ,GAAG,EAAE,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9C,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACzC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;KAChC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nfunction intValue(charCode: number): number {\n // 0-9\n if (charCode >= 48 && charCode <= 57) {\n return charCode - 48;\n }\n\n // a-f\n if (charCode >= 97 && charCode <= 102) {\n return charCode - 87;\n }\n\n // A-F\n return charCode - 55;\n}\n\nexport function hexToBinary(hexStr: string): Uint8Array {\n const buf = new Uint8Array(hexStr.length / 2);\n let offset = 0;\n\n for (let i = 0; i < hexStr.length; i += 2) {\n const hi = intValue(hexStr.charCodeAt(i));\n const lo = intValue(hexStr.charCodeAt(i + 1));\n buf[offset++] = (hi << 4) | lo;\n }\n\n return buf;\n}\n"]}

View File

@@ -0,0 +1,66 @@
/** Properties of a Resource. */
export interface Resource {
/** Resource attributes */
attributes: IKeyValue[];
/** Resource droppedAttributesCount */
droppedAttributesCount: number;
/** Resource schemaUrl */
schemaUrl?: string;
}
/** Properties of an InstrumentationScope. */
export interface IInstrumentationScope {
/** InstrumentationScope name */
name: string;
/** InstrumentationScope version */
version?: string;
/** InstrumentationScope attributes */
attributes?: IKeyValue[];
/** InstrumentationScope droppedAttributesCount */
droppedAttributesCount?: number;
}
/** Properties of a KeyValue. */
export interface IKeyValue {
/** KeyValue key */
key: string;
/** KeyValue value */
value: IAnyValue;
}
/** Properties of an AnyValue. */
export interface IAnyValue {
/** AnyValue stringValue */
stringValue?: string | null;
/** AnyValue boolValue */
boolValue?: boolean | null;
/** AnyValue intValue */
intValue?: number | null;
/** AnyValue doubleValue */
doubleValue?: number | null;
/** AnyValue arrayValue */
arrayValue?: IArrayValue;
/** AnyValue kvlistValue */
kvlistValue?: IKeyValueList;
/** AnyValue bytesValue */
bytesValue?: Uint8Array | string;
}
/** Properties of an ArrayValue. */
export interface IArrayValue {
/** ArrayValue values */
values: IAnyValue[];
}
/** Properties of a KeyValueList. */
export interface IKeyValueList {
/** KeyValueList values */
values: IKeyValue[];
}
export interface LongBits {
low: number;
high: number;
}
export type Fixed64 = LongBits | string | number;
export interface OtlpEncodingOptions {
/** Convert trace and span IDs to hex strings. */
useHex?: boolean;
/** Convert HrTime to 2 part 64 bit values. */
useLongBits?: boolean;
}
//# sourceMappingURL=internal-types.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=internal-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"internal-types.js","sourceRoot":"","sources":["../../../src/common/internal-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/** Properties of a Resource. */\nexport interface Resource {\n /** Resource attributes */\n attributes: IKeyValue[];\n\n /** Resource droppedAttributesCount */\n droppedAttributesCount: number;\n\n /** Resource schemaUrl */\n schemaUrl?: string;\n}\n\n/** Properties of an InstrumentationScope. */\nexport interface IInstrumentationScope {\n /** InstrumentationScope name */\n name: string;\n\n /** InstrumentationScope version */\n version?: string;\n\n /** InstrumentationScope attributes */\n attributes?: IKeyValue[];\n\n /** InstrumentationScope droppedAttributesCount */\n droppedAttributesCount?: number;\n}\n\n/** Properties of a KeyValue. */\nexport interface IKeyValue {\n /** KeyValue key */\n key: string;\n\n /** KeyValue value */\n value: IAnyValue;\n}\n\n/** Properties of an AnyValue. */\nexport interface IAnyValue {\n /** AnyValue stringValue */\n stringValue?: string | null;\n\n /** AnyValue boolValue */\n boolValue?: boolean | null;\n\n /** AnyValue intValue */\n intValue?: number | null;\n\n /** AnyValue doubleValue */\n doubleValue?: number | null;\n\n /** AnyValue arrayValue */\n arrayValue?: IArrayValue;\n\n /** AnyValue kvlistValue */\n kvlistValue?: IKeyValueList;\n\n /** AnyValue bytesValue */\n bytesValue?: Uint8Array | string;\n}\n\n/** Properties of an ArrayValue. */\nexport interface IArrayValue {\n /** ArrayValue values */\n values: IAnyValue[];\n}\n\n/** Properties of a KeyValueList. */\nexport interface IKeyValueList {\n /** KeyValueList values */\n values: IKeyValue[];\n}\n\nexport interface LongBits {\n low: number;\n high: number;\n}\n\nexport type Fixed64 = LongBits | string | number;\n\nexport interface OtlpEncodingOptions {\n /** Convert trace and span IDs to hex strings. */\n useHex?: boolean;\n /** Convert HrTime to 2 part 64 bit values. */\n useLongBits?: boolean;\n}\n"]}

View File

@@ -0,0 +1,11 @@
import type { IAnyValue, IInstrumentationScope, IKeyValue, Resource } from './internal-types';
import type { Attributes } from '@opentelemetry/api';
import type { InstrumentationScope } from '@opentelemetry/core';
import type { Resource as ISdkResource } from '@opentelemetry/resources';
import type { Encoder } from './utils';
export declare function createResource(resource: ISdkResource, encoder: Encoder): Resource;
export declare function createInstrumentationScope(scope: InstrumentationScope): IInstrumentationScope;
export declare function toAttributes(attributes: Attributes, encoder: Encoder): IKeyValue[];
export declare function toKeyValue(key: string, value: unknown, encoder: Encoder): IKeyValue;
export declare function toAnyValue(value: unknown, encoder: Encoder): IAnyValue;
//# sourceMappingURL=internal.d.ts.map

View File

@@ -0,0 +1,59 @@
export function createResource(resource, encoder) {
const result = {
attributes: toAttributes(resource.attributes, encoder),
droppedAttributesCount: 0,
};
const schemaUrl = resource.schemaUrl;
if (schemaUrl && schemaUrl !== '')
result.schemaUrl = schemaUrl;
return result;
}
export function createInstrumentationScope(scope) {
return {
name: scope.name,
version: scope.version,
};
}
export function toAttributes(attributes, encoder) {
return Object.keys(attributes).map(key => toKeyValue(key, attributes[key], encoder));
}
export function toKeyValue(key, value, encoder) {
return {
key: key,
value: toAnyValue(value, encoder),
};
}
export function toAnyValue(value, encoder) {
const t = typeof value;
if (t === 'string')
return { stringValue: value };
if (t === 'number') {
if (!Number.isInteger(value))
return { doubleValue: value };
return { intValue: value };
}
if (t === 'boolean')
return { boolValue: value };
if (value instanceof Uint8Array)
return { bytesValue: encoder.encodeUint8Array(value) };
if (Array.isArray(value)) {
const values = new Array(value.length);
for (let i = 0; i < value.length; i++) {
values[i] = toAnyValue(value[i], encoder);
}
return { arrayValue: { values } };
}
if (t === 'object' && value != null) {
const keys = Object.keys(value);
const values = new Array(keys.length);
for (let i = 0; i < keys.length; i++) {
values[i] = {
key: keys[i],
value: toAnyValue(value[keys[i]], encoder),
};
}
return { kvlistValue: { values } };
}
return {};
}
//# sourceMappingURL=internal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/common/internal.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,cAAc,CAC5B,QAAsB,EACtB,OAAgB;IAEhB,MAAM,MAAM,GAAa;QACvB,UAAU,EAAE,YAAY,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;QACtD,sBAAsB,EAAE,CAAC;KAC1B,CAAC;IAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;IACrC,IAAI,SAAS,IAAI,SAAS,KAAK,EAAE;QAAE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;IAEhE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAA2B;IAE3B,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,UAAsB,EACtB,OAAgB;IAEhB,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CACvC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAC1C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,GAAW,EACX,KAAc,EACd,OAAgB;IAEhB,OAAO;QACL,GAAG,EAAE,GAAG;QACR,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAc,EAAE,OAAgB;IACzD,MAAM,CAAC,GAAG,OAAO,KAAK,CAAC;IACvB,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,EAAE,WAAW,EAAE,KAAe,EAAE,CAAC;IAC5D,IAAI,CAAC,KAAK,QAAQ,EAAE;QAClB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,WAAW,EAAE,KAAe,EAAE,CAAC;QACtE,OAAO,EAAE,QAAQ,EAAE,KAAe,EAAE,CAAC;KACtC;IACD,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,EAAE,SAAS,EAAE,KAAgB,EAAE,CAAC;IAC5D,IAAI,KAAK,YAAY,UAAU;QAC7B,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;IACzD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,MAAM,MAAM,GAAgB,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC3C;QACD,OAAO,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;KACnC;IACD,IAAI,CAAC,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE;QACnC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,MAAM,GAAgB,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,CAAC,CAAC,CAAC,GAAG;gBACV,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;gBACZ,KAAK,EAAE,UAAU,CAAE,KAAiC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;aACxE,CAAC;SACH;QACD,OAAO,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;KACpC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type {\n IAnyValue,\n IInstrumentationScope,\n IKeyValue,\n Resource,\n} from './internal-types';\nimport type { Attributes } from '@opentelemetry/api';\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport type { Resource as ISdkResource } from '@opentelemetry/resources';\nimport type { Encoder } from './utils';\n\nexport function createResource(\n resource: ISdkResource,\n encoder: Encoder\n): Resource {\n const result: Resource = {\n attributes: toAttributes(resource.attributes, encoder),\n droppedAttributesCount: 0,\n };\n\n const schemaUrl = resource.schemaUrl;\n if (schemaUrl && schemaUrl !== '') result.schemaUrl = schemaUrl;\n\n return result;\n}\n\nexport function createInstrumentationScope(\n scope: InstrumentationScope\n): IInstrumentationScope {\n return {\n name: scope.name,\n version: scope.version,\n };\n}\n\nexport function toAttributes(\n attributes: Attributes,\n encoder: Encoder\n): IKeyValue[] {\n return Object.keys(attributes).map(key =>\n toKeyValue(key, attributes[key], encoder)\n );\n}\n\nexport function toKeyValue(\n key: string,\n value: unknown,\n encoder: Encoder\n): IKeyValue {\n return {\n key: key,\n value: toAnyValue(value, encoder),\n };\n}\n\nexport function toAnyValue(value: unknown, encoder: Encoder): IAnyValue {\n const t = typeof value;\n if (t === 'string') return { stringValue: value as string };\n if (t === 'number') {\n if (!Number.isInteger(value)) return { doubleValue: value as number };\n return { intValue: value as number };\n }\n if (t === 'boolean') return { boolValue: value as boolean };\n if (value instanceof Uint8Array)\n return { bytesValue: encoder.encodeUint8Array(value) };\n if (Array.isArray(value)) {\n const values: IAnyValue[] = new Array(value.length);\n for (let i = 0; i < value.length; i++) {\n values[i] = toAnyValue(value[i], encoder);\n }\n return { arrayValue: { values } };\n }\n if (t === 'object' && value != null) {\n const keys = Object.keys(value);\n const values: IKeyValue[] = new Array(keys.length);\n for (let i = 0; i < keys.length; i++) {\n values[i] = {\n key: keys[i],\n value: toAnyValue((value as Record<string, unknown>)[keys[i]], encoder),\n };\n }\n return { kvlistValue: { values } };\n }\n\n return {};\n}\n"]}

View File

@@ -0,0 +1,8 @@
import type * as protobuf from 'protobufjs';
export interface ExportType<T, R = T & {
toJSON: () => unknown;
}> {
encode(message: T, writer?: protobuf.Writer): protobuf.Writer;
decode(reader: protobuf.Reader | Uint8Array, length?: number): R;
}
//# sourceMappingURL=protobuf-export-type.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=protobuf-export-type.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"protobuf-export-type.js","sourceRoot":"","sources":["../../../../src/common/protobuf/protobuf-export-type.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type * as protobuf from 'protobufjs';\n\nexport interface ExportType<T, R = T & { toJSON: () => unknown }> {\n encode(message: T, writer?: protobuf.Writer): protobuf.Writer;\n decode(reader: protobuf.Reader | Uint8Array, length?: number): R;\n}\n"]}

View File

@@ -0,0 +1,27 @@
import type { Fixed64, LongBits } from './internal-types';
import type { HrTime } from '@opentelemetry/api';
export declare function hrTimeToNanos(hrTime: HrTime): bigint;
export declare function toLongBits(value: bigint): LongBits;
export declare function encodeAsLongBits(hrTime: HrTime): LongBits;
export declare function encodeAsString(hrTime: HrTime): string;
export type HrTimeEncodeFunction = (hrTime: HrTime) => Fixed64;
export type SpanContextEncodeFunction = (spanContext: string) => string | Uint8Array;
export type OptionalSpanContextEncodeFunction = (spanContext: string | undefined) => string | Uint8Array | undefined;
export type Uint8ArrayEncodeFunction = (value: Uint8Array) => string | Uint8Array;
export interface Encoder {
encodeHrTime: HrTimeEncodeFunction;
encodeSpanContext: SpanContextEncodeFunction;
encodeOptionalSpanContext: OptionalSpanContextEncodeFunction;
encodeUint8Array: Uint8ArrayEncodeFunction;
}
/**
* Encoder for protobuf format.
* Uses { high, low } timestamps and binary for span/trace IDs, leaves Uint8Array attributes as-is.
*/
export declare const PROTOBUF_ENCODER: Encoder;
/**
* Encoder for JSON format.
* Uses string timestamps, hex for span/trace IDs, and base64 for Uint8Array.
*/
export declare const JSON_ENCODER: Encoder;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1,64 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
import { hrTimeToNanoseconds } from '@opentelemetry/core';
import { hexToBinary } from './hex-to-binary';
export function hrTimeToNanos(hrTime) {
const NANOSECONDS = BigInt(1000000000);
return (BigInt(Math.trunc(hrTime[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime[1])));
}
export function toLongBits(value) {
const low = Number(BigInt.asUintN(32, value));
const high = Number(BigInt.asUintN(32, value >> BigInt(32)));
return { low, high };
}
export function encodeAsLongBits(hrTime) {
const nanos = hrTimeToNanos(hrTime);
return toLongBits(nanos);
}
export function encodeAsString(hrTime) {
const nanos = hrTimeToNanos(hrTime);
return nanos.toString();
}
const encodeTimestamp = typeof BigInt !== 'undefined' ? encodeAsString : hrTimeToNanoseconds;
function identity(value) {
return value;
}
function optionalHexToBinary(str) {
if (str === undefined)
return undefined;
return hexToBinary(str);
}
/**
* Encoder for protobuf format.
* Uses { high, low } timestamps and binary for span/trace IDs, leaves Uint8Array attributes as-is.
*/
export const PROTOBUF_ENCODER = {
encodeHrTime: encodeAsLongBits,
encodeSpanContext: hexToBinary,
encodeOptionalSpanContext: optionalHexToBinary,
encodeUint8Array: identity,
};
/**
* Encoder for JSON format.
* Uses string timestamps, hex for span/trace IDs, and base64 for Uint8Array.
*/
export const JSON_ENCODER = {
encodeHrTime: encodeTimestamp,
encodeSpanContext: identity,
encodeOptionalSpanContext: identity,
encodeUint8Array: (bytes) => {
if (typeof Buffer !== 'undefined') {
return Buffer.from(bytes).toString('base64');
}
// implementation note: not using spread operator and passing to
// btoa to avoid stack overflow on large Uint8Arrays
const chars = new Array(bytes.length);
for (let i = 0; i < bytes.length; i++) {
chars[i] = String.fromCharCode(bytes[i]);
}
return btoa(chars.join(''));
},
};
//# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
export = $root;
declare var $root: $protobuf.Root;
import $protobuf = require("protobufjs/minimal");
//# sourceMappingURL=root.d.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
/**
* Serializes and deserializes the OTLP request/response to and from {@link Uint8Array}
*/
export interface ISerializer<Request, Response> {
serializeRequest(request: Request): Uint8Array | undefined;
deserializeResponse(data: Uint8Array): Response;
}
//# sourceMappingURL=i-serializer.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=i-serializer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"i-serializer.js","sourceRoot":"","sources":["../../src/i-serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Serializes and deserializes the OTLP request/response to and from {@link Uint8Array}\n */\nexport interface ISerializer<Request, Response> {\n serializeRequest(request: Request): Uint8Array | undefined;\n deserializeResponse(data: Uint8Array): Response;\n}\n"]}

View File

@@ -0,0 +1,11 @@
export type { IExportMetricsPartialSuccess, IExportMetricsServiceResponse, } from './metrics';
export type { IExportTracePartialSuccess, IExportTraceServiceResponse, } from './trace';
export type { IExportLogsServiceResponse, IExportLogsPartialSuccess, } from './logs';
export { ProtobufLogsSerializer } from './logs/protobuf';
export { ProtobufMetricsSerializer } from './metrics/protobuf';
export { ProtobufTraceSerializer } from './trace/protobuf';
export { JsonLogsSerializer } from './logs/json';
export { JsonMetricsSerializer } from './metrics/json';
export { JsonTraceSerializer } from './trace/json';
export type { ISerializer } from './i-serializer';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,11 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export { ProtobufLogsSerializer } from './logs/protobuf';
export { ProtobufMetricsSerializer } from './metrics/protobuf';
export { ProtobufTraceSerializer } from './trace/protobuf';
export { JsonLogsSerializer } from './logs/json';
export { JsonMetricsSerializer } from './metrics/json';
export { JsonTraceSerializer } from './trace/json';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport type {\n IExportMetricsPartialSuccess,\n IExportMetricsServiceResponse,\n} from './metrics';\nexport type {\n IExportTracePartialSuccess,\n IExportTraceServiceResponse,\n} from './trace';\nexport type {\n IExportLogsServiceResponse,\n IExportLogsPartialSuccess,\n} from './logs';\n\nexport { ProtobufLogsSerializer } from './logs/protobuf';\nexport { ProtobufMetricsSerializer } from './metrics/protobuf';\nexport { ProtobufTraceSerializer } from './trace/protobuf';\n\nexport { JsonLogsSerializer } from './logs/json';\nexport { JsonMetricsSerializer } from './metrics/json';\nexport { JsonTraceSerializer } from './trace/json';\n\nexport type { ISerializer } from './i-serializer';\n"]}

View File

@@ -0,0 +1,11 @@
export interface IExportMetricsServiceResponse {
/** ExportMetricsServiceResponse partialSuccess */
partialSuccess?: IExportMetricsPartialSuccess;
}
export interface IExportMetricsPartialSuccess {
/** ExportMetricsPartialSuccess rejectedDataPoints */
rejectedDataPoints?: number;
/** ExportMetricsPartialSuccess errorMessage */
errorMessage?: string;
}
//# sourceMappingURL=export-response.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=export-response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"export-response.js","sourceRoot":"","sources":["../../../src/metrics/export-response.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport interface IExportMetricsServiceResponse {\n /** ExportMetricsServiceResponse partialSuccess */\n partialSuccess?: IExportMetricsPartialSuccess;\n}\n\nexport interface IExportMetricsPartialSuccess {\n /** ExportMetricsPartialSuccess rejectedDataPoints */\n rejectedDataPoints?: number;\n\n /** ExportMetricsPartialSuccess errorMessage */\n errorMessage?: string;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export type { IExportMetricsPartialSuccess, IExportMetricsServiceResponse, } from './export-response';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// IMPORTANT: exports added here are public\nexport type {\n IExportMetricsPartialSuccess,\n IExportMetricsServiceResponse,\n} from './export-response';\n"]}

View File

@@ -0,0 +1,263 @@
import type { Fixed64, IInstrumentationScope, IKeyValue, Resource } from '../common/internal-types';
/** Properties of an ExportMetricsServiceRequest. */
export interface IExportMetricsServiceRequest {
/** ExportMetricsServiceRequest resourceMetrics */
resourceMetrics: IResourceMetrics[];
}
/** Properties of a ResourceMetrics. */
export interface IResourceMetrics {
/** ResourceMetrics resource */
resource?: Resource;
/** ResourceMetrics scopeMetrics */
scopeMetrics: IScopeMetrics[];
/** ResourceMetrics schemaUrl */
schemaUrl?: string;
}
/** Properties of an IScopeMetrics. */
export interface IScopeMetrics {
/** ScopeMetrics scope */
scope?: IInstrumentationScope;
/** ScopeMetrics metrics */
metrics: IMetric[];
/** ScopeMetrics schemaUrl */
schemaUrl?: string;
}
/** Properties of a Metric. */
export interface IMetric {
/** Metric name */
name: string;
/** Metric description */
description?: string;
/** Metric unit */
unit?: string;
/** Metric gauge */
gauge?: IGauge;
/** Metric sum */
sum?: ISum;
/** Metric histogram */
histogram?: IHistogram;
/** Metric exponentialHistogram */
exponentialHistogram?: IExponentialHistogram;
/** Metric summary */
summary?: ISummary;
}
/** Properties of a Gauge. */
export interface IGauge {
/** Gauge dataPoints */
dataPoints: INumberDataPoint[];
}
/** Properties of a Sum. */
export interface ISum {
/** Sum dataPoints */
dataPoints: INumberDataPoint[];
/** Sum aggregationTemporality */
aggregationTemporality: EAggregationTemporality;
/** Sum isMonotonic */
isMonotonic?: boolean | null;
}
/** Properties of a Histogram. */
export interface IHistogram {
/** Histogram dataPoints */
dataPoints: IHistogramDataPoint[];
/** Histogram aggregationTemporality */
aggregationTemporality?: EAggregationTemporality;
}
/** Properties of an ExponentialHistogram. */
export interface IExponentialHistogram {
/** ExponentialHistogram dataPoints */
dataPoints: IExponentialHistogramDataPoint[];
/** ExponentialHistogram aggregationTemporality */
aggregationTemporality?: EAggregationTemporality;
}
/** Properties of a Summary. */
export interface ISummary {
/** Summary dataPoints */
dataPoints: ISummaryDataPoint[];
}
/** Properties of a NumberDataPoint. */
export interface INumberDataPoint {
/** NumberDataPoint attributes */
attributes: IKeyValue[];
/** NumberDataPoint startTimeUnixNano */
startTimeUnixNano?: Fixed64;
/** NumberDataPoint timeUnixNano */
timeUnixNano?: Fixed64;
/** NumberDataPoint asDouble */
asDouble?: number | null;
/** NumberDataPoint asInt */
asInt?: number;
/** NumberDataPoint exemplars */
exemplars?: IExemplar[];
/** NumberDataPoint flags */
flags?: number;
}
/** Properties of a HistogramDataPoint. */
export interface IHistogramDataPoint {
/** HistogramDataPoint attributes */
attributes?: IKeyValue[];
/** HistogramDataPoint startTimeUnixNano */
startTimeUnixNano?: Fixed64;
/** HistogramDataPoint timeUnixNano */
timeUnixNano?: Fixed64;
/** HistogramDataPoint count */
count?: number;
/** HistogramDataPoint sum */
sum?: number;
/** HistogramDataPoint bucketCounts */
bucketCounts?: number[];
/** HistogramDataPoint explicitBounds */
explicitBounds?: number[];
/** HistogramDataPoint exemplars */
exemplars?: IExemplar[];
/** HistogramDataPoint flags */
flags?: number;
/** HistogramDataPoint min */
min?: number;
/** HistogramDataPoint max */
max?: number;
}
/** Properties of an ExponentialHistogramDataPoint. */
export interface IExponentialHistogramDataPoint {
/** ExponentialHistogramDataPoint attributes */
attributes?: IKeyValue[];
/** ExponentialHistogramDataPoint startTimeUnixNano */
startTimeUnixNano?: Fixed64;
/** ExponentialHistogramDataPoint timeUnixNano */
timeUnixNano?: Fixed64;
/** ExponentialHistogramDataPoint count */
count?: number;
/** ExponentialHistogramDataPoint sum */
sum?: number;
/** ExponentialHistogramDataPoint scale */
scale?: number;
/** ExponentialHistogramDataPoint zeroCount */
zeroCount?: number;
/** ExponentialHistogramDataPoint positive */
positive?: IBuckets;
/** ExponentialHistogramDataPoint negative */
negative?: IBuckets;
/** ExponentialHistogramDataPoint flags */
flags?: number;
/** ExponentialHistogramDataPoint exemplars */
exemplars?: IExemplar[];
/** ExponentialHistogramDataPoint min */
min?: number;
/** ExponentialHistogramDataPoint max */
max?: number;
}
/** Properties of a SummaryDataPoint. */
export interface ISummaryDataPoint {
/** SummaryDataPoint attributes */
attributes?: IKeyValue[];
/** SummaryDataPoint startTimeUnixNano */
startTimeUnixNano?: number;
/** SummaryDataPoint timeUnixNano */
timeUnixNano?: string;
/** SummaryDataPoint count */
count?: number;
/** SummaryDataPoint sum */
sum?: number;
/** SummaryDataPoint quantileValues */
quantileValues?: IValueAtQuantile[];
/** SummaryDataPoint flags */
flags?: number;
}
/** Properties of a ValueAtQuantile. */
export interface IValueAtQuantile {
/** ValueAtQuantile quantile */
quantile?: number;
/** ValueAtQuantile value */
value?: number;
}
/** Properties of a Buckets. */
export interface IBuckets {
/** Buckets offset */
offset?: number;
/** Buckets bucketCounts */
bucketCounts?: number[];
}
/** Properties of an Exemplar. */
export interface IExemplar {
/** Exemplar filteredAttributes */
filteredAttributes?: IKeyValue[];
/** Exemplar timeUnixNano */
timeUnixNano?: string;
/** Exemplar asDouble */
asDouble?: number;
/** Exemplar asInt */
asInt?: number;
/** Exemplar spanId */
spanId?: string | Uint8Array;
/** Exemplar traceId */
traceId?: string | Uint8Array;
}
/**
* AggregationTemporality defines how a metric aggregator reports aggregated
* values. It describes how those values relate to the time interval over
* which they are aggregated.
*/
export declare const enum EAggregationTemporality {
AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,
/** DELTA is an AggregationTemporality for a metric aggregator which reports
changes since last report time. Successive metrics contain aggregation of
values from continuous and non-overlapping intervals.
The values for a DELTA metric are based only on the time interval
associated with one measurement cycle. There is no dependency on
previous measurements like is the case for CUMULATIVE metrics.
For example, consider a system measuring the number of requests that
it receives and reports the sum of these requests every second as a
DELTA metric:
1. The system starts receiving at time=t_0.
2. A request is received, the system measures 1 request.
3. A request is received, the system measures 1 request.
4. A request is received, the system measures 1 request.
5. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0 to
t_0+1 with a value of 3.
6. A request is received, the system measures 1 request.
7. A request is received, the system measures 1 request.
8. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0+1 to
t_0+2 with a value of 2. */
AGGREGATION_TEMPORALITY_DELTA = 1,
/** CUMULATIVE is an AggregationTemporality for a metric aggregator which
reports changes since a fixed start time. This means that current values
of a CUMULATIVE metric depend on all previous measurements since the
start time. Because of this, the sender is required to retain this state
in some form. If this state is lost or invalidated, the CUMULATIVE metric
values MUST be reset and a new fixed start time following the last
reported measurement time sent MUST be used.
For example, consider a system measuring the number of requests that
it receives and reports the sum of these requests every second as a
CUMULATIVE metric:
1. The system starts receiving at time=t_0.
2. A request is received, the system measures 1 request.
3. A request is received, the system measures 1 request.
4. A request is received, the system measures 1 request.
5. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0 to
t_0+1 with a value of 3.
6. A request is received, the system measures 1 request.
7. A request is received, the system measures 1 request.
8. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0 to
t_0+2 with a value of 5.
9. The system experiences a fault and loses state.
10. The system recovers and resumes receiving at time=t_1.
11. A request is received, the system measures 1 request.
12. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_1 to
t_0+1 with a value of 1.
Note: Even though, when reporting changes since last report time, using
CUMULATIVE is valid, it is not recommended. This may cause problems for
systems that do not use start_time to determine when the aggregation
value was reset (e.g. Prometheus). */
AGGREGATION_TEMPORALITY_CUMULATIVE = 2
}
//# sourceMappingURL=internal-types.d.ts.map

View File

@@ -0,0 +1,72 @@
/**
* AggregationTemporality defines how a metric aggregator reports aggregated
* values. It describes how those values relate to the time interval over
* which they are aggregated.
*/
export var EAggregationTemporality;
(function (EAggregationTemporality) {
/* UNSPECIFIED is the default AggregationTemporality, it MUST not be used. */
EAggregationTemporality[EAggregationTemporality["AGGREGATION_TEMPORALITY_UNSPECIFIED"] = 0] = "AGGREGATION_TEMPORALITY_UNSPECIFIED";
/** DELTA is an AggregationTemporality for a metric aggregator which reports
changes since last report time. Successive metrics contain aggregation of
values from continuous and non-overlapping intervals.
The values for a DELTA metric are based only on the time interval
associated with one measurement cycle. There is no dependency on
previous measurements like is the case for CUMULATIVE metrics.
For example, consider a system measuring the number of requests that
it receives and reports the sum of these requests every second as a
DELTA metric:
1. The system starts receiving at time=t_0.
2. A request is received, the system measures 1 request.
3. A request is received, the system measures 1 request.
4. A request is received, the system measures 1 request.
5. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0 to
t_0+1 with a value of 3.
6. A request is received, the system measures 1 request.
7. A request is received, the system measures 1 request.
8. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0+1 to
t_0+2 with a value of 2. */
EAggregationTemporality[EAggregationTemporality["AGGREGATION_TEMPORALITY_DELTA"] = 1] = "AGGREGATION_TEMPORALITY_DELTA";
/** CUMULATIVE is an AggregationTemporality for a metric aggregator which
reports changes since a fixed start time. This means that current values
of a CUMULATIVE metric depend on all previous measurements since the
start time. Because of this, the sender is required to retain this state
in some form. If this state is lost or invalidated, the CUMULATIVE metric
values MUST be reset and a new fixed start time following the last
reported measurement time sent MUST be used.
For example, consider a system measuring the number of requests that
it receives and reports the sum of these requests every second as a
CUMULATIVE metric:
1. The system starts receiving at time=t_0.
2. A request is received, the system measures 1 request.
3. A request is received, the system measures 1 request.
4. A request is received, the system measures 1 request.
5. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0 to
t_0+1 with a value of 3.
6. A request is received, the system measures 1 request.
7. A request is received, the system measures 1 request.
8. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_0 to
t_0+2 with a value of 5.
9. The system experiences a fault and loses state.
10. The system recovers and resumes receiving at time=t_1.
11. A request is received, the system measures 1 request.
12. The 1 second collection cycle ends. A metric is exported for the
number of requests received over the interval of time t_1 to
t_0+1 with a value of 1.
Note: Even though, when reporting changes since last report time, using
CUMULATIVE is valid, it is not recommended. This may cause problems for
systems that do not use start_time to determine when the aggregation
value was reset (e.g. Prometheus). */
EAggregationTemporality[EAggregationTemporality["AGGREGATION_TEMPORALITY_CUMULATIVE"] = 2] = "AGGREGATION_TEMPORALITY_CUMULATIVE";
})(EAggregationTemporality || (EAggregationTemporality = {}));
//# sourceMappingURL=internal-types.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
import type { MetricData, ResourceMetrics, ScopeMetrics } from '@opentelemetry/sdk-metrics';
import type { IExportMetricsServiceRequest, IMetric, IResourceMetrics, IScopeMetrics } from './internal-types';
import type { Encoder } from '../common/utils';
export declare function toResourceMetrics(resourceMetrics: ResourceMetrics, encoder: Encoder): IResourceMetrics;
export declare function toScopeMetrics(scopeMetrics: ScopeMetrics[], encoder: Encoder): IScopeMetrics[];
export declare function toMetric(metricData: MetricData, encoder: Encoder): IMetric;
export declare function createExportMetricsServiceRequest(resourceMetrics: ResourceMetrics[], encoder: Encoder): IExportMetricsServiceRequest;
//# sourceMappingURL=internal.d.ts.map

View File

@@ -0,0 +1,133 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
import { ValueType } from '@opentelemetry/api';
import { AggregationTemporality, DataPointType, } from '@opentelemetry/sdk-metrics';
import { EAggregationTemporality } from './internal-types';
import { createInstrumentationScope, createResource, toAttributes, } from '../common/internal';
export function toResourceMetrics(resourceMetrics, encoder) {
const processedResource = createResource(resourceMetrics.resource, encoder);
return {
resource: processedResource,
schemaUrl: processedResource.schemaUrl,
scopeMetrics: toScopeMetrics(resourceMetrics.scopeMetrics, encoder),
};
}
export function toScopeMetrics(scopeMetrics, encoder) {
return Array.from(scopeMetrics.map(metrics => ({
scope: createInstrumentationScope(metrics.scope),
metrics: metrics.metrics.map(metricData => toMetric(metricData, encoder)),
schemaUrl: metrics.scope.schemaUrl,
})));
}
export function toMetric(metricData, encoder) {
const out = {
name: metricData.descriptor.name,
description: metricData.descriptor.description,
unit: metricData.descriptor.unit,
};
const aggregationTemporality = toAggregationTemporality(metricData.aggregationTemporality);
switch (metricData.dataPointType) {
case DataPointType.SUM:
out.sum = {
aggregationTemporality,
isMonotonic: metricData.isMonotonic,
dataPoints: toSingularDataPoints(metricData, encoder),
};
break;
case DataPointType.GAUGE:
out.gauge = {
dataPoints: toSingularDataPoints(metricData, encoder),
};
break;
case DataPointType.HISTOGRAM:
out.histogram = {
aggregationTemporality,
dataPoints: toHistogramDataPoints(metricData, encoder),
};
break;
case DataPointType.EXPONENTIAL_HISTOGRAM:
out.exponentialHistogram = {
aggregationTemporality,
dataPoints: toExponentialHistogramDataPoints(metricData, encoder),
};
break;
}
return out;
}
function toSingularDataPoint(dataPoint, valueType, encoder) {
const out = {
attributes: toAttributes(dataPoint.attributes, encoder),
startTimeUnixNano: encoder.encodeHrTime(dataPoint.startTime),
timeUnixNano: encoder.encodeHrTime(dataPoint.endTime),
};
switch (valueType) {
case ValueType.INT:
out.asInt = dataPoint.value;
break;
case ValueType.DOUBLE:
out.asDouble = dataPoint.value;
break;
}
return out;
}
function toSingularDataPoints(metricData, encoder) {
return metricData.dataPoints.map(dataPoint => {
return toSingularDataPoint(dataPoint, metricData.descriptor.valueType, encoder);
});
}
function toHistogramDataPoints(metricData, encoder) {
return metricData.dataPoints.map(dataPoint => {
const histogram = dataPoint.value;
return {
attributes: toAttributes(dataPoint.attributes, encoder),
bucketCounts: histogram.buckets.counts,
explicitBounds: histogram.buckets.boundaries,
count: histogram.count,
sum: histogram.sum,
min: histogram.min,
max: histogram.max,
startTimeUnixNano: encoder.encodeHrTime(dataPoint.startTime),
timeUnixNano: encoder.encodeHrTime(dataPoint.endTime),
};
});
}
function toExponentialHistogramDataPoints(metricData, encoder) {
return metricData.dataPoints.map(dataPoint => {
const histogram = dataPoint.value;
return {
attributes: toAttributes(dataPoint.attributes, encoder),
count: histogram.count,
min: histogram.min,
max: histogram.max,
sum: histogram.sum,
positive: {
offset: histogram.positive.offset,
bucketCounts: histogram.positive.bucketCounts,
},
negative: {
offset: histogram.negative.offset,
bucketCounts: histogram.negative.bucketCounts,
},
scale: histogram.scale,
zeroCount: histogram.zeroCount,
startTimeUnixNano: encoder.encodeHrTime(dataPoint.startTime),
timeUnixNano: encoder.encodeHrTime(dataPoint.endTime),
};
});
}
function toAggregationTemporality(temporality) {
switch (temporality) {
case AggregationTemporality.DELTA:
return EAggregationTemporality.AGGREGATION_TEMPORALITY_DELTA;
case AggregationTemporality.CUMULATIVE:
return EAggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE;
}
}
export function createExportMetricsServiceRequest(resourceMetrics, encoder) {
return {
resourceMetrics: resourceMetrics.map(metrics => toResourceMetrics(metrics, encoder)),
};
}
//# sourceMappingURL=internal.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export { JsonMetricsSerializer } from './metrics';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,7 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: exports added here are public
export { JsonMetricsSerializer } from './metrics';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/metrics/json/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2CAA2C;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// IMPORTANT: exports added here are public\nexport { JsonMetricsSerializer } from './metrics';\n"]}

View File

@@ -0,0 +1,5 @@
import type { ISerializer } from '../../i-serializer';
import type { ResourceMetrics } from '@opentelemetry/sdk-metrics';
import type { IExportMetricsServiceResponse } from '../export-response';
export declare const JsonMetricsSerializer: ISerializer<ResourceMetrics, IExportMetricsServiceResponse>;
//# sourceMappingURL=metrics.d.ts.map

View File

@@ -0,0 +1,17 @@
import { createExportMetricsServiceRequest } from '../internal';
import { JSON_ENCODER } from '../../common/utils';
export const JsonMetricsSerializer = {
serializeRequest: (arg) => {
const request = createExportMetricsServiceRequest([arg], JSON_ENCODER);
const encoder = new TextEncoder();
return encoder.encode(JSON.stringify(request));
},
deserializeResponse: (arg) => {
if (arg.length === 0) {
return {};
}
const decoder = new TextDecoder();
return JSON.parse(decoder.decode(arg));
},
};
//# sourceMappingURL=metrics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../src/metrics/json/metrics.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,qBAAqB,GAG9B;IACF,gBAAgB,EAAE,CAAC,GAAoB,EAAE,EAAE;QACzC,MAAM,OAAO,GAAG,iCAAiC,CAAC,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,mBAAmB,EAAE,CAAC,GAAe,EAAE,EAAE;QACvC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAO,EAAE,CAAC;SACX;QACD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAkC,CAAC;IAC1E,CAAC;CACF,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { ISerializer } from '../../i-serializer';\nimport type { ResourceMetrics } from '@opentelemetry/sdk-metrics';\nimport { createExportMetricsServiceRequest } from '../internal';\nimport type { IExportMetricsServiceResponse } from '../export-response';\nimport { JSON_ENCODER } from '../../common/utils';\n\nexport const JsonMetricsSerializer: ISerializer<\n ResourceMetrics,\n IExportMetricsServiceResponse\n> = {\n serializeRequest: (arg: ResourceMetrics) => {\n const request = createExportMetricsServiceRequest([arg], JSON_ENCODER);\n const encoder = new TextEncoder();\n return encoder.encode(JSON.stringify(request));\n },\n deserializeResponse: (arg: Uint8Array) => {\n if (arg.length === 0) {\n return {};\n }\n const decoder = new TextDecoder();\n return JSON.parse(decoder.decode(arg)) as IExportMetricsServiceResponse;\n },\n};\n"]}

View File

@@ -0,0 +1,2 @@
export { ProtobufMetricsSerializer } from './metrics';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,7 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: exports added here are public
export { ProtobufMetricsSerializer } from './metrics';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/metrics/protobuf/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2CAA2C;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// IMPORTANT: exports added here are public\nexport { ProtobufMetricsSerializer } from './metrics';\n"]}

View File

@@ -0,0 +1,5 @@
import type { ISerializer } from '../../i-serializer';
import type { ResourceMetrics } from '@opentelemetry/sdk-metrics';
import type { IExportMetricsServiceResponse } from '../export-response';
export declare const ProtobufMetricsSerializer: ISerializer<ResourceMetrics, IExportMetricsServiceResponse>;
//# sourceMappingURL=metrics.d.ts.map

View File

@@ -0,0 +1,21 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
import * as root from '../../generated/root';
import { createExportMetricsServiceRequest } from '../internal';
import { PROTOBUF_ENCODER } from '../../common/utils';
const metricsResponseType = root.opentelemetry.proto.collector.metrics.v1
.ExportMetricsServiceResponse;
const metricsRequestType = root.opentelemetry.proto.collector.metrics.v1
.ExportMetricsServiceRequest;
export const ProtobufMetricsSerializer = {
serializeRequest: (arg) => {
const request = createExportMetricsServiceRequest([arg], PROTOBUF_ENCODER);
return metricsRequestType.encode(request).finish();
},
deserializeResponse: (arg) => {
return metricsResponseType.decode(arg);
},
};
//# sourceMappingURL=metrics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../src/metrics/protobuf/metrics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAI7C,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;KACtE,4BAAyE,CAAC;AAE7E,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;KACrE,2BAAuE,CAAC;AAE3E,MAAM,CAAC,MAAM,yBAAyB,GAGlC;IACF,gBAAgB,EAAE,CAAC,GAAoB,EAAE,EAAE;QACzC,MAAM,OAAO,GAAG,iCAAiC,CAAC,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC,CAAC;QAC3E,OAAO,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IACrD,CAAC;IACD,mBAAmB,EAAE,CAAC,GAAe,EAAE,EAAE;QACvC,OAAO,mBAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;CACF,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport * as root from '../../generated/root';\nimport type { ISerializer } from '../../i-serializer';\nimport type { IExportMetricsServiceRequest } from '../internal-types';\nimport type { ExportType } from '../../common/protobuf/protobuf-export-type';\nimport { createExportMetricsServiceRequest } from '../internal';\nimport type { ResourceMetrics } from '@opentelemetry/sdk-metrics';\nimport type { IExportMetricsServiceResponse } from '../export-response';\nimport { PROTOBUF_ENCODER } from '../../common/utils';\n\nconst metricsResponseType = root.opentelemetry.proto.collector.metrics.v1\n .ExportMetricsServiceResponse as ExportType<IExportMetricsServiceResponse>;\n\nconst metricsRequestType = root.opentelemetry.proto.collector.metrics.v1\n .ExportMetricsServiceRequest as ExportType<IExportMetricsServiceRequest>;\n\nexport const ProtobufMetricsSerializer: ISerializer<\n ResourceMetrics,\n IExportMetricsServiceResponse\n> = {\n serializeRequest: (arg: ResourceMetrics) => {\n const request = createExportMetricsServiceRequest([arg], PROTOBUF_ENCODER);\n return metricsRequestType.encode(request).finish();\n },\n deserializeResponse: (arg: Uint8Array) => {\n return metricsResponseType.decode(arg);\n },\n};\n"]}

View File

@@ -0,0 +1,11 @@
export interface IExportTraceServiceResponse {
/** ExportTraceServiceResponse partialSuccess */
partialSuccess?: IExportTracePartialSuccess;
}
export interface IExportTracePartialSuccess {
/** ExportLogsServiceResponse rejectedLogRecords */
rejectedSpans?: number;
/** ExportLogsServiceResponse errorMessage */
errorMessage?: string;
}
//# sourceMappingURL=export-response.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=export-response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"export-response.js","sourceRoot":"","sources":["../../../src/trace/export-response.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport interface IExportTraceServiceResponse {\n /** ExportTraceServiceResponse partialSuccess */\n partialSuccess?: IExportTracePartialSuccess;\n}\n\nexport interface IExportTracePartialSuccess {\n /** ExportLogsServiceResponse rejectedLogRecords */\n rejectedSpans?: number;\n\n /** ExportLogsServiceResponse errorMessage */\n errorMessage?: string;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export type { IExportTracePartialSuccess, IExportTraceServiceResponse, } from './export-response';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trace/index.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// IMPORTANT: exports added here are public\nexport type {\n IExportTracePartialSuccess,\n IExportTraceServiceResponse,\n} from './export-response';\n"]}

View File

@@ -0,0 +1,132 @@
import type { Fixed64, IInstrumentationScope, IKeyValue, Resource } from '../common/internal-types';
/** Properties of an ExportTraceServiceRequest. */
export interface IExportTraceServiceRequest {
/** ExportTraceServiceRequest resourceSpans */
resourceSpans?: IResourceSpans[];
}
/** Properties of a ResourceSpans. */
export interface IResourceSpans {
/** ResourceSpans resource */
resource?: Resource;
/** ResourceSpans scopeSpans */
scopeSpans: IScopeSpans[];
/** ResourceSpans schemaUrl */
schemaUrl?: string;
}
/** Properties of an ScopeSpans. */
export interface IScopeSpans {
/** IScopeSpans scope */
scope?: IInstrumentationScope;
/** IScopeSpans spans */
spans?: ISpan[];
/** IScopeSpans schemaUrl */
schemaUrl?: string | null;
}
/** Properties of a Span. */
export interface ISpan {
/** Span traceId */
traceId: string | Uint8Array;
/** Span spanId */
spanId: string | Uint8Array;
/** Span traceState */
traceState?: string | null;
/** Span parentSpanId */
parentSpanId?: string | Uint8Array;
/** Span name */
name: string;
/** Span kind */
kind: ESpanKind;
/** Span startTimeUnixNano */
startTimeUnixNano: Fixed64;
/** Span endTimeUnixNano */
endTimeUnixNano: Fixed64;
/** Span attributes */
attributes: IKeyValue[];
/** Span droppedAttributesCount */
droppedAttributesCount: number;
/** Span events */
events: IEvent[];
/** Span droppedEventsCount */
droppedEventsCount: number;
/** Span links */
links: ILink[];
/** Span droppedLinksCount */
droppedLinksCount: number;
/** Span status */
status: IStatus;
/** Span flags */
flags?: number;
}
/**
* SpanKind is the type of span. Can be used to specify additional relationships between spans
* in addition to a parent/child relationship.
*/
export declare enum ESpanKind {
/** Unspecified. Do NOT use as default. Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED. */
SPAN_KIND_UNSPECIFIED = 0,
/** Indicates that the span represents an internal operation within an application,
* as opposed to an operation happening at the boundaries. Default value.
*/
SPAN_KIND_INTERNAL = 1,
/** Indicates that the span covers server-side handling of an RPC or other
* remote network request.
*/
SPAN_KIND_SERVER = 2,
/** Indicates that the span describes a request to some remote service.
*/
SPAN_KIND_CLIENT = 3,
/** Indicates that the span describes a producer sending a message to a broker.
* Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
* between producer and consumer spans. A PRODUCER span ends when the message was accepted
* by the broker while the logical processing of the message might span a much longer time.
*/
SPAN_KIND_PRODUCER = 4,
/** Indicates that the span describes consumer receiving a message from a broker.
* Like the PRODUCER kind, there is often no direct critical path latency relationship
* between producer and consumer spans.
*/
SPAN_KIND_CONSUMER = 5
}
/** Properties of a Status. */
export interface IStatus {
/** Status message */
message?: string;
/** Status code */
code: EStatusCode;
}
/** StatusCode enum. */
export declare const enum EStatusCode {
/** The default status. */
STATUS_CODE_UNSET = 0,
/** The Span has been evaluated by an Application developers or Operator to have completed successfully. */
STATUS_CODE_OK = 1,
/** The Span contains an error. */
STATUS_CODE_ERROR = 2
}
/** Properties of an Event. */
export interface IEvent {
/** Event timeUnixNano */
timeUnixNano: Fixed64;
/** Event name */
name: string;
/** Event attributes */
attributes: IKeyValue[];
/** Event droppedAttributesCount */
droppedAttributesCount: number;
}
/** Properties of a Link. */
export interface ILink {
/** Link traceId */
traceId: string | Uint8Array;
/** Link spanId */
spanId: string | Uint8Array;
/** Link traceState */
traceState?: string;
/** Link attributes */
attributes: IKeyValue[];
/** Link droppedAttributesCount */
droppedAttributesCount: number;
/** Link flags */
flags?: number;
}
//# sourceMappingURL=internal-types.d.ts.map

View File

@@ -0,0 +1,46 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
/**
* SpanKind is the type of span. Can be used to specify additional relationships between spans
* in addition to a parent/child relationship.
*/
export var ESpanKind;
(function (ESpanKind) {
/** Unspecified. Do NOT use as default. Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED. */
ESpanKind[ESpanKind["SPAN_KIND_UNSPECIFIED"] = 0] = "SPAN_KIND_UNSPECIFIED";
/** Indicates that the span represents an internal operation within an application,
* as opposed to an operation happening at the boundaries. Default value.
*/
ESpanKind[ESpanKind["SPAN_KIND_INTERNAL"] = 1] = "SPAN_KIND_INTERNAL";
/** Indicates that the span covers server-side handling of an RPC or other
* remote network request.
*/
ESpanKind[ESpanKind["SPAN_KIND_SERVER"] = 2] = "SPAN_KIND_SERVER";
/** Indicates that the span describes a request to some remote service.
*/
ESpanKind[ESpanKind["SPAN_KIND_CLIENT"] = 3] = "SPAN_KIND_CLIENT";
/** Indicates that the span describes a producer sending a message to a broker.
* Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
* between producer and consumer spans. A PRODUCER span ends when the message was accepted
* by the broker while the logical processing of the message might span a much longer time.
*/
ESpanKind[ESpanKind["SPAN_KIND_PRODUCER"] = 4] = "SPAN_KIND_PRODUCER";
/** Indicates that the span describes consumer receiving a message from a broker.
* Like the PRODUCER kind, there is often no direct critical path latency relationship
* between producer and consumer spans.
*/
ESpanKind[ESpanKind["SPAN_KIND_CONSUMER"] = 5] = "SPAN_KIND_CONSUMER";
})(ESpanKind || (ESpanKind = {}));
/** StatusCode enum. */
export var EStatusCode;
(function (EStatusCode) {
/** The default status. */
EStatusCode[EStatusCode["STATUS_CODE_UNSET"] = 0] = "STATUS_CODE_UNSET";
/** The Span has been evaluated by an Application developers or Operator to have completed successfully. */
EStatusCode[EStatusCode["STATUS_CODE_OK"] = 1] = "STATUS_CODE_OK";
/** The Span contains an error. */
EStatusCode[EStatusCode["STATUS_CODE_ERROR"] = 2] = "STATUS_CODE_ERROR";
})(EStatusCode || (EStatusCode = {}));
//# sourceMappingURL=internal-types.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { Link } from '@opentelemetry/api';
import type { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';
import type { Encoder } from '../common/utils';
import type { IEvent, IExportTraceServiceRequest, ILink, ISpan } from './internal-types';
export declare function sdkSpanToOtlpSpan(span: ReadableSpan, encoder: Encoder): ISpan;
export declare function toOtlpLink(link: Link, encoder: Encoder): ILink;
export declare function toOtlpSpanEvent(timedEvent: TimedEvent, encoder: Encoder): IEvent;
export declare function createExportTraceServiceRequest(spans: ReadableSpan[], encoder: Encoder): IExportTraceServiceRequest;
//# sourceMappingURL=internal.d.ts.map

View File

@@ -0,0 +1,124 @@
import { createInstrumentationScope, createResource, toAttributes, } from '../common/internal';
// Span flags constants matching the OTLP specification
const SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 0x100;
const SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 0x200;
/**
* Builds the 32-bit span flags value combining the low 8-bit W3C TraceFlags
* with the HAS_IS_REMOTE and IS_REMOTE bits according to the OTLP spec.
*/
function buildSpanFlagsFrom(traceFlags, isRemote) {
// low 8 bits are W3C TraceFlags (e.g., sampled)
let flags = (traceFlags & 0xff) | SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK;
if (isRemote) {
flags |= SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK;
}
return flags;
}
export function sdkSpanToOtlpSpan(span, encoder) {
const ctx = span.spanContext();
const status = span.status;
const parentSpanId = span.parentSpanContext?.spanId
? encoder.encodeSpanContext(span.parentSpanContext?.spanId)
: undefined;
return {
traceId: encoder.encodeSpanContext(ctx.traceId),
spanId: encoder.encodeSpanContext(ctx.spanId),
parentSpanId: parentSpanId,
traceState: ctx.traceState?.serialize(),
name: span.name,
// Span kind is offset by 1 because the API does not define a value for unset
kind: span.kind == null ? 0 : span.kind + 1,
startTimeUnixNano: encoder.encodeHrTime(span.startTime),
endTimeUnixNano: encoder.encodeHrTime(span.endTime),
attributes: toAttributes(span.attributes, encoder),
droppedAttributesCount: span.droppedAttributesCount,
events: span.events.map(event => toOtlpSpanEvent(event, encoder)),
droppedEventsCount: span.droppedEventsCount,
status: {
// API and proto enums share the same values
code: status.code,
message: status.message,
},
links: span.links.map(link => toOtlpLink(link, encoder)),
droppedLinksCount: span.droppedLinksCount,
flags: buildSpanFlagsFrom(ctx.traceFlags, span.parentSpanContext?.isRemote),
};
}
export function toOtlpLink(link, encoder) {
return {
attributes: link.attributes ? toAttributes(link.attributes, encoder) : [],
spanId: encoder.encodeSpanContext(link.context.spanId),
traceId: encoder.encodeSpanContext(link.context.traceId),
traceState: link.context.traceState?.serialize(),
droppedAttributesCount: link.droppedAttributesCount || 0,
flags: buildSpanFlagsFrom(link.context.traceFlags, link.context.isRemote),
};
}
export function toOtlpSpanEvent(timedEvent, encoder) {
return {
attributes: timedEvent.attributes
? toAttributes(timedEvent.attributes, encoder)
: [],
name: timedEvent.name,
timeUnixNano: encoder.encodeHrTime(timedEvent.time),
droppedAttributesCount: timedEvent.droppedAttributesCount || 0,
};
}
export function createExportTraceServiceRequest(spans, encoder) {
return {
resourceSpans: spanRecordsToResourceSpans(spans, encoder),
};
}
function createResourceMap(readableSpans) {
const resourceMap = new Map();
for (const record of readableSpans) {
let ilsMap = resourceMap.get(record.resource);
if (!ilsMap) {
ilsMap = new Map();
resourceMap.set(record.resource, ilsMap);
}
// TODO this is duplicated in basic tracer. Consolidate on a common helper in core
const instrumentationScopeKey = `${record.instrumentationScope.name}@${record.instrumentationScope.version || ''}:${record.instrumentationScope.schemaUrl || ''}`;
let records = ilsMap.get(instrumentationScopeKey);
if (!records) {
records = [];
ilsMap.set(instrumentationScopeKey, records);
}
records.push(record);
}
return resourceMap;
}
function spanRecordsToResourceSpans(readableSpans, encoder) {
const resourceMap = createResourceMap(readableSpans);
const out = [];
const entryIterator = resourceMap.entries();
let entry = entryIterator.next();
while (!entry.done) {
const [resource, ilmMap] = entry.value;
const scopeResourceSpans = [];
const ilmIterator = ilmMap.values();
let ilmEntry = ilmIterator.next();
while (!ilmEntry.done) {
const scopeSpans = ilmEntry.value;
if (scopeSpans.length > 0) {
const spans = scopeSpans.map(readableSpan => sdkSpanToOtlpSpan(readableSpan, encoder));
scopeResourceSpans.push({
scope: createInstrumentationScope(scopeSpans[0].instrumentationScope),
spans: spans,
schemaUrl: scopeSpans[0].instrumentationScope.schemaUrl,
});
}
ilmEntry = ilmIterator.next();
}
const processedResource = createResource(resource, encoder);
const transformedSpans = {
resource: processedResource,
scopeSpans: scopeResourceSpans,
schemaUrl: processedResource.schemaUrl,
};
out.push(transformedSpans);
entry = entryIterator.next();
}
return out;
}
//# sourceMappingURL=internal.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export { JsonTraceSerializer } from './trace';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,7 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: exports added here are public
export { JsonTraceSerializer } from './trace';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/trace/json/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2CAA2C;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// IMPORTANT: exports added here are public\nexport { JsonTraceSerializer } from './trace';\n"]}

View File

@@ -0,0 +1,5 @@
import type { ISerializer } from '../../i-serializer';
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import type { IExportTraceServiceResponse } from '../export-response';
export declare const JsonTraceSerializer: ISerializer<ReadableSpan[], IExportTraceServiceResponse>;
//# sourceMappingURL=trace.d.ts.map

View File

@@ -0,0 +1,17 @@
import { createExportTraceServiceRequest } from '../internal';
import { JSON_ENCODER } from '../../common/utils';
export const JsonTraceSerializer = {
serializeRequest: (arg) => {
const request = createExportTraceServiceRequest(arg, JSON_ENCODER);
const encoder = new TextEncoder();
return encoder.encode(JSON.stringify(request));
},
deserializeResponse: (arg) => {
if (arg.length === 0) {
return {};
}
const decoder = new TextDecoder();
return JSON.parse(decoder.decode(arg));
},
};
//# sourceMappingURL=trace.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../src/trace/json/trace.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,mBAAmB,GAG5B;IACF,gBAAgB,EAAE,CAAC,GAAmB,EAAE,EAAE;QACxC,MAAM,OAAO,GAAG,+BAA+B,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QACnE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,mBAAmB,EAAE,CAAC,GAAe,EAAE,EAAE;QACvC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAO,EAAE,CAAC;SACX;QACD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAgC,CAAC;IACxE,CAAC;CACF,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { ISerializer } from '../../i-serializer';\nimport type { ReadableSpan } from '@opentelemetry/sdk-trace-base';\nimport type { IExportTraceServiceResponse } from '../export-response';\nimport { createExportTraceServiceRequest } from '../internal';\nimport { JSON_ENCODER } from '../../common/utils';\n\nexport const JsonTraceSerializer: ISerializer<\n ReadableSpan[],\n IExportTraceServiceResponse\n> = {\n serializeRequest: (arg: ReadableSpan[]) => {\n const request = createExportTraceServiceRequest(arg, JSON_ENCODER);\n const encoder = new TextEncoder();\n return encoder.encode(JSON.stringify(request));\n },\n deserializeResponse: (arg: Uint8Array) => {\n if (arg.length === 0) {\n return {};\n }\n const decoder = new TextDecoder();\n return JSON.parse(decoder.decode(arg)) as IExportTraceServiceResponse;\n },\n};\n"]}

View File

@@ -0,0 +1,2 @@
export { ProtobufTraceSerializer } from './trace';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,7 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
// IMPORTANT: exports added here are public
export { ProtobufTraceSerializer } from './trace';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/trace/protobuf/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2CAA2C;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// IMPORTANT: exports added here are public\nexport { ProtobufTraceSerializer } from './trace';\n"]}

View File

@@ -0,0 +1,5 @@
import type { ISerializer } from '../../i-serializer';
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import type { IExportTraceServiceResponse } from '../export-response';
export declare const ProtobufTraceSerializer: ISerializer<ReadableSpan[], IExportTraceServiceResponse>;
//# sourceMappingURL=trace.d.ts.map

View File

@@ -0,0 +1,21 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
import * as root from '../../generated/root';
import { createExportTraceServiceRequest } from '../internal';
import { PROTOBUF_ENCODER } from '../../common/utils';
const traceResponseType = root.opentelemetry.proto.collector.trace.v1
.ExportTraceServiceResponse;
const traceRequestType = root.opentelemetry.proto.collector.trace.v1
.ExportTraceServiceRequest;
export const ProtobufTraceSerializer = {
serializeRequest: (arg) => {
const request = createExportTraceServiceRequest(arg, PROTOBUF_ENCODER);
return traceRequestType.encode(request).finish();
},
deserializeResponse: (arg) => {
return traceResponseType.decode(arg);
},
};
//# sourceMappingURL=trace.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../src/trace/protobuf/trace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAK7C,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;KAClE,0BAAqE,CAAC;AAEzE,MAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;KACjE,yBAAmE,CAAC;AAEvE,MAAM,CAAC,MAAM,uBAAuB,GAGhC;IACF,gBAAgB,EAAE,CAAC,GAAmB,EAAE,EAAE;QACxC,MAAM,OAAO,GAAG,+BAA+B,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QACvE,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;IACD,mBAAmB,EAAE,CAAC,GAAe,EAAE,EAAE;QACvC,OAAO,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;CACF,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport * as root from '../../generated/root';\nimport type { ISerializer } from '../../i-serializer';\nimport type { ExportType } from '../../common/protobuf/protobuf-export-type';\nimport type { IExportTraceServiceRequest } from '../internal-types';\nimport type { ReadableSpan } from '@opentelemetry/sdk-trace-base';\nimport { createExportTraceServiceRequest } from '../internal';\nimport type { IExportTraceServiceResponse } from '../export-response';\nimport { PROTOBUF_ENCODER } from '../../common/utils';\n\nconst traceResponseType = root.opentelemetry.proto.collector.trace.v1\n .ExportTraceServiceResponse as ExportType<IExportTraceServiceResponse>;\n\nconst traceRequestType = root.opentelemetry.proto.collector.trace.v1\n .ExportTraceServiceRequest as ExportType<IExportTraceServiceRequest>;\n\nexport const ProtobufTraceSerializer: ISerializer<\n ReadableSpan[],\n IExportTraceServiceResponse\n> = {\n serializeRequest: (arg: ReadableSpan[]) => {\n const request = createExportTraceServiceRequest(arg, PROTOBUF_ENCODER);\n return traceRequestType.encode(request).finish();\n },\n deserializeResponse: (arg: Uint8Array) => {\n return traceResponseType.decode(arg);\n },\n};\n"]}