chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:32:57 +08:00
commit cd420f9332
4811 changed files with 884702 additions and 0 deletions
@@ -0,0 +1 @@
protoc.exe
@@ -0,0 +1,117 @@
# @trigger.dev/otlp-importer
## 3.0.0
## 3.0.0-beta.55
## 3.0.0-beta.54
## 3.0.0-beta.53
## 3.0.0-beta.52
## 3.0.0-beta.51
## 3.0.0-beta.50
## 3.0.0-beta.49
## 3.0.0-beta.48
## 3.0.0-beta.47
## 3.0.0-beta.46
## 3.0.0-beta.45
## 3.0.0-beta.44
## 3.0.0-beta.43
## 3.0.0-beta.42
## 3.0.0-beta.41
## 3.0.0-beta.40
## 3.0.0-beta.39
## 3.0.0-beta.38
## 3.0.0-beta.37
## 3.0.0-beta.36
## 3.0.0-beta.35
## 3.0.0-beta.34
## 3.0.0-beta.33
## 3.0.0-beta.32
## 3.0.0-beta.31
## 3.0.0-beta.30
## 3.0.0-beta.29
## 3.0.0-beta.28
## 3.0.0-beta.27
## 3.0.0-beta.26
## 3.0.0-beta.25
## 3.0.0-beta.24
## 3.0.0-beta.23
## 3.0.0-beta.22
## 3.0.0-beta.21
## 3.0.0-beta.20
## 3.0.0-beta.19
## 3.0.0-beta.18
## 3.0.0-beta.17
## 3.0.0-beta.16
## 3.0.0-beta.15
## 3.0.0-beta.14
## 3.0.0-beta.13
## 3.0.0-beta.12
### Patch Changes
- d3a18fbdf: Fix package builds and CLI commands on Windows
## 3.0.0-beta.11
## 3.0.0-beta.7
## 3.0.0-beta.6
## 3.0.0-beta.5
## 3.0.0-beta.4
## 3.0.0-beta.3
## 3.0.0-beta.2
## 3.0.0-beta.1
## 3.0.0-beta.0
### Major Changes
- 395abe1b9: Updates to support Trigger.dev v3
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Trigger.dev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+64
View File
@@ -0,0 +1,64 @@
# OTLP Importer
## Getting started
Install dependencies:
```sh Mac
brew install protobuf
```
```sh Linux
apt install -y protobuf-compiler
```
Alternatively, follow the [manual install instructions](https://github.com/protocolbuffers/protobuf?tab=readme-ov-file#protobuf-compiler-installation) for the protobuf compiler.
On Windows, download the correct binary from the [latest release](https://github.com/protocolbuffers/protobuf/releases) and extract the `protoc` binary to this directory, or add it to your `PATH`.
## Submodules
**Submodule is always pointing to certain revision number. So updating the submodule repo will not have impact on your code.
Knowing this if you want to change the submodule to point to a different version (when for example proto has changed) here is how to do it:**
### Updating submodule to point to certain revision number
1. Make sure you are in the same folder as this instruction
2. Update your submodules by running this command
```shell script
git submodule sync --recursive
git submodule update --init --recursive
```
3. Find the SHA which you want to update to and copy it (the long one)
the latest sha when this guide was written is `c451441d7b73f702d1647574c730daf7786f188c`
4. Enter a submodule directory from this directory
```shell script
cd protos
```
5. Updates files in the submodule tree to given commit:
```shell script
git checkout -q <sha>
```
6. Return to the main directory:
```shell script
cd ../
```
7. Please run `git status` you should see something like `Head detached at`. This is correct, go to next step
8. Now thing which is very important. You have to commit this to apply these changes
```shell script
git commit -am "chore: updating protos submodule for @trigger.dev/otlp-importer"
```
9. If you look now at git log you will notice that the folder `protos` has been changed and it will show what was the previous sha and what is current one.
@@ -0,0 +1,8 @@
module.exports = {
moduleFileExtensions: ["ts", "tsx", "js"],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
},
testMatch: ["<rootDir>/test/**/*.ts?(x)", "<rootDir>/test/**/?(*.)+(spec|test).ts?(x)"],
testEnvironment: "node",
};
@@ -0,0 +1,41 @@
{
"name": "@trigger.dev/otlp-importer",
"version": "3.0.0",
"description": "OpenTelemetry OTLP Importer for Node.js written in TypeScript",
"license": "MIT",
"main": "./src/index.ts",
"types": "./src/index.ts",
"module": "./src/index.ts",
"private": true,
"exports": {
".": {
"import": {
"types": "./src/index.ts",
"default": "./src/index.ts"
},
"require": "./src/index.ts",
"types": "./src/index.ts"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"scripts": {
"generate:code": "npm run protos",
"protos": "npm run submodule && npm run protos:generate",
"protos:generate": "node ./scripts/generate-protos.mjs",
"submodule": "node ./scripts/submodule.mjs",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@types/node": "^22.20.0",
"rimraf": "^6.0.1",
"ts-proto": "^1.167.3"
},
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"long": "^5.2.3",
"protobufjs": "^7.2.6"
}
}
@@ -0,0 +1,60 @@
import { promises as fs } from "fs";
import path from "path";
import { execPromise } from "./utils.mjs";
const isWindows = process.platform === "win32";
// Define the application root and directories for generated files and proto files
const appRoot = process.cwd();
const generatedPath = path.join(appRoot, "src", "generated");
const protosPath = path.join(appRoot, "protos");
const pluginPath = path.join(
appRoot,
"node_modules",
".bin",
isWindows ? "protoc-gen-ts_proto.cmd" : "protoc-gen-ts_proto"
);
// Ensure the generated directory exists
await fs.mkdir(generatedPath, { recursive: true });
// Define proto files
const protos = [
"opentelemetry/proto/common/v1/common.proto",
"opentelemetry/proto/resource/v1/resource.proto",
"opentelemetry/proto/trace/v1/trace.proto",
"opentelemetry/proto/collector/trace/v1/trace_service.proto",
"opentelemetry/proto/metrics/v1/metrics.proto",
"opentelemetry/proto/collector/metrics/v1/metrics_service.proto",
"opentelemetry/proto/logs/v1/logs.proto",
"opentelemetry/proto/collector/logs/v1/logs_service.proto",
];
// Use protoc with ts-proto to generate TypeScript files from proto files
for (const proto of protos) {
const command =
`protoc --plugin=protoc-gen-ts_proto="${pluginPath}" ` +
`--ts_proto_out="${generatedPath}" ` +
`--proto_path="${protosPath}" ` +
`--ts_proto_opt=forceLong=bigint ` +
`--ts_proto_opt=esModuleInterop=true ` +
`--ts_proto_opt=env=node ` +
`--ts_proto_opt=removeEnumPrefix=true ` +
`--ts_proto_opt=lowerCaseServiceMethods=true ` +
`--experimental_allow_proto3_optional ` +
`"${path.join(protosPath, proto)}"`;
try {
const { stdout, stderr } = await execPromise(command);
if (stdout) {
console.log(stdout);
} else {
console.log(`Generated ts file for ${proto}`);
}
if (stderr) console.error(stderr);
} catch (error) {
console.error(`An error occurred during generation: ${error}`);
process.exit(1);
}
}
console.log("TypeScript files generated successfully.");
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
# Define the application root and directories for generated files and proto files
appRoot=$(pwd)
generatedPath="$appRoot/src/generated"
protosPath="$appRoot/protos"
pluginPath="$appRoot/node_modules/.bin/protoc-gen-ts_proto"
# Ensure the generated directory exists
mkdir -p "$generatedPath"
# Define proto files
protos=(
"opentelemetry/proto/common/v1/common.proto"
"opentelemetry/proto/resource/v1/resource.proto"
"opentelemetry/proto/trace/v1/trace.proto"
"opentelemetry/proto/collector/trace/v1/trace_service.proto"
"opentelemetry/proto/metrics/v1/metrics.proto"
"opentelemetry/proto/collector/metrics/v1/metrics_service.proto"
"opentelemetry/proto/logs/v1/logs.proto"
"opentelemetry/proto/collector/logs/v1/logs_service.proto"
)
# Use protoc with ts-proto to generate TypeScript files from proto files
for proto in "${protos[@]}"; do
protoc --plugin=protoc-gen-ts_proto="$pluginPath" \
--ts_proto_out="$generatedPath" \
--proto_path="$protosPath" \
--ts_proto_opt=forceLong=bigint \
--ts_proto_opt=esModuleInterop=true \
--ts_proto_opt=env=node \
--ts_proto_opt=removeEnumPrefix=true \
--ts_proto_opt=lowerCaseServiceMethods=true \
--ts_proto_opt=oneof=unions \
"$protosPath/$proto"
done
# Check for errors
if [ $? -eq 0 ]; then
echo "TypeScript files generated successfully."
else
echo "An error occurred during generation."
fi
@@ -0,0 +1,31 @@
import { execPromise } from "./utils.mjs";
// git install check
try {
await execPromise("git --version");
} catch (_error) {
console.error("Git not installed or missing from PATH.");
process.exit(0);
}
// submodule sync
try {
const { stdout, stderr } = await execPromise("git submodule sync --recursive");
if (stdout) console.log(stdout);
if (stderr) console.error(stderr);
} catch (_error) {
console.error("Error during submodule sync.");
process.exit(1);
}
// submodule update
try {
const { stdout, stderr } = await execPromise("git submodule update --init --recursive");
if (stdout) console.log(stdout);
if (stderr) console.error(stderr);
} catch (_error) {
console.error("Error during submodule update.");
process.exit(1);
}
@@ -0,0 +1,13 @@
import { exec } from "child_process";
// Helper function to execute shell commands
export const execPromise = (command) =>
new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
reject(error);
} else {
resolve({ stdout, stderr });
}
});
});
@@ -0,0 +1,339 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { ResourceLogs } from "../../../logs/v1/logs";
export const protobufPackage = "opentelemetry.proto.collector.logs.v1";
export interface ExportLogsServiceRequest {
/**
* An array of ResourceLogs.
* For data coming from a single resource this array will typically contain one
* element. Intermediary nodes (such as OpenTelemetry Collector) that receive
* data from multiple origins typically batch the data before forwarding further and
* in that case this array will contain multiple elements.
*/
resourceLogs: ResourceLogs[];
}
export interface ExportLogsServiceResponse {
/**
* The details of a partially successful export request.
*
* If the request is only partially accepted
* (i.e. when the server accepts only parts of the data and rejects the rest)
* the server MUST initialize the `partial_success` field and MUST
* set the `rejected_<signal>` with the number of items it rejected.
*
* Servers MAY also make use of the `partial_success` field to convey
* warnings/suggestions to senders even when the request was fully accepted.
* In such cases, the `rejected_<signal>` MUST have a value of `0` and
* the `error_message` MUST be non-empty.
*
* A `partial_success` message with an empty value (rejected_<signal> = 0 and
* `error_message` = "") is equivalent to it not being set/present. Senders
* SHOULD interpret it the same way as in the full success case.
*/
partialSuccess: ExportLogsPartialSuccess | undefined;
}
export interface ExportLogsPartialSuccess {
/**
* The number of rejected log records.
*
* A `rejected_<signal>` field holding a `0` value indicates that the
* request was fully accepted.
*/
rejectedLogRecords: bigint;
/**
* A developer-facing human-readable message in English. It should be used
* either to explain why the server rejected parts of the data during a partial
* success or to convey warnings/suggestions during a full success. The message
* should offer guidance on how users can address such issues.
*
* error_message is an optional field. An error_message with an empty value
* is equivalent to it not being set.
*/
errorMessage: string;
}
function createBaseExportLogsServiceRequest(): ExportLogsServiceRequest {
return { resourceLogs: [] };
}
export const ExportLogsServiceRequest = {
encode(message: ExportLogsServiceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.resourceLogs) {
ResourceLogs.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportLogsServiceRequest {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportLogsServiceRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resourceLogs.push(ResourceLogs.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportLogsServiceRequest {
return {
resourceLogs: globalThis.Array.isArray(object?.resourceLogs)
? object.resourceLogs.map((e: any) => ResourceLogs.fromJSON(e))
: [],
};
},
toJSON(message: ExportLogsServiceRequest): unknown {
const obj: any = {};
if (message.resourceLogs?.length) {
obj.resourceLogs = message.resourceLogs.map((e) => ResourceLogs.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<ExportLogsServiceRequest>, I>>(
base?: I
): ExportLogsServiceRequest {
return ExportLogsServiceRequest.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportLogsServiceRequest>, I>>(
object: I
): ExportLogsServiceRequest {
const message = createBaseExportLogsServiceRequest();
message.resourceLogs = object.resourceLogs?.map((e) => ResourceLogs.fromPartial(e)) || [];
return message;
},
};
function createBaseExportLogsServiceResponse(): ExportLogsServiceResponse {
return { partialSuccess: undefined };
}
export const ExportLogsServiceResponse = {
encode(message: ExportLogsServiceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.partialSuccess !== undefined) {
ExportLogsPartialSuccess.encode(message.partialSuccess, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportLogsServiceResponse {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportLogsServiceResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.partialSuccess = ExportLogsPartialSuccess.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportLogsServiceResponse {
return {
partialSuccess: isSet(object.partialSuccess)
? ExportLogsPartialSuccess.fromJSON(object.partialSuccess)
: undefined,
};
},
toJSON(message: ExportLogsServiceResponse): unknown {
const obj: any = {};
if (message.partialSuccess !== undefined) {
obj.partialSuccess = ExportLogsPartialSuccess.toJSON(message.partialSuccess);
}
return obj;
},
create<I extends Exact<DeepPartial<ExportLogsServiceResponse>, I>>(
base?: I
): ExportLogsServiceResponse {
return ExportLogsServiceResponse.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportLogsServiceResponse>, I>>(
object: I
): ExportLogsServiceResponse {
const message = createBaseExportLogsServiceResponse();
message.partialSuccess =
object.partialSuccess !== undefined && object.partialSuccess !== null
? ExportLogsPartialSuccess.fromPartial(object.partialSuccess)
: undefined;
return message;
},
};
function createBaseExportLogsPartialSuccess(): ExportLogsPartialSuccess {
return { rejectedLogRecords: BigInt("0"), errorMessage: "" };
}
export const ExportLogsPartialSuccess = {
encode(message: ExportLogsPartialSuccess, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.rejectedLogRecords !== BigInt("0")) {
if (BigInt.asIntN(64, message.rejectedLogRecords) !== message.rejectedLogRecords) {
throw new globalThis.Error(
"value provided for field message.rejectedLogRecords of type int64 too large"
);
}
writer.uint32(8).int64(message.rejectedLogRecords.toString());
}
if (message.errorMessage !== "") {
writer.uint32(18).string(message.errorMessage);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportLogsPartialSuccess {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportLogsPartialSuccess();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.rejectedLogRecords = longToBigint(reader.int64() as Long);
continue;
case 2:
if (tag !== 18) {
break;
}
message.errorMessage = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportLogsPartialSuccess {
return {
rejectedLogRecords: isSet(object.rejectedLogRecords)
? BigInt(object.rejectedLogRecords)
: BigInt("0"),
errorMessage: isSet(object.errorMessage) ? globalThis.String(object.errorMessage) : "",
};
},
toJSON(message: ExportLogsPartialSuccess): unknown {
const obj: any = {};
if (message.rejectedLogRecords !== BigInt("0")) {
obj.rejectedLogRecords = message.rejectedLogRecords.toString();
}
if (message.errorMessage !== "") {
obj.errorMessage = message.errorMessage;
}
return obj;
},
create<I extends Exact<DeepPartial<ExportLogsPartialSuccess>, I>>(
base?: I
): ExportLogsPartialSuccess {
return ExportLogsPartialSuccess.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportLogsPartialSuccess>, I>>(
object: I
): ExportLogsPartialSuccess {
const message = createBaseExportLogsPartialSuccess();
message.rejectedLogRecords = object.rejectedLogRecords ?? BigInt("0");
message.errorMessage = object.errorMessage ?? "";
return message;
},
};
/**
* Service that can be used to push logs between one Application instrumented with
* OpenTelemetry and an collector, or between an collector and a central collector (in this
* case logs are sent/received to/from multiple Applications).
*/
export interface LogsService {
/**
* For performance reasons, it is recommended to keep this RPC
* alive for the entire life of the application.
*/
export(request: ExportLogsServiceRequest): Promise<ExportLogsServiceResponse>;
}
export const LogsServiceServiceName = "opentelemetry.proto.collector.logs.v1.LogsService";
export class LogsServiceClientImpl implements LogsService {
private readonly rpc: Rpc;
private readonly service: string;
constructor(rpc: Rpc, opts?: { service?: string }) {
this.service = opts?.service || LogsServiceServiceName;
this.rpc = rpc;
this.export = this.export.bind(this);
}
export(request: ExportLogsServiceRequest): Promise<ExportLogsServiceResponse> {
const data = ExportLogsServiceRequest.encode(request).finish();
const promise = this.rpc.request(this.service, "Export", data);
return promise.then((data) => ExportLogsServiceResponse.decode(_m0.Reader.create(data)));
}
}
interface Rpc {
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
}
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToBigint(long: Long) {
return BigInt(long.toString());
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
@@ -0,0 +1,349 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { ResourceMetrics } from "../../../metrics/v1/metrics";
export const protobufPackage = "opentelemetry.proto.collector.metrics.v1";
export interface ExportMetricsServiceRequest {
/**
* An array of ResourceMetrics.
* For data coming from a single resource this array will typically contain one
* element. Intermediary nodes (such as OpenTelemetry Collector) that receive
* data from multiple origins typically batch the data before forwarding further and
* in that case this array will contain multiple elements.
*/
resourceMetrics: ResourceMetrics[];
}
export interface ExportMetricsServiceResponse {
/**
* The details of a partially successful export request.
*
* If the request is only partially accepted
* (i.e. when the server accepts only parts of the data and rejects the rest)
* the server MUST initialize the `partial_success` field and MUST
* set the `rejected_<signal>` with the number of items it rejected.
*
* Servers MAY also make use of the `partial_success` field to convey
* warnings/suggestions to senders even when the request was fully accepted.
* In such cases, the `rejected_<signal>` MUST have a value of `0` and
* the `error_message` MUST be non-empty.
*
* A `partial_success` message with an empty value (rejected_<signal> = 0 and
* `error_message` = "") is equivalent to it not being set/present. Senders
* SHOULD interpret it the same way as in the full success case.
*/
partialSuccess: ExportMetricsPartialSuccess | undefined;
}
export interface ExportMetricsPartialSuccess {
/**
* The number of rejected data points.
*
* A `rejected_<signal>` field holding a `0` value indicates that the
* request was fully accepted.
*/
rejectedDataPoints: bigint;
/**
* A developer-facing human-readable message in English. It should be used
* either to explain why the server rejected parts of the data during a partial
* success or to convey warnings/suggestions during a full success. The message
* should offer guidance on how users can address such issues.
*
* error_message is an optional field. An error_message with an empty value
* is equivalent to it not being set.
*/
errorMessage: string;
}
function createBaseExportMetricsServiceRequest(): ExportMetricsServiceRequest {
return { resourceMetrics: [] };
}
export const ExportMetricsServiceRequest = {
encode(
message: ExportMetricsServiceRequest,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
for (const v of message.resourceMetrics) {
ResourceMetrics.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportMetricsServiceRequest {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportMetricsServiceRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resourceMetrics.push(ResourceMetrics.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportMetricsServiceRequest {
return {
resourceMetrics: globalThis.Array.isArray(object?.resourceMetrics)
? object.resourceMetrics.map((e: any) => ResourceMetrics.fromJSON(e))
: [],
};
},
toJSON(message: ExportMetricsServiceRequest): unknown {
const obj: any = {};
if (message.resourceMetrics?.length) {
obj.resourceMetrics = message.resourceMetrics.map((e) => ResourceMetrics.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<ExportMetricsServiceRequest>, I>>(
base?: I
): ExportMetricsServiceRequest {
return ExportMetricsServiceRequest.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportMetricsServiceRequest>, I>>(
object: I
): ExportMetricsServiceRequest {
const message = createBaseExportMetricsServiceRequest();
message.resourceMetrics =
object.resourceMetrics?.map((e) => ResourceMetrics.fromPartial(e)) || [];
return message;
},
};
function createBaseExportMetricsServiceResponse(): ExportMetricsServiceResponse {
return { partialSuccess: undefined };
}
export const ExportMetricsServiceResponse = {
encode(
message: ExportMetricsServiceResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.partialSuccess !== undefined) {
ExportMetricsPartialSuccess.encode(message.partialSuccess, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportMetricsServiceResponse {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportMetricsServiceResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.partialSuccess = ExportMetricsPartialSuccess.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportMetricsServiceResponse {
return {
partialSuccess: isSet(object.partialSuccess)
? ExportMetricsPartialSuccess.fromJSON(object.partialSuccess)
: undefined,
};
},
toJSON(message: ExportMetricsServiceResponse): unknown {
const obj: any = {};
if (message.partialSuccess !== undefined) {
obj.partialSuccess = ExportMetricsPartialSuccess.toJSON(message.partialSuccess);
}
return obj;
},
create<I extends Exact<DeepPartial<ExportMetricsServiceResponse>, I>>(
base?: I
): ExportMetricsServiceResponse {
return ExportMetricsServiceResponse.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportMetricsServiceResponse>, I>>(
object: I
): ExportMetricsServiceResponse {
const message = createBaseExportMetricsServiceResponse();
message.partialSuccess =
object.partialSuccess !== undefined && object.partialSuccess !== null
? ExportMetricsPartialSuccess.fromPartial(object.partialSuccess)
: undefined;
return message;
},
};
function createBaseExportMetricsPartialSuccess(): ExportMetricsPartialSuccess {
return { rejectedDataPoints: BigInt("0"), errorMessage: "" };
}
export const ExportMetricsPartialSuccess = {
encode(
message: ExportMetricsPartialSuccess,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.rejectedDataPoints !== BigInt("0")) {
if (BigInt.asIntN(64, message.rejectedDataPoints) !== message.rejectedDataPoints) {
throw new globalThis.Error(
"value provided for field message.rejectedDataPoints of type int64 too large"
);
}
writer.uint32(8).int64(message.rejectedDataPoints.toString());
}
if (message.errorMessage !== "") {
writer.uint32(18).string(message.errorMessage);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportMetricsPartialSuccess {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportMetricsPartialSuccess();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.rejectedDataPoints = longToBigint(reader.int64() as Long);
continue;
case 2:
if (tag !== 18) {
break;
}
message.errorMessage = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportMetricsPartialSuccess {
return {
rejectedDataPoints: isSet(object.rejectedDataPoints)
? BigInt(object.rejectedDataPoints)
: BigInt("0"),
errorMessage: isSet(object.errorMessage) ? globalThis.String(object.errorMessage) : "",
};
},
toJSON(message: ExportMetricsPartialSuccess): unknown {
const obj: any = {};
if (message.rejectedDataPoints !== BigInt("0")) {
obj.rejectedDataPoints = message.rejectedDataPoints.toString();
}
if (message.errorMessage !== "") {
obj.errorMessage = message.errorMessage;
}
return obj;
},
create<I extends Exact<DeepPartial<ExportMetricsPartialSuccess>, I>>(
base?: I
): ExportMetricsPartialSuccess {
return ExportMetricsPartialSuccess.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportMetricsPartialSuccess>, I>>(
object: I
): ExportMetricsPartialSuccess {
const message = createBaseExportMetricsPartialSuccess();
message.rejectedDataPoints = object.rejectedDataPoints ?? BigInt("0");
message.errorMessage = object.errorMessage ?? "";
return message;
},
};
/**
* Service that can be used to push metrics between one Application
* instrumented with OpenTelemetry and a collector, or between a collector and a
* central collector.
*/
export interface MetricsService {
/**
* For performance reasons, it is recommended to keep this RPC
* alive for the entire life of the application.
*/
export(request: ExportMetricsServiceRequest): Promise<ExportMetricsServiceResponse>;
}
export const MetricsServiceServiceName = "opentelemetry.proto.collector.metrics.v1.MetricsService";
export class MetricsServiceClientImpl implements MetricsService {
private readonly rpc: Rpc;
private readonly service: string;
constructor(rpc: Rpc, opts?: { service?: string }) {
this.service = opts?.service || MetricsServiceServiceName;
this.rpc = rpc;
this.export = this.export.bind(this);
}
export(request: ExportMetricsServiceRequest): Promise<ExportMetricsServiceResponse> {
const data = ExportMetricsServiceRequest.encode(request).finish();
const promise = this.rpc.request(this.service, "Export", data);
return promise.then((data) => ExportMetricsServiceResponse.decode(_m0.Reader.create(data)));
}
}
interface Rpc {
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
}
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToBigint(long: Long) {
return BigInt(long.toString());
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
@@ -0,0 +1,340 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { ResourceSpans } from "../../../trace/v1/trace";
export const protobufPackage = "opentelemetry.proto.collector.trace.v1";
export interface ExportTraceServiceRequest {
/**
* An array of ResourceSpans.
* For data coming from a single resource this array will typically contain one
* element. Intermediary nodes (such as OpenTelemetry Collector) that receive
* data from multiple origins typically batch the data before forwarding further and
* in that case this array will contain multiple elements.
*/
resourceSpans: ResourceSpans[];
}
export interface ExportTraceServiceResponse {
/**
* The details of a partially successful export request.
*
* If the request is only partially accepted
* (i.e. when the server accepts only parts of the data and rejects the rest)
* the server MUST initialize the `partial_success` field and MUST
* set the `rejected_<signal>` with the number of items it rejected.
*
* Servers MAY also make use of the `partial_success` field to convey
* warnings/suggestions to senders even when the request was fully accepted.
* In such cases, the `rejected_<signal>` MUST have a value of `0` and
* the `error_message` MUST be non-empty.
*
* A `partial_success` message with an empty value (rejected_<signal> = 0 and
* `error_message` = "") is equivalent to it not being set/present. Senders
* SHOULD interpret it the same way as in the full success case.
*/
partialSuccess: ExportTracePartialSuccess | undefined;
}
export interface ExportTracePartialSuccess {
/**
* The number of rejected spans.
*
* A `rejected_<signal>` field holding a `0` value indicates that the
* request was fully accepted.
*/
rejectedSpans: bigint;
/**
* A developer-facing human-readable message in English. It should be used
* either to explain why the server rejected parts of the data during a partial
* success or to convey warnings/suggestions during a full success. The message
* should offer guidance on how users can address such issues.
*
* error_message is an optional field. An error_message with an empty value
* is equivalent to it not being set.
*/
errorMessage: string;
}
function createBaseExportTraceServiceRequest(): ExportTraceServiceRequest {
return { resourceSpans: [] };
}
export const ExportTraceServiceRequest = {
encode(message: ExportTraceServiceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.resourceSpans) {
ResourceSpans.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportTraceServiceRequest {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportTraceServiceRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resourceSpans.push(ResourceSpans.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportTraceServiceRequest {
return {
resourceSpans: globalThis.Array.isArray(object?.resourceSpans)
? object.resourceSpans.map((e: any) => ResourceSpans.fromJSON(e))
: [],
};
},
toJSON(message: ExportTraceServiceRequest): unknown {
const obj: any = {};
if (message.resourceSpans?.length) {
obj.resourceSpans = message.resourceSpans.map((e) => ResourceSpans.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<ExportTraceServiceRequest>, I>>(
base?: I
): ExportTraceServiceRequest {
return ExportTraceServiceRequest.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportTraceServiceRequest>, I>>(
object: I
): ExportTraceServiceRequest {
const message = createBaseExportTraceServiceRequest();
message.resourceSpans = object.resourceSpans?.map((e) => ResourceSpans.fromPartial(e)) || [];
return message;
},
};
function createBaseExportTraceServiceResponse(): ExportTraceServiceResponse {
return { partialSuccess: undefined };
}
export const ExportTraceServiceResponse = {
encode(
message: ExportTraceServiceResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.partialSuccess !== undefined) {
ExportTracePartialSuccess.encode(message.partialSuccess, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportTraceServiceResponse {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportTraceServiceResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.partialSuccess = ExportTracePartialSuccess.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportTraceServiceResponse {
return {
partialSuccess: isSet(object.partialSuccess)
? ExportTracePartialSuccess.fromJSON(object.partialSuccess)
: undefined,
};
},
toJSON(message: ExportTraceServiceResponse): unknown {
const obj: any = {};
if (message.partialSuccess !== undefined) {
obj.partialSuccess = ExportTracePartialSuccess.toJSON(message.partialSuccess);
}
return obj;
},
create<I extends Exact<DeepPartial<ExportTraceServiceResponse>, I>>(
base?: I
): ExportTraceServiceResponse {
return ExportTraceServiceResponse.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportTraceServiceResponse>, I>>(
object: I
): ExportTraceServiceResponse {
const message = createBaseExportTraceServiceResponse();
message.partialSuccess =
object.partialSuccess !== undefined && object.partialSuccess !== null
? ExportTracePartialSuccess.fromPartial(object.partialSuccess)
: undefined;
return message;
},
};
function createBaseExportTracePartialSuccess(): ExportTracePartialSuccess {
return { rejectedSpans: BigInt("0"), errorMessage: "" };
}
export const ExportTracePartialSuccess = {
encode(message: ExportTracePartialSuccess, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.rejectedSpans !== BigInt("0")) {
if (BigInt.asIntN(64, message.rejectedSpans) !== message.rejectedSpans) {
throw new globalThis.Error(
"value provided for field message.rejectedSpans of type int64 too large"
);
}
writer.uint32(8).int64(message.rejectedSpans.toString());
}
if (message.errorMessage !== "") {
writer.uint32(18).string(message.errorMessage);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ExportTracePartialSuccess {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExportTracePartialSuccess();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.rejectedSpans = longToBigint(reader.int64() as Long);
continue;
case 2:
if (tag !== 18) {
break;
}
message.errorMessage = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ExportTracePartialSuccess {
return {
rejectedSpans: isSet(object.rejectedSpans) ? BigInt(object.rejectedSpans) : BigInt("0"),
errorMessage: isSet(object.errorMessage) ? globalThis.String(object.errorMessage) : "",
};
},
toJSON(message: ExportTracePartialSuccess): unknown {
const obj: any = {};
if (message.rejectedSpans !== BigInt("0")) {
obj.rejectedSpans = message.rejectedSpans.toString();
}
if (message.errorMessage !== "") {
obj.errorMessage = message.errorMessage;
}
return obj;
},
create<I extends Exact<DeepPartial<ExportTracePartialSuccess>, I>>(
base?: I
): ExportTracePartialSuccess {
return ExportTracePartialSuccess.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ExportTracePartialSuccess>, I>>(
object: I
): ExportTracePartialSuccess {
const message = createBaseExportTracePartialSuccess();
message.rejectedSpans = object.rejectedSpans ?? BigInt("0");
message.errorMessage = object.errorMessage ?? "";
return message;
},
};
/**
* Service that can be used to push spans between one Application instrumented with
* OpenTelemetry and a collector, or between a collector and a central collector (in this
* case spans are sent/received to/from multiple Applications).
*/
export interface TraceService {
/**
* For performance reasons, it is recommended to keep this RPC
* alive for the entire life of the application.
*/
export(request: ExportTraceServiceRequest): Promise<ExportTraceServiceResponse>;
}
export const TraceServiceServiceName = "opentelemetry.proto.collector.trace.v1.TraceService";
export class TraceServiceClientImpl implements TraceService {
private readonly rpc: Rpc;
private readonly service: string;
constructor(rpc: Rpc, opts?: { service?: string }) {
this.service = opts?.service || TraceServiceServiceName;
this.rpc = rpc;
this.export = this.export.bind(this);
}
export(request: ExportTraceServiceRequest): Promise<ExportTraceServiceResponse> {
const data = ExportTraceServiceRequest.encode(request).finish();
const promise = this.rpc.request(this.service, "Export", data);
return promise.then((data) => ExportTraceServiceResponse.decode(_m0.Reader.create(data)));
}
}
interface Rpc {
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
}
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToBigint(long: Long) {
return BigInt(long.toString());
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
@@ -0,0 +1,608 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "opentelemetry.proto.common.v1";
/**
* AnyValue is used to represent any type of attribute value. AnyValue may contain a
* primitive value such as a string or integer or it may contain an arbitrary nested
* object containing arrays, key-value lists and primitives.
*/
export interface AnyValue {
stringValue?: string | undefined;
boolValue?: boolean | undefined;
intValue?: bigint | undefined;
doubleValue?: number | undefined;
arrayValue?: ArrayValue | undefined;
kvlistValue?: KeyValueList | undefined;
bytesValue?: Buffer | undefined;
}
/**
* ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
* since oneof in AnyValue does not allow repeated fields.
*/
export interface ArrayValue {
/** Array of values. The array may be empty (contain 0 elements). */
values: AnyValue[];
}
/**
* KeyValueList is a list of KeyValue messages. We need KeyValueList as a message
* since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need
* a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
* avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
* are semantically equivalent.
*/
export interface KeyValueList {
/**
* A collection of key/value pairs of key-value pairs. The list may be empty (may
* contain 0 elements).
* The keys MUST be unique (it is not allowed to have more than one
* value with the same key).
*/
values: KeyValue[];
}
/**
* KeyValue is a key-value pair that is used to store Span attributes, Link
* attributes, etc.
*/
export interface KeyValue {
key: string;
value: AnyValue | undefined;
}
/**
* InstrumentationScope is a message representing the instrumentation scope information
* such as the fully qualified name and version.
*/
export interface InstrumentationScope {
/** An empty instrumentation scope name means the name is unknown. */
name: string;
version: string;
/**
* Additional attributes that describe the scope. [Optional].
* Attribute keys MUST be unique (it is not allowed to have more than one
* attribute with the same key).
*/
attributes: KeyValue[];
droppedAttributesCount: number;
}
function createBaseAnyValue(): AnyValue {
return {
stringValue: undefined,
boolValue: undefined,
intValue: undefined,
doubleValue: undefined,
arrayValue: undefined,
kvlistValue: undefined,
bytesValue: undefined,
};
}
export const AnyValue = {
encode(message: AnyValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.stringValue !== undefined) {
writer.uint32(10).string(message.stringValue);
}
if (message.boolValue !== undefined) {
writer.uint32(16).bool(message.boolValue);
}
if (message.intValue !== undefined) {
if (BigInt.asIntN(64, message.intValue) !== message.intValue) {
throw new globalThis.Error(
"value provided for field message.intValue of type int64 too large"
);
}
writer.uint32(24).int64(message.intValue.toString());
}
if (message.doubleValue !== undefined) {
writer.uint32(33).double(message.doubleValue);
}
if (message.arrayValue !== undefined) {
ArrayValue.encode(message.arrayValue, writer.uint32(42).fork()).ldelim();
}
if (message.kvlistValue !== undefined) {
KeyValueList.encode(message.kvlistValue, writer.uint32(50).fork()).ldelim();
}
if (message.bytesValue !== undefined) {
writer.uint32(58).bytes(message.bytesValue);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): AnyValue {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAnyValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.stringValue = reader.string();
continue;
case 2:
if (tag !== 16) {
break;
}
message.boolValue = reader.bool();
continue;
case 3:
if (tag !== 24) {
break;
}
message.intValue = longToBigint(reader.int64() as Long);
continue;
case 4:
if (tag !== 33) {
break;
}
message.doubleValue = reader.double();
continue;
case 5:
if (tag !== 42) {
break;
}
message.arrayValue = ArrayValue.decode(reader, reader.uint32());
continue;
case 6:
if (tag !== 50) {
break;
}
message.kvlistValue = KeyValueList.decode(reader, reader.uint32());
continue;
case 7:
if (tag !== 58) {
break;
}
message.bytesValue = reader.bytes() as Buffer;
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): AnyValue {
return {
stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined,
boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined,
intValue: isSet(object.intValue) ? BigInt(object.intValue) : undefined,
doubleValue: isSet(object.doubleValue) ? globalThis.Number(object.doubleValue) : undefined,
arrayValue: isSet(object.arrayValue) ? ArrayValue.fromJSON(object.arrayValue) : undefined,
kvlistValue: isSet(object.kvlistValue)
? KeyValueList.fromJSON(object.kvlistValue)
: undefined,
bytesValue: isSet(object.bytesValue)
? Buffer.from(bytesFromBase64(object.bytesValue))
: undefined,
};
},
toJSON(message: AnyValue): unknown {
const obj: any = {};
if (message.stringValue !== undefined) {
obj.stringValue = message.stringValue;
}
if (message.boolValue !== undefined) {
obj.boolValue = message.boolValue;
}
if (message.intValue !== undefined) {
obj.intValue = message.intValue.toString();
}
if (message.doubleValue !== undefined) {
obj.doubleValue = message.doubleValue;
}
if (message.arrayValue !== undefined) {
obj.arrayValue = ArrayValue.toJSON(message.arrayValue);
}
if (message.kvlistValue !== undefined) {
obj.kvlistValue = KeyValueList.toJSON(message.kvlistValue);
}
if (message.bytesValue !== undefined) {
obj.bytesValue = base64FromBytes(message.bytesValue);
}
return obj;
},
create<I extends Exact<DeepPartial<AnyValue>, I>>(base?: I): AnyValue {
return AnyValue.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<AnyValue>, I>>(object: I): AnyValue {
const message = createBaseAnyValue();
message.stringValue = object.stringValue ?? undefined;
message.boolValue = object.boolValue ?? undefined;
message.intValue = object.intValue ?? undefined;
message.doubleValue = object.doubleValue ?? undefined;
message.arrayValue =
object.arrayValue !== undefined && object.arrayValue !== null
? ArrayValue.fromPartial(object.arrayValue)
: undefined;
message.kvlistValue =
object.kvlistValue !== undefined && object.kvlistValue !== null
? KeyValueList.fromPartial(object.kvlistValue)
: undefined;
message.bytesValue = object.bytesValue ?? undefined;
return message;
},
};
function createBaseArrayValue(): ArrayValue {
return { values: [] };
}
export const ArrayValue = {
encode(message: ArrayValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.values) {
AnyValue.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ArrayValue {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseArrayValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.values.push(AnyValue.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ArrayValue {
return {
values: globalThis.Array.isArray(object?.values)
? object.values.map((e: any) => AnyValue.fromJSON(e))
: [],
};
},
toJSON(message: ArrayValue): unknown {
const obj: any = {};
if (message.values?.length) {
obj.values = message.values.map((e) => AnyValue.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<ArrayValue>, I>>(base?: I): ArrayValue {
return ArrayValue.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ArrayValue>, I>>(object: I): ArrayValue {
const message = createBaseArrayValue();
message.values = object.values?.map((e) => AnyValue.fromPartial(e)) || [];
return message;
},
};
function createBaseKeyValueList(): KeyValueList {
return { values: [] };
}
export const KeyValueList = {
encode(message: KeyValueList, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.values) {
KeyValue.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): KeyValueList {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseKeyValueList();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.values.push(KeyValue.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): KeyValueList {
return {
values: globalThis.Array.isArray(object?.values)
? object.values.map((e: any) => KeyValue.fromJSON(e))
: [],
};
},
toJSON(message: KeyValueList): unknown {
const obj: any = {};
if (message.values?.length) {
obj.values = message.values.map((e) => KeyValue.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<KeyValueList>, I>>(base?: I): KeyValueList {
return KeyValueList.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<KeyValueList>, I>>(object: I): KeyValueList {
const message = createBaseKeyValueList();
message.values = object.values?.map((e) => KeyValue.fromPartial(e)) || [];
return message;
},
};
function createBaseKeyValue(): KeyValue {
return { key: "", value: undefined };
}
export const KeyValue = {
encode(message: KeyValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.key !== "") {
writer.uint32(10).string(message.key);
}
if (message.value !== undefined) {
AnyValue.encode(message.value, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): KeyValue {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseKeyValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.key = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.value = AnyValue.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): KeyValue {
return {
key: isSet(object.key) ? globalThis.String(object.key) : "",
value: isSet(object.value) ? AnyValue.fromJSON(object.value) : undefined,
};
},
toJSON(message: KeyValue): unknown {
const obj: any = {};
if (message.key !== "") {
obj.key = message.key;
}
if (message.value !== undefined) {
obj.value = AnyValue.toJSON(message.value);
}
return obj;
},
create<I extends Exact<DeepPartial<KeyValue>, I>>(base?: I): KeyValue {
return KeyValue.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<KeyValue>, I>>(object: I): KeyValue {
const message = createBaseKeyValue();
message.key = object.key ?? "";
message.value =
object.value !== undefined && object.value !== null
? AnyValue.fromPartial(object.value)
: undefined;
return message;
},
};
function createBaseInstrumentationScope(): InstrumentationScope {
return { name: "", version: "", attributes: [], droppedAttributesCount: 0 };
}
export const InstrumentationScope = {
encode(message: InstrumentationScope, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.name !== "") {
writer.uint32(10).string(message.name);
}
if (message.version !== "") {
writer.uint32(18).string(message.version);
}
for (const v of message.attributes) {
KeyValue.encode(v!, writer.uint32(26).fork()).ldelim();
}
if (message.droppedAttributesCount !== 0) {
writer.uint32(32).uint32(message.droppedAttributesCount);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): InstrumentationScope {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseInstrumentationScope();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.name = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.version = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.attributes.push(KeyValue.decode(reader, reader.uint32()));
continue;
case 4:
if (tag !== 32) {
break;
}
message.droppedAttributesCount = reader.uint32();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): InstrumentationScope {
return {
name: isSet(object.name) ? globalThis.String(object.name) : "",
version: isSet(object.version) ? globalThis.String(object.version) : "",
attributes: globalThis.Array.isArray(object?.attributes)
? object.attributes.map((e: any) => KeyValue.fromJSON(e))
: [],
droppedAttributesCount: isSet(object.droppedAttributesCount)
? globalThis.Number(object.droppedAttributesCount)
: 0,
};
},
toJSON(message: InstrumentationScope): unknown {
const obj: any = {};
if (message.name !== "") {
obj.name = message.name;
}
if (message.version !== "") {
obj.version = message.version;
}
if (message.attributes?.length) {
obj.attributes = message.attributes.map((e) => KeyValue.toJSON(e));
}
if (message.droppedAttributesCount !== 0) {
obj.droppedAttributesCount = Math.round(message.droppedAttributesCount);
}
return obj;
},
create<I extends Exact<DeepPartial<InstrumentationScope>, I>>(base?: I): InstrumentationScope {
return InstrumentationScope.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<InstrumentationScope>, I>>(
object: I
): InstrumentationScope {
const message = createBaseInstrumentationScope();
message.name = object.name ?? "";
message.version = object.version ?? "";
message.attributes = object.attributes?.map((e) => KeyValue.fromPartial(e)) || [];
message.droppedAttributesCount = object.droppedAttributesCount ?? 0;
return message;
},
};
function bytesFromBase64(b64: string): Uint8Array {
if (globalThis.Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
} else {
const bin = globalThis.atob(b64);
const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i);
}
return arr;
}
}
function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
arr.forEach((byte) => {
bin.push(globalThis.String.fromCharCode(byte));
});
return globalThis.btoa(bin.join(""));
}
}
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToBigint(long: Long) {
return BigInt(long.toString());
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
@@ -0,0 +1,911 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { AnyValue, InstrumentationScope, KeyValue } from "../../common/v1/common";
import { Resource } from "../../resource/v1/resource";
export const protobufPackage = "opentelemetry.proto.logs.v1";
/** Possible values for LogRecord.SeverityNumber. */
export enum SeverityNumber {
/** UNSPECIFIED - UNSPECIFIED is the default SeverityNumber, it MUST NOT be used. */
UNSPECIFIED = 0,
TRACE = 1,
TRACE2 = 2,
TRACE3 = 3,
TRACE4 = 4,
DEBUG = 5,
DEBUG2 = 6,
DEBUG3 = 7,
DEBUG4 = 8,
INFO = 9,
INFO2 = 10,
INFO3 = 11,
INFO4 = 12,
WARN = 13,
WARN2 = 14,
WARN3 = 15,
WARN4 = 16,
ERROR = 17,
ERROR2 = 18,
ERROR3 = 19,
ERROR4 = 20,
FATAL = 21,
FATAL2 = 22,
FATAL3 = 23,
FATAL4 = 24,
UNRECOGNIZED = -1,
}
export function severityNumberFromJSON(object: any): SeverityNumber {
switch (object) {
case 0:
case "SEVERITY_NUMBER_UNSPECIFIED":
return SeverityNumber.UNSPECIFIED;
case 1:
case "SEVERITY_NUMBER_TRACE":
return SeverityNumber.TRACE;
case 2:
case "SEVERITY_NUMBER_TRACE2":
return SeverityNumber.TRACE2;
case 3:
case "SEVERITY_NUMBER_TRACE3":
return SeverityNumber.TRACE3;
case 4:
case "SEVERITY_NUMBER_TRACE4":
return SeverityNumber.TRACE4;
case 5:
case "SEVERITY_NUMBER_DEBUG":
return SeverityNumber.DEBUG;
case 6:
case "SEVERITY_NUMBER_DEBUG2":
return SeverityNumber.DEBUG2;
case 7:
case "SEVERITY_NUMBER_DEBUG3":
return SeverityNumber.DEBUG3;
case 8:
case "SEVERITY_NUMBER_DEBUG4":
return SeverityNumber.DEBUG4;
case 9:
case "SEVERITY_NUMBER_INFO":
return SeverityNumber.INFO;
case 10:
case "SEVERITY_NUMBER_INFO2":
return SeverityNumber.INFO2;
case 11:
case "SEVERITY_NUMBER_INFO3":
return SeverityNumber.INFO3;
case 12:
case "SEVERITY_NUMBER_INFO4":
return SeverityNumber.INFO4;
case 13:
case "SEVERITY_NUMBER_WARN":
return SeverityNumber.WARN;
case 14:
case "SEVERITY_NUMBER_WARN2":
return SeverityNumber.WARN2;
case 15:
case "SEVERITY_NUMBER_WARN3":
return SeverityNumber.WARN3;
case 16:
case "SEVERITY_NUMBER_WARN4":
return SeverityNumber.WARN4;
case 17:
case "SEVERITY_NUMBER_ERROR":
return SeverityNumber.ERROR;
case 18:
case "SEVERITY_NUMBER_ERROR2":
return SeverityNumber.ERROR2;
case 19:
case "SEVERITY_NUMBER_ERROR3":
return SeverityNumber.ERROR3;
case 20:
case "SEVERITY_NUMBER_ERROR4":
return SeverityNumber.ERROR4;
case 21:
case "SEVERITY_NUMBER_FATAL":
return SeverityNumber.FATAL;
case 22:
case "SEVERITY_NUMBER_FATAL2":
return SeverityNumber.FATAL2;
case 23:
case "SEVERITY_NUMBER_FATAL3":
return SeverityNumber.FATAL3;
case 24:
case "SEVERITY_NUMBER_FATAL4":
return SeverityNumber.FATAL4;
case -1:
case "UNRECOGNIZED":
default:
return SeverityNumber.UNRECOGNIZED;
}
}
export function severityNumberToJSON(object: SeverityNumber): string {
switch (object) {
case SeverityNumber.UNSPECIFIED:
return "SEVERITY_NUMBER_UNSPECIFIED";
case SeverityNumber.TRACE:
return "SEVERITY_NUMBER_TRACE";
case SeverityNumber.TRACE2:
return "SEVERITY_NUMBER_TRACE2";
case SeverityNumber.TRACE3:
return "SEVERITY_NUMBER_TRACE3";
case SeverityNumber.TRACE4:
return "SEVERITY_NUMBER_TRACE4";
case SeverityNumber.DEBUG:
return "SEVERITY_NUMBER_DEBUG";
case SeverityNumber.DEBUG2:
return "SEVERITY_NUMBER_DEBUG2";
case SeverityNumber.DEBUG3:
return "SEVERITY_NUMBER_DEBUG3";
case SeverityNumber.DEBUG4:
return "SEVERITY_NUMBER_DEBUG4";
case SeverityNumber.INFO:
return "SEVERITY_NUMBER_INFO";
case SeverityNumber.INFO2:
return "SEVERITY_NUMBER_INFO2";
case SeverityNumber.INFO3:
return "SEVERITY_NUMBER_INFO3";
case SeverityNumber.INFO4:
return "SEVERITY_NUMBER_INFO4";
case SeverityNumber.WARN:
return "SEVERITY_NUMBER_WARN";
case SeverityNumber.WARN2:
return "SEVERITY_NUMBER_WARN2";
case SeverityNumber.WARN3:
return "SEVERITY_NUMBER_WARN3";
case SeverityNumber.WARN4:
return "SEVERITY_NUMBER_WARN4";
case SeverityNumber.ERROR:
return "SEVERITY_NUMBER_ERROR";
case SeverityNumber.ERROR2:
return "SEVERITY_NUMBER_ERROR2";
case SeverityNumber.ERROR3:
return "SEVERITY_NUMBER_ERROR3";
case SeverityNumber.ERROR4:
return "SEVERITY_NUMBER_ERROR4";
case SeverityNumber.FATAL:
return "SEVERITY_NUMBER_FATAL";
case SeverityNumber.FATAL2:
return "SEVERITY_NUMBER_FATAL2";
case SeverityNumber.FATAL3:
return "SEVERITY_NUMBER_FATAL3";
case SeverityNumber.FATAL4:
return "SEVERITY_NUMBER_FATAL4";
case SeverityNumber.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
/**
* LogRecordFlags represents constants used to interpret the
* LogRecord.flags field, which is protobuf 'fixed32' type and is to
* be used as bit-fields. Each non-zero value defined in this enum is
* a bit-mask. To extract the bit-field, for example, use an
* expression like:
*
* (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
*/
export enum LogRecordFlags {
/**
* DO_NOT_USE - The zero value for the enum. Should not be used for comparisons.
* Instead use bitwise "and" with the appropriate mask as shown above.
*/
DO_NOT_USE = 0,
/** TRACE_FLAGS_MASK - Bits 0-7 are used for trace flags. */
TRACE_FLAGS_MASK = 255,
UNRECOGNIZED = -1,
}
export function logRecordFlagsFromJSON(object: any): LogRecordFlags {
switch (object) {
case 0:
case "LOG_RECORD_FLAGS_DO_NOT_USE":
return LogRecordFlags.DO_NOT_USE;
case 255:
case "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK":
return LogRecordFlags.TRACE_FLAGS_MASK;
case -1:
case "UNRECOGNIZED":
default:
return LogRecordFlags.UNRECOGNIZED;
}
}
export function logRecordFlagsToJSON(object: LogRecordFlags): string {
switch (object) {
case LogRecordFlags.DO_NOT_USE:
return "LOG_RECORD_FLAGS_DO_NOT_USE";
case LogRecordFlags.TRACE_FLAGS_MASK:
return "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK";
case LogRecordFlags.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
/**
* LogsData represents the logs data that can be stored in a persistent storage,
* OR can be embedded by other protocols that transfer OTLP logs data but do not
* implement the OTLP protocol.
*
* The main difference between this message and collector protocol is that
* in this message there will not be any "control" or "metadata" specific to
* OTLP protocol.
*
* When new fields are added into this message, the OTLP request MUST be updated
* as well.
*/
export interface LogsData {
/**
* An array of ResourceLogs.
* For data coming from a single resource this array will typically contain
* one element. Intermediary nodes that receive data from multiple origins
* typically batch the data before forwarding further and in that case this
* array will contain multiple elements.
*/
resourceLogs: ResourceLogs[];
}
/** A collection of ScopeLogs from a Resource. */
export interface ResourceLogs {
/**
* The resource for the logs in this message.
* If this field is not set then resource info is unknown.
*/
resource: Resource | undefined;
/** A list of ScopeLogs that originate from a resource. */
scopeLogs: ScopeLogs[];
/**
* The Schema URL, if known. This is the identifier of the Schema that the resource data
* is recorded in. To learn more about Schema URL see
* https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
* This schema_url applies to the data in the "resource" field. It does not apply
* to the data in the "scope_logs" field which have their own schema_url field.
*/
schemaUrl: string;
}
/** A collection of Logs produced by a Scope. */
export interface ScopeLogs {
/**
* The instrumentation scope information for the logs in this message.
* Semantically when InstrumentationScope isn't set, it is equivalent with
* an empty instrumentation scope name (unknown).
*/
scope: InstrumentationScope | undefined;
/** A list of log records. */
logRecords: LogRecord[];
/**
* The Schema URL, if known. This is the identifier of the Schema that the log data
* is recorded in. To learn more about Schema URL see
* https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
* This schema_url applies to all logs in the "logs" field.
*/
schemaUrl: string;
}
/**
* A log record according to OpenTelemetry Log Data Model:
* https://github.com/open-telemetry/oteps/blob/main/text/logs/0097-log-data-model.md
*/
export interface LogRecord {
/**
* time_unix_nano is the time when the event occurred.
* Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
* Value of 0 indicates unknown or missing timestamp.
*/
timeUnixNano: bigint;
/**
* Time when the event was observed by the collection system.
* For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK)
* this timestamp is typically set at the generation time and is equal to Timestamp.
* For events originating externally and collected by OpenTelemetry (e.g. using
* Collector) this is the time when OpenTelemetry's code observed the event measured
* by the clock of the OpenTelemetry code. This field MUST be set once the event is
* observed by OpenTelemetry.
*
* For converting OpenTelemetry log data to formats that support only one timestamp or
* when receiving OpenTelemetry log data by recipients that support only one timestamp
* internally the following logic is recommended:
* - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano.
*
* Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
* Value of 0 indicates unknown or missing timestamp.
*/
observedTimeUnixNano: bigint;
/**
* Numerical value of the severity, normalized to values described in Log Data Model.
* [Optional].
*/
severityNumber: SeverityNumber;
/**
* The severity text (also known as log level). The original string representation as
* it is known at the source. [Optional].
*/
severityText: string;
/**
* A value containing the body of the log record. Can be for example a human-readable
* string message (including multi-line) describing the event in a free form or it can
* be a structured data composed of arrays and maps of other values. [Optional].
*/
body: AnyValue | undefined;
/**
* Additional attributes that describe the specific event occurrence. [Optional].
* Attribute keys MUST be unique (it is not allowed to have more than one
* attribute with the same key).
*/
attributes: KeyValue[];
droppedAttributesCount: number;
/**
* Flags, a bit field. 8 least significant bits are the trace flags as
* defined in W3C Trace Context specification. 24 most significant bits are reserved
* and must be set to 0. Readers must not assume that 24 most significant bits
* will be zero and must correctly mask the bits when reading 8-bit trace flag (use
* flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].
*/
flags: number;
/**
* A unique identifier for a trace. All logs from the same trace share
* the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
* of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
* is zero-length and thus is also invalid).
*
* This field is optional.
*
* The receivers SHOULD assume that the log record is not associated with a
* trace if any of the following is true:
* - the field is not present,
* - the field contains an invalid value.
*/
traceId: Buffer;
/**
* A unique identifier for a span within a trace, assigned when the span
* is created. The ID is an 8-byte array. An ID with all zeroes OR of length
* other than 8 bytes is considered invalid (empty string in OTLP/JSON
* is zero-length and thus is also invalid).
*
* This field is optional. If the sender specifies a valid span_id then it SHOULD also
* specify a valid trace_id.
*
* The receivers SHOULD assume that the log record is not associated with a
* span if any of the following is true:
* - the field is not present,
* - the field contains an invalid value.
*/
spanId: Buffer;
}
function createBaseLogsData(): LogsData {
return { resourceLogs: [] };
}
export const LogsData = {
encode(message: LogsData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.resourceLogs) {
ResourceLogs.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): LogsData {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseLogsData();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resourceLogs.push(ResourceLogs.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): LogsData {
return {
resourceLogs: globalThis.Array.isArray(object?.resourceLogs)
? object.resourceLogs.map((e: any) => ResourceLogs.fromJSON(e))
: [],
};
},
toJSON(message: LogsData): unknown {
const obj: any = {};
if (message.resourceLogs?.length) {
obj.resourceLogs = message.resourceLogs.map((e) => ResourceLogs.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<LogsData>, I>>(base?: I): LogsData {
return LogsData.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<LogsData>, I>>(object: I): LogsData {
const message = createBaseLogsData();
message.resourceLogs = object.resourceLogs?.map((e) => ResourceLogs.fromPartial(e)) || [];
return message;
},
};
function createBaseResourceLogs(): ResourceLogs {
return { resource: undefined, scopeLogs: [], schemaUrl: "" };
}
export const ResourceLogs = {
encode(message: ResourceLogs, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.resource !== undefined) {
Resource.encode(message.resource, writer.uint32(10).fork()).ldelim();
}
for (const v of message.scopeLogs) {
ScopeLogs.encode(v!, writer.uint32(18).fork()).ldelim();
}
if (message.schemaUrl !== "") {
writer.uint32(26).string(message.schemaUrl);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ResourceLogs {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseResourceLogs();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resource = Resource.decode(reader, reader.uint32());
continue;
case 2:
if (tag !== 18) {
break;
}
message.scopeLogs.push(ScopeLogs.decode(reader, reader.uint32()));
continue;
case 3:
if (tag !== 26) {
break;
}
message.schemaUrl = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ResourceLogs {
return {
resource: isSet(object.resource) ? Resource.fromJSON(object.resource) : undefined,
scopeLogs: globalThis.Array.isArray(object?.scopeLogs)
? object.scopeLogs.map((e: any) => ScopeLogs.fromJSON(e))
: [],
schemaUrl: isSet(object.schemaUrl) ? globalThis.String(object.schemaUrl) : "",
};
},
toJSON(message: ResourceLogs): unknown {
const obj: any = {};
if (message.resource !== undefined) {
obj.resource = Resource.toJSON(message.resource);
}
if (message.scopeLogs?.length) {
obj.scopeLogs = message.scopeLogs.map((e) => ScopeLogs.toJSON(e));
}
if (message.schemaUrl !== "") {
obj.schemaUrl = message.schemaUrl;
}
return obj;
},
create<I extends Exact<DeepPartial<ResourceLogs>, I>>(base?: I): ResourceLogs {
return ResourceLogs.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ResourceLogs>, I>>(object: I): ResourceLogs {
const message = createBaseResourceLogs();
message.resource =
object.resource !== undefined && object.resource !== null
? Resource.fromPartial(object.resource)
: undefined;
message.scopeLogs = object.scopeLogs?.map((e) => ScopeLogs.fromPartial(e)) || [];
message.schemaUrl = object.schemaUrl ?? "";
return message;
},
};
function createBaseScopeLogs(): ScopeLogs {
return { scope: undefined, logRecords: [], schemaUrl: "" };
}
export const ScopeLogs = {
encode(message: ScopeLogs, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.scope !== undefined) {
InstrumentationScope.encode(message.scope, writer.uint32(10).fork()).ldelim();
}
for (const v of message.logRecords) {
LogRecord.encode(v!, writer.uint32(18).fork()).ldelim();
}
if (message.schemaUrl !== "") {
writer.uint32(26).string(message.schemaUrl);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ScopeLogs {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseScopeLogs();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.scope = InstrumentationScope.decode(reader, reader.uint32());
continue;
case 2:
if (tag !== 18) {
break;
}
message.logRecords.push(LogRecord.decode(reader, reader.uint32()));
continue;
case 3:
if (tag !== 26) {
break;
}
message.schemaUrl = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ScopeLogs {
return {
scope: isSet(object.scope) ? InstrumentationScope.fromJSON(object.scope) : undefined,
logRecords: globalThis.Array.isArray(object?.logRecords)
? object.logRecords.map((e: any) => LogRecord.fromJSON(e))
: [],
schemaUrl: isSet(object.schemaUrl) ? globalThis.String(object.schemaUrl) : "",
};
},
toJSON(message: ScopeLogs): unknown {
const obj: any = {};
if (message.scope !== undefined) {
obj.scope = InstrumentationScope.toJSON(message.scope);
}
if (message.logRecords?.length) {
obj.logRecords = message.logRecords.map((e) => LogRecord.toJSON(e));
}
if (message.schemaUrl !== "") {
obj.schemaUrl = message.schemaUrl;
}
return obj;
},
create<I extends Exact<DeepPartial<ScopeLogs>, I>>(base?: I): ScopeLogs {
return ScopeLogs.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ScopeLogs>, I>>(object: I): ScopeLogs {
const message = createBaseScopeLogs();
message.scope =
object.scope !== undefined && object.scope !== null
? InstrumentationScope.fromPartial(object.scope)
: undefined;
message.logRecords = object.logRecords?.map((e) => LogRecord.fromPartial(e)) || [];
message.schemaUrl = object.schemaUrl ?? "";
return message;
},
};
function createBaseLogRecord(): LogRecord {
return {
timeUnixNano: BigInt("0"),
observedTimeUnixNano: BigInt("0"),
severityNumber: 0,
severityText: "",
body: undefined,
attributes: [],
droppedAttributesCount: 0,
flags: 0,
traceId: Buffer.alloc(0),
spanId: Buffer.alloc(0),
};
}
export const LogRecord = {
encode(message: LogRecord, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.timeUnixNano !== BigInt("0")) {
if (BigInt.asUintN(64, message.timeUnixNano) !== message.timeUnixNano) {
throw new globalThis.Error(
"value provided for field message.timeUnixNano of type fixed64 too large"
);
}
writer.uint32(9).fixed64(message.timeUnixNano.toString());
}
if (message.observedTimeUnixNano !== BigInt("0")) {
if (BigInt.asUintN(64, message.observedTimeUnixNano) !== message.observedTimeUnixNano) {
throw new globalThis.Error(
"value provided for field message.observedTimeUnixNano of type fixed64 too large"
);
}
writer.uint32(89).fixed64(message.observedTimeUnixNano.toString());
}
if (message.severityNumber !== 0) {
writer.uint32(16).int32(message.severityNumber);
}
if (message.severityText !== "") {
writer.uint32(26).string(message.severityText);
}
if (message.body !== undefined) {
AnyValue.encode(message.body, writer.uint32(42).fork()).ldelim();
}
for (const v of message.attributes) {
KeyValue.encode(v!, writer.uint32(50).fork()).ldelim();
}
if (message.droppedAttributesCount !== 0) {
writer.uint32(56).uint32(message.droppedAttributesCount);
}
if (message.flags !== 0) {
writer.uint32(69).fixed32(message.flags);
}
if (message.traceId.length !== 0) {
writer.uint32(74).bytes(message.traceId);
}
if (message.spanId.length !== 0) {
writer.uint32(82).bytes(message.spanId);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): LogRecord {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseLogRecord();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 9) {
break;
}
message.timeUnixNano = longToBigint(reader.fixed64() as Long);
continue;
case 11:
if (tag !== 89) {
break;
}
message.observedTimeUnixNano = longToBigint(reader.fixed64() as Long);
continue;
case 2:
if (tag !== 16) {
break;
}
message.severityNumber = reader.int32() as any;
continue;
case 3:
if (tag !== 26) {
break;
}
message.severityText = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
message.body = AnyValue.decode(reader, reader.uint32());
continue;
case 6:
if (tag !== 50) {
break;
}
message.attributes.push(KeyValue.decode(reader, reader.uint32()));
continue;
case 7:
if (tag !== 56) {
break;
}
message.droppedAttributesCount = reader.uint32();
continue;
case 8:
if (tag !== 69) {
break;
}
message.flags = reader.fixed32();
continue;
case 9:
if (tag !== 74) {
break;
}
message.traceId = reader.bytes() as Buffer;
continue;
case 10:
if (tag !== 82) {
break;
}
message.spanId = reader.bytes() as Buffer;
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): LogRecord {
return {
timeUnixNano: isSet(object.timeUnixNano) ? BigInt(object.timeUnixNano) : BigInt("0"),
observedTimeUnixNano: isSet(object.observedTimeUnixNano)
? BigInt(object.observedTimeUnixNano)
: BigInt("0"),
severityNumber: isSet(object.severityNumber)
? severityNumberFromJSON(object.severityNumber)
: 0,
severityText: isSet(object.severityText) ? globalThis.String(object.severityText) : "",
body: isSet(object.body) ? AnyValue.fromJSON(object.body) : undefined,
attributes: globalThis.Array.isArray(object?.attributes)
? object.attributes.map((e: any) => KeyValue.fromJSON(e))
: [],
droppedAttributesCount: isSet(object.droppedAttributesCount)
? globalThis.Number(object.droppedAttributesCount)
: 0,
flags: isSet(object.flags) ? globalThis.Number(object.flags) : 0,
traceId: isSet(object.traceId)
? Buffer.from(bytesFromBase64(object.traceId))
: Buffer.alloc(0),
spanId: isSet(object.spanId) ? Buffer.from(bytesFromBase64(object.spanId)) : Buffer.alloc(0),
};
},
toJSON(message: LogRecord): unknown {
const obj: any = {};
if (message.timeUnixNano !== BigInt("0")) {
obj.timeUnixNano = message.timeUnixNano.toString();
}
if (message.observedTimeUnixNano !== BigInt("0")) {
obj.observedTimeUnixNano = message.observedTimeUnixNano.toString();
}
if (message.severityNumber !== 0) {
obj.severityNumber = severityNumberToJSON(message.severityNumber);
}
if (message.severityText !== "") {
obj.severityText = message.severityText;
}
if (message.body !== undefined) {
obj.body = AnyValue.toJSON(message.body);
}
if (message.attributes?.length) {
obj.attributes = message.attributes.map((e) => KeyValue.toJSON(e));
}
if (message.droppedAttributesCount !== 0) {
obj.droppedAttributesCount = Math.round(message.droppedAttributesCount);
}
if (message.flags !== 0) {
obj.flags = Math.round(message.flags);
}
if (message.traceId.length !== 0) {
obj.traceId = base64FromBytes(message.traceId);
}
if (message.spanId.length !== 0) {
obj.spanId = base64FromBytes(message.spanId);
}
return obj;
},
create<I extends Exact<DeepPartial<LogRecord>, I>>(base?: I): LogRecord {
return LogRecord.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<LogRecord>, I>>(object: I): LogRecord {
const message = createBaseLogRecord();
message.timeUnixNano = object.timeUnixNano ?? BigInt("0");
message.observedTimeUnixNano = object.observedTimeUnixNano ?? BigInt("0");
message.severityNumber = object.severityNumber ?? 0;
message.severityText = object.severityText ?? "";
message.body =
object.body !== undefined && object.body !== null
? AnyValue.fromPartial(object.body)
: undefined;
message.attributes = object.attributes?.map((e) => KeyValue.fromPartial(e)) || [];
message.droppedAttributesCount = object.droppedAttributesCount ?? 0;
message.flags = object.flags ?? 0;
message.traceId = object.traceId ?? Buffer.alloc(0);
message.spanId = object.spanId ?? Buffer.alloc(0);
return message;
},
};
function bytesFromBase64(b64: string): Uint8Array {
if (globalThis.Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
} else {
const bin = globalThis.atob(b64);
const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i);
}
return arr;
}
}
function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
arr.forEach((byte) => {
bin.push(globalThis.String.fromCharCode(byte));
});
return globalThis.btoa(bin.join(""));
}
}
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToBigint(long: Long) {
return BigInt(long.toString());
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
@@ -0,0 +1,119 @@
/* eslint-disable */
import _m0 from "protobufjs/minimal";
import { KeyValue } from "../../common/v1/common";
export const protobufPackage = "opentelemetry.proto.resource.v1";
/** Resource information. */
export interface Resource {
/**
* Set of attributes that describe the resource.
* Attribute keys MUST be unique (it is not allowed to have more than one
* attribute with the same key).
*/
attributes: KeyValue[];
/**
* dropped_attributes_count is the number of dropped attributes. If the value is 0, then
* no attributes were dropped.
*/
droppedAttributesCount: number;
}
function createBaseResource(): Resource {
return { attributes: [], droppedAttributesCount: 0 };
}
export const Resource = {
encode(message: Resource, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.attributes) {
KeyValue.encode(v!, writer.uint32(10).fork()).ldelim();
}
if (message.droppedAttributesCount !== 0) {
writer.uint32(16).uint32(message.droppedAttributesCount);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): Resource {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseResource();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.attributes.push(KeyValue.decode(reader, reader.uint32()));
continue;
case 2:
if (tag !== 16) {
break;
}
message.droppedAttributesCount = reader.uint32();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): Resource {
return {
attributes: globalThis.Array.isArray(object?.attributes)
? object.attributes.map((e: any) => KeyValue.fromJSON(e))
: [],
droppedAttributesCount: isSet(object.droppedAttributesCount)
? globalThis.Number(object.droppedAttributesCount)
: 0,
};
},
toJSON(message: Resource): unknown {
const obj: any = {};
if (message.attributes?.length) {
obj.attributes = message.attributes.map((e) => KeyValue.toJSON(e));
}
if (message.droppedAttributesCount !== 0) {
obj.droppedAttributesCount = Math.round(message.droppedAttributesCount);
}
return obj;
},
create<I extends Exact<DeepPartial<Resource>, I>>(base?: I): Resource {
return Resource.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Resource>, I>>(object: I): Resource {
const message = createBaseResource();
message.attributes = object.attributes?.map((e) => KeyValue.fromPartial(e)) || [];
message.droppedAttributesCount = object.droppedAttributesCount ?? 0;
return message;
},
};
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
@@ -0,0 +1,98 @@
import {
ExportTracePartialSuccess,
ExportTraceServiceRequest,
ExportTraceServiceResponse,
} from "./generated/opentelemetry/proto/collector/trace/v1/trace_service";
import {
ExportLogsPartialSuccess,
ExportLogsServiceRequest,
ExportLogsServiceResponse,
} from "./generated/opentelemetry/proto/collector/logs/v1/logs_service";
import {
ExportMetricsPartialSuccess,
ExportMetricsServiceRequest,
ExportMetricsServiceResponse,
} from "./generated/opentelemetry/proto/collector/metrics/v1/metrics_service";
import type {
AnyValue,
KeyValue,
KeyValueList,
} from "./generated/opentelemetry/proto/common/v1/common";
import {
LogRecord,
ResourceLogs,
ScopeLogs,
SeverityNumber,
} from "./generated/opentelemetry/proto/logs/v1/logs";
import { Resource } from "./generated/opentelemetry/proto/resource/v1/resource";
import {
ResourceSpans,
ScopeSpans,
Span,
SpanFlags,
Span_Event,
Span_Link,
Span_SpanKind,
Status,
Status_StatusCode,
} from "./generated/opentelemetry/proto/trace/v1/trace";
import {
ResourceMetrics,
ScopeMetrics,
Metric,
Gauge,
Sum,
Histogram,
ExponentialHistogram,
Summary,
NumberDataPoint,
HistogramDataPoint,
ExponentialHistogramDataPoint,
SummaryDataPoint,
AggregationTemporality,
} from "./generated/opentelemetry/proto/metrics/v1/metrics";
export {
LogRecord,
Resource,
ResourceLogs,
ResourceSpans,
ScopeLogs,
ScopeSpans,
SeverityNumber,
Span,
SpanFlags,
Span_Event,
Span_Link,
Span_SpanKind,
Status,
Status_StatusCode,
type AnyValue,
type KeyValue,
type KeyValueList,
};
export { ExportTracePartialSuccess, ExportTraceServiceRequest, ExportTraceServiceResponse };
export { ExportLogsPartialSuccess, ExportLogsServiceRequest, ExportLogsServiceResponse };
export { ExportMetricsPartialSuccess, ExportMetricsServiceRequest, ExportMetricsServiceResponse };
export {
ResourceMetrics,
ScopeMetrics,
Metric,
Gauge,
Sum,
Histogram,
ExponentialHistogram,
Summary,
NumberDataPoint,
HistogramDataPoint,
ExponentialHistogramDataPoint,
SummaryDataPoint,
AggregationTemporality,
};
@@ -0,0 +1,10 @@
{
"extends": "../../.configs/tsconfig.base.json",
"compilerOptions": {
"isolatedDeclarations": false,
"composite": true,
"sourceMap": true,
"stripInternal": true
},
"include": ["./src/**/*.ts"]
}
@@ -0,0 +1,19 @@
import { defineConfig } from "tsup";
export default defineConfig({
name: "main",
config: "tsconfig.build.json",
entry: ["./src/index.ts"],
outDir: "./dist",
platform: "node",
format: ["cjs", "esm"],
legacyOutput: false,
sourcemap: true,
clean: true,
bundle: true,
splitting: false,
dts: true,
treeshake: {
preset: "recommended",
},
});