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,44 @@
import type * as logsAPI from '@opentelemetry/api-logs';
import * as api from '@opentelemetry/api';
import { InstrumentationScope } from '@opentelemetry/core';
import type { IResource } from '@opentelemetry/resources';
import type { ReadableLogRecord } from './export/ReadableLogRecord';
import { AnyValue, LogAttributes, LogBody } from '@opentelemetry/api-logs';
import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';
export declare class LogRecord implements ReadableLogRecord {
readonly hrTime: api.HrTime;
readonly hrTimeObserved: api.HrTime;
readonly spanContext?: api.SpanContext;
readonly resource: IResource;
readonly instrumentationScope: InstrumentationScope;
readonly attributes: logsAPI.LogAttributes;
private _severityText?;
private _severityNumber?;
private _body?;
private totalAttributesCount;
private _isReadonly;
private readonly _logRecordLimits;
set severityText(severityText: string | undefined);
get severityText(): string | undefined;
set severityNumber(severityNumber: logsAPI.SeverityNumber | undefined);
get severityNumber(): logsAPI.SeverityNumber | undefined;
set body(body: LogBody | undefined);
get body(): LogBody | undefined;
get droppedAttributesCount(): number;
constructor(_sharedState: LoggerProviderSharedState, instrumentationScope: InstrumentationScope, logRecord: logsAPI.LogRecord);
setAttribute(key: string, value?: AnyValue): this;
setAttributes(attributes: LogAttributes): this;
setBody(body: LogBody): this;
setSeverityNumber(severityNumber: logsAPI.SeverityNumber): this;
setSeverityText(severityText: string): this;
/**
* @internal
* A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.
* If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.
*/
_makeReadonly(): void;
private _truncateToSize;
private _truncateToLimitUtil;
private _isLogRecordReadonly;
}
//# sourceMappingURL=LogRecord.d.ts.map

View File

@@ -0,0 +1,225 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
import { diag } from '@opentelemetry/api';
import * as api from '@opentelemetry/api';
import { timeInputToHrTime, isAttributeValue, } from '@opentelemetry/core';
var LogRecord = /** @class */ (function () {
function LogRecord(_sharedState, instrumentationScope, logRecord) {
this.attributes = {};
this.totalAttributesCount = 0;
this._isReadonly = false;
var timestamp = logRecord.timestamp, observedTimestamp = logRecord.observedTimestamp, severityNumber = logRecord.severityNumber, severityText = logRecord.severityText, body = logRecord.body, _a = logRecord.attributes, attributes = _a === void 0 ? {} : _a, context = logRecord.context;
var now = Date.now();
this.hrTime = timeInputToHrTime(timestamp !== null && timestamp !== void 0 ? timestamp : now);
this.hrTimeObserved = timeInputToHrTime(observedTimestamp !== null && observedTimestamp !== void 0 ? observedTimestamp : now);
if (context) {
var spanContext = api.trace.getSpanContext(context);
if (spanContext && api.isSpanContextValid(spanContext)) {
this.spanContext = spanContext;
}
}
this.severityNumber = severityNumber;
this.severityText = severityText;
this.body = body;
this.resource = _sharedState.resource;
this.instrumentationScope = instrumentationScope;
this._logRecordLimits = _sharedState.logRecordLimits;
this.setAttributes(attributes);
}
Object.defineProperty(LogRecord.prototype, "severityText", {
get: function () {
return this._severityText;
},
set: function (severityText) {
if (this._isLogRecordReadonly()) {
return;
}
this._severityText = severityText;
},
enumerable: false,
configurable: true
});
Object.defineProperty(LogRecord.prototype, "severityNumber", {
get: function () {
return this._severityNumber;
},
set: function (severityNumber) {
if (this._isLogRecordReadonly()) {
return;
}
this._severityNumber = severityNumber;
},
enumerable: false,
configurable: true
});
Object.defineProperty(LogRecord.prototype, "body", {
get: function () {
return this._body;
},
set: function (body) {
if (this._isLogRecordReadonly()) {
return;
}
this._body = body;
},
enumerable: false,
configurable: true
});
Object.defineProperty(LogRecord.prototype, "droppedAttributesCount", {
get: function () {
return this.totalAttributesCount - Object.keys(this.attributes).length;
},
enumerable: false,
configurable: true
});
LogRecord.prototype.setAttribute = function (key, value) {
if (this._isLogRecordReadonly()) {
return this;
}
if (value === null) {
return this;
}
if (key.length === 0) {
api.diag.warn("Invalid attribute key: " + key);
return this;
}
if (!isAttributeValue(value) &&
!(typeof value === 'object' &&
!Array.isArray(value) &&
Object.keys(value).length > 0)) {
api.diag.warn("Invalid attribute value set for key: " + key);
return this;
}
this.totalAttributesCount += 1;
if (Object.keys(this.attributes).length >=
this._logRecordLimits.attributeCountLimit &&
!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
// This logic is to create drop message at most once per LogRecord to prevent excessive logging.
if (this.droppedAttributesCount === 1) {
api.diag.warn('Dropping extra attributes.');
}
return this;
}
if (isAttributeValue(value)) {
this.attributes[key] = this._truncateToSize(value);
}
else {
this.attributes[key] = value;
}
return this;
};
LogRecord.prototype.setAttributes = function (attributes) {
var e_1, _a;
try {
for (var _b = __values(Object.entries(attributes)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), k = _d[0], v = _d[1];
this.setAttribute(k, v);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
return this;
};
LogRecord.prototype.setBody = function (body) {
this.body = body;
return this;
};
LogRecord.prototype.setSeverityNumber = function (severityNumber) {
this.severityNumber = severityNumber;
return this;
};
LogRecord.prototype.setSeverityText = function (severityText) {
this.severityText = severityText;
return this;
};
/**
* @internal
* A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.
* If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.
*/
LogRecord.prototype._makeReadonly = function () {
this._isReadonly = true;
};
LogRecord.prototype._truncateToSize = function (value) {
var _this = this;
var limit = this._logRecordLimits.attributeValueLengthLimit;
// Check limit
if (limit <= 0) {
// Negative values are invalid, so do not truncate
api.diag.warn("Attribute value limit must be positive, got " + limit);
return value;
}
// String
if (typeof value === 'string') {
return this._truncateToLimitUtil(value, limit);
}
// Array of strings
if (Array.isArray(value)) {
return value.map(function (val) {
return typeof val === 'string' ? _this._truncateToLimitUtil(val, limit) : val;
});
}
// Other types, no need to apply value length limit
return value;
};
LogRecord.prototype._truncateToLimitUtil = function (value, limit) {
if (value.length <= limit) {
return value;
}
return value.substring(0, limit);
};
LogRecord.prototype._isLogRecordReadonly = function () {
if (this._isReadonly) {
diag.warn('Can not execute the operation on emitted log record');
}
return this._isReadonly;
};
return LogRecord;
}());
export { LogRecord };
//# sourceMappingURL=LogRecord.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import { Context } from '@opentelemetry/api';
import { LogRecord } from './LogRecord';
export interface LogRecordProcessor {
/**
* Forces to export all finished log records
*/
forceFlush(): Promise<void>;
/**
* Called when a {@link LogRecord} is emit
* @param logRecord the ReadWriteLogRecord that just emitted.
* @param context the current Context, or an empty Context if the Logger was obtained with include_trace_context=false
*/
onEmit(logRecord: LogRecord, context?: Context): void;
/**
* Shuts down the processor. Called when SDK is shut down. This is an
* opportunity for processor to do any cleanup required.
*/
shutdown(): Promise<void>;
}
//# sourceMappingURL=LogRecordProcessor.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"LogRecordProcessor.js","sourceRoot":"","sources":["../../src/LogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context } from '@opentelemetry/api';\n\nimport { LogRecord } from './LogRecord';\n\nexport interface LogRecordProcessor {\n /**\n * Forces to export all finished log records\n */\n forceFlush(): Promise<void>;\n\n /**\n * Called when a {@link LogRecord} is emit\n * @param logRecord the ReadWriteLogRecord that just emitted.\n * @param context the current Context, or an empty Context if the Logger was obtained with include_trace_context=false\n */\n onEmit(logRecord: LogRecord, context?: Context): void;\n\n /**\n * Shuts down the processor. Called when SDK is shut down. This is an\n * opportunity for processor to do any cleanup required.\n */\n shutdown(): Promise<void>;\n}\n"]}

View File

@@ -0,0 +1,10 @@
import type * as logsAPI from '@opentelemetry/api-logs';
import type { InstrumentationScope } from '@opentelemetry/core';
import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';
export declare class Logger implements logsAPI.Logger {
readonly instrumentationScope: InstrumentationScope;
private _sharedState;
constructor(instrumentationScope: InstrumentationScope, _sharedState: LoggerProviderSharedState);
emit(logRecord: logsAPI.LogRecord): void;
}
//# sourceMappingURL=Logger.d.ts.map

View File

@@ -0,0 +1,56 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { context } from '@opentelemetry/api';
import { LogRecord } from './LogRecord';
var Logger = /** @class */ (function () {
function Logger(instrumentationScope, _sharedState) {
this.instrumentationScope = instrumentationScope;
this._sharedState = _sharedState;
}
Logger.prototype.emit = function (logRecord) {
var currentContext = logRecord.context || context.active();
/**
* If a Logger was obtained with include_trace_context=true,
* the LogRecords it emits MUST automatically include the Trace Context from the active Context,
* if Context has not been explicitly set.
*/
var logRecordInstance = new LogRecord(this._sharedState, this.instrumentationScope, __assign({ context: currentContext }, logRecord));
/**
* the explicitly passed Context,
* the current Context, or an empty Context if the Logger was obtained with include_trace_context=false
*/
this._sharedState.activeProcessor.onEmit(logRecordInstance, currentContext);
/**
* A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.
* If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.
*/
logRecordInstance._makeReadonly();
};
return Logger;
}());
export { Logger };
//# sourceMappingURL=Logger.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;IACE,gBACkB,oBAA0C,EAClD,YAAuC;QAD/B,yBAAoB,GAApB,oBAAoB,CAAsB;QAClD,iBAAY,GAAZ,YAAY,CAA2B;IAC9C,CAAC;IAEG,qBAAI,GAAX,UAAY,SAA4B;QACtC,IAAM,cAAc,GAAG,SAAS,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QAC7D;;;;WAIG;QACH,IAAM,iBAAiB,GAAG,IAAI,SAAS,CACrC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,oBAAoB,aAEvB,OAAO,EAAE,cAAc,IACpB,SAAS,EAEf,CAAC;QACF;;;WAGG;QACH,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;QAC5E;;;WAGG;QACH,iBAAiB,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC;IACH,aAAC;AAAD,CAAC,AAhCD,IAgCC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as logsAPI from '@opentelemetry/api-logs';\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport { context } from '@opentelemetry/api';\n\nimport { LogRecord } from './LogRecord';\nimport { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';\n\nexport class Logger implements logsAPI.Logger {\n constructor(\n public readonly instrumentationScope: InstrumentationScope,\n private _sharedState: LoggerProviderSharedState\n ) {}\n\n public emit(logRecord: logsAPI.LogRecord): void {\n const currentContext = logRecord.context || context.active();\n /**\n * If a Logger was obtained with include_trace_context=true,\n * the LogRecords it emits MUST automatically include the Trace Context from the active Context,\n * if Context has not been explicitly set.\n */\n const logRecordInstance = new LogRecord(\n this._sharedState,\n this.instrumentationScope,\n {\n context: currentContext,\n ...logRecord,\n }\n );\n /**\n * the explicitly passed Context,\n * the current Context, or an empty Context if the Logger was obtained with include_trace_context=false\n */\n this._sharedState.activeProcessor.onEmit(logRecordInstance, currentContext);\n /**\n * A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.\n * If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.\n */\n logRecordInstance._makeReadonly();\n }\n}\n"]}

View File

@@ -0,0 +1,33 @@
import type * as logsAPI from '@opentelemetry/api-logs';
import type { LoggerProviderConfig } from './types';
import type { LogRecordProcessor } from './LogRecordProcessor';
export declare const DEFAULT_LOGGER_NAME = "unknown";
export declare class LoggerProvider implements logsAPI.LoggerProvider {
private _shutdownOnce;
private readonly _sharedState;
constructor(config?: LoggerProviderConfig);
/**
* Get a logger with the configuration of the LoggerProvider.
*/
getLogger(name: string, version?: string, options?: logsAPI.LoggerOptions): logsAPI.Logger;
/**
* Adds a new {@link LogRecordProcessor} to this logger.
* @param processor the new LogRecordProcessor to be added.
*/
addLogRecordProcessor(processor: LogRecordProcessor): void;
/**
* Notifies all registered LogRecordProcessor to flush any buffered data.
*
* Returns a promise which is resolved when all flushes are complete.
*/
forceFlush(): Promise<void>;
/**
* Flush all buffered data and shut down the LoggerProvider and all registered
* LogRecordProcessor.
*
* Returns a promise which is resolved when all flushes are complete.
*/
shutdown(): Promise<void>;
private _shutdown;
}
//# sourceMappingURL=LoggerProvider.d.ts.map

View File

@@ -0,0 +1,108 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { diag } from '@opentelemetry/api';
import { NOOP_LOGGER } from '@opentelemetry/api-logs';
import { Resource } from '@opentelemetry/resources';
import { BindOnceFuture, merge } from '@opentelemetry/core';
import { Logger } from './Logger';
import { loadDefaultConfig, reconfigureLimits } from './config';
import { MultiLogRecordProcessor } from './MultiLogRecordProcessor';
import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';
export var DEFAULT_LOGGER_NAME = 'unknown';
function prepareResource(mergeWithDefaults, providedResource) {
var resource = providedResource !== null && providedResource !== void 0 ? providedResource : Resource.empty();
if (mergeWithDefaults) {
return Resource.default().merge(resource);
}
return resource;
}
var LoggerProvider = /** @class */ (function () {
function LoggerProvider(config) {
if (config === void 0) { config = {}; }
var mergedConfig = merge({}, loadDefaultConfig(), config);
var resource = prepareResource(mergedConfig.mergeResourceWithDefaults, config.resource);
this._sharedState = new LoggerProviderSharedState(resource, mergedConfig.forceFlushTimeoutMillis, reconfigureLimits(mergedConfig.logRecordLimits));
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
}
/**
* Get a logger with the configuration of the LoggerProvider.
*/
LoggerProvider.prototype.getLogger = function (name, version, options) {
if (this._shutdownOnce.isCalled) {
diag.warn('A shutdown LoggerProvider cannot provide a Logger');
return NOOP_LOGGER;
}
if (!name) {
diag.warn('Logger requested without instrumentation scope name.');
}
var loggerName = name || DEFAULT_LOGGER_NAME;
var key = loggerName + "@" + (version || '') + ":" + ((options === null || options === void 0 ? void 0 : options.schemaUrl) || '');
if (!this._sharedState.loggers.has(key)) {
this._sharedState.loggers.set(key, new Logger({ name: loggerName, version: version, schemaUrl: options === null || options === void 0 ? void 0 : options.schemaUrl }, this._sharedState));
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._sharedState.loggers.get(key);
};
/**
* Adds a new {@link LogRecordProcessor} to this logger.
* @param processor the new LogRecordProcessor to be added.
*/
LoggerProvider.prototype.addLogRecordProcessor = function (processor) {
if (this._sharedState.registeredLogRecordProcessors.length === 0) {
// since we might have enabled by default a batchProcessor, we disable it
// before adding the new one
this._sharedState.activeProcessor
.shutdown()
.catch(function (err) {
return diag.error('Error while trying to shutdown current log record processor', err);
});
}
this._sharedState.registeredLogRecordProcessors.push(processor);
this._sharedState.activeProcessor = new MultiLogRecordProcessor(this._sharedState.registeredLogRecordProcessors, this._sharedState.forceFlushTimeoutMillis);
};
/**
* Notifies all registered LogRecordProcessor to flush any buffered data.
*
* Returns a promise which is resolved when all flushes are complete.
*/
LoggerProvider.prototype.forceFlush = function () {
// do not flush after shutdown
if (this._shutdownOnce.isCalled) {
diag.warn('invalid attempt to force flush after LoggerProvider shutdown');
return this._shutdownOnce.promise;
}
return this._sharedState.activeProcessor.forceFlush();
};
/**
* Flush all buffered data and shut down the LoggerProvider and all registered
* LogRecordProcessor.
*
* Returns a promise which is resolved when all flushes are complete.
*/
LoggerProvider.prototype.shutdown = function () {
if (this._shutdownOnce.isCalled) {
diag.warn('shutdown may only be called once per LoggerProvider');
return this._shutdownOnce.promise;
}
return this._shutdownOnce.call();
};
LoggerProvider.prototype._shutdown = function () {
return this._sharedState.activeProcessor.shutdown();
};
return LoggerProvider;
}());
export { LoggerProvider };
//# sourceMappingURL=LoggerProvider.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
import type { Context } from '@opentelemetry/api';
import type { LogRecordProcessor } from './LogRecordProcessor';
import type { LogRecord } from './LogRecord';
/**
* Implementation of the {@link LogRecordProcessor} that simply forwards all
* received events to a list of {@link LogRecordProcessor}s.
*/
export declare class MultiLogRecordProcessor implements LogRecordProcessor {
readonly processors: LogRecordProcessor[];
readonly forceFlushTimeoutMillis: number;
constructor(processors: LogRecordProcessor[], forceFlushTimeoutMillis: number);
forceFlush(): Promise<void>;
onEmit(logRecord: LogRecord, context?: Context): void;
shutdown(): Promise<void>;
}
//# sourceMappingURL=MultiLogRecordProcessor.d.ts.map

View File

@@ -0,0 +1,99 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { callWithTimeout } from '@opentelemetry/core';
/**
* Implementation of the {@link LogRecordProcessor} that simply forwards all
* received events to a list of {@link LogRecordProcessor}s.
*/
var MultiLogRecordProcessor = /** @class */ (function () {
function MultiLogRecordProcessor(processors, forceFlushTimeoutMillis) {
this.processors = processors;
this.forceFlushTimeoutMillis = forceFlushTimeoutMillis;
}
MultiLogRecordProcessor.prototype.forceFlush = function () {
return __awaiter(this, void 0, void 0, function () {
var timeout;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
timeout = this.forceFlushTimeoutMillis;
return [4 /*yield*/, Promise.all(this.processors.map(function (processor) {
return callWithTimeout(processor.forceFlush(), timeout);
}))];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
MultiLogRecordProcessor.prototype.onEmit = function (logRecord, context) {
this.processors.forEach(function (processors) {
return processors.onEmit(logRecord, context);
});
};
MultiLogRecordProcessor.prototype.shutdown = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.all(this.processors.map(function (processor) { return processor.shutdown(); }))];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
return MultiLogRecordProcessor;
}());
export { MultiLogRecordProcessor };
//# sourceMappingURL=MultiLogRecordProcessor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MultiLogRecordProcessor.js","sourceRoot":"","sources":["../../src/MultiLogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD;;;GAGG;AACH;IACE,iCACkB,UAAgC,EAChC,uBAA+B;QAD/B,eAAU,GAAV,UAAU,CAAsB;QAChC,4BAAuB,GAAvB,uBAAuB,CAAQ;IAC9C,CAAC;IAES,4CAAU,GAAvB;;;;;;wBACQ,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC;wBAC7C,qBAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAA,SAAS;gCAC3B,OAAA,eAAe,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC;4BAAhD,CAAgD,CACjD,CACF,EAAA;;wBAJD,SAIC,CAAC;;;;;KACH;IAEM,wCAAM,GAAb,UAAc,SAAoB,EAAE,OAAiB;QACnD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAA,UAAU;YAChC,OAAA,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC;QAArC,CAAqC,CACtC,CAAC;IACJ,CAAC;IAEY,0CAAQ,GAArB;;;;4BACE,qBAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAA,SAAS,IAAI,OAAA,SAAS,CAAC,QAAQ,EAAE,EAApB,CAAoB,CAAC,CAAC,EAAA;;wBAAzE,SAAyE,CAAC;;;;;KAC3E;IACH,8BAAC;AAAD,CAAC,AAxBD,IAwBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { callWithTimeout } from '@opentelemetry/core';\nimport type { Context } from '@opentelemetry/api';\nimport type { LogRecordProcessor } from './LogRecordProcessor';\nimport type { LogRecord } from './LogRecord';\n\n/**\n * Implementation of the {@link LogRecordProcessor} that simply forwards all\n * received events to a list of {@link LogRecordProcessor}s.\n */\nexport class MultiLogRecordProcessor implements LogRecordProcessor {\n constructor(\n public readonly processors: LogRecordProcessor[],\n public readonly forceFlushTimeoutMillis: number\n ) {}\n\n public async forceFlush(): Promise<void> {\n const timeout = this.forceFlushTimeoutMillis;\n await Promise.all(\n this.processors.map(processor =>\n callWithTimeout(processor.forceFlush(), timeout)\n )\n );\n }\n\n public onEmit(logRecord: LogRecord, context?: Context): void {\n this.processors.forEach(processors =>\n processors.onEmit(logRecord, context)\n );\n }\n\n public async shutdown(): Promise<void> {\n await Promise.all(this.processors.map(processor => processor.shutdown()));\n }\n}\n"]}

View File

@@ -0,0 +1,17 @@
import { LogRecordLimits } from './types';
export declare function loadDefaultConfig(): {
forceFlushTimeoutMillis: number;
logRecordLimits: {
attributeValueLengthLimit: number;
attributeCountLimit: number;
};
includeTraceContext: boolean;
mergeResourceWithDefaults: boolean;
};
/**
* When general limits are provided and model specific limits are not,
* configures the model specific limits by using the values from the general ones.
* @param logRecordLimits User provided limits configuration
*/
export declare function reconfigureLimits(logRecordLimits: LogRecordLimits): Required<LogRecordLimits>;
//# sourceMappingURL=config.d.ts.map

View File

@@ -0,0 +1,47 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, getEnv, getEnvWithoutDefaults, } from '@opentelemetry/core';
export function loadDefaultConfig() {
return {
forceFlushTimeoutMillis: 30000,
logRecordLimits: {
attributeValueLengthLimit: getEnv().OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT,
},
includeTraceContext: true,
mergeResourceWithDefaults: true,
};
}
/**
* When general limits are provided and model specific limits are not,
* configures the model specific limits by using the values from the general ones.
* @param logRecordLimits User provided limits configuration
*/
export function reconfigureLimits(logRecordLimits) {
var _a, _b, _c, _d, _e, _f;
var parsedEnvConfig = getEnvWithoutDefaults();
return {
/**
* Reassign log record attribute count limit to use first non null value defined by user or use default value
*/
attributeCountLimit: (_c = (_b = (_a = logRecordLimits.attributeCountLimit) !== null && _a !== void 0 ? _a : parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT) !== null && _b !== void 0 ? _b : parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT) !== null && _c !== void 0 ? _c : DEFAULT_ATTRIBUTE_COUNT_LIMIT,
/**
* Reassign log record attribute value length limit to use first non null value defined by user or use default value
*/
attributeValueLengthLimit: (_f = (_e = (_d = logRecordLimits.attributeValueLengthLimit) !== null && _d !== void 0 ? _d : parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _e !== void 0 ? _e : parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _f !== void 0 ? _f : DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,
};
}
//# sourceMappingURL=config.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,EACpC,MAAM,EACN,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,uBAAuB,EAAE,KAAK;QAC9B,eAAe,EAAE;YACf,yBAAyB,EACvB,MAAM,EAAE,CAAC,2CAA2C;YACtD,mBAAmB,EAAE,MAAM,EAAE,CAAC,oCAAoC;SACnE;QACD,mBAAmB,EAAE,IAAI;QACzB,yBAAyB,EAAE,IAAI;KAChC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,eAAgC;;IAEhC,IAAM,eAAe,GAAG,qBAAqB,EAAE,CAAC;IAEhD,OAAO;QACL;;WAEG;QACH,mBAAmB,EACjB,MAAA,MAAA,MAAA,eAAe,CAAC,mBAAmB,mCACnC,eAAe,CAAC,oCAAoC,mCACpD,eAAe,CAAC,0BAA0B,mCAC1C,6BAA6B;QAC/B;;WAEG;QACH,yBAAyB,EACvB,MAAA,MAAA,MAAA,eAAe,CAAC,yBAAyB,mCACzC,eAAe,CAAC,2CAA2C,mCAC3D,eAAe,CAAC,iCAAiC,mCACjD,oCAAoC;KACvC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DEFAULT_ATTRIBUTE_COUNT_LIMIT,\n DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,\n getEnv,\n getEnvWithoutDefaults,\n} from '@opentelemetry/core';\nimport { LogRecordLimits } from './types';\n\nexport function loadDefaultConfig() {\n return {\n forceFlushTimeoutMillis: 30000,\n logRecordLimits: {\n attributeValueLengthLimit:\n getEnv().OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT,\n attributeCountLimit: getEnv().OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT,\n },\n includeTraceContext: true,\n mergeResourceWithDefaults: true,\n };\n}\n\n/**\n * When general limits are provided and model specific limits are not,\n * configures the model specific limits by using the values from the general ones.\n * @param logRecordLimits User provided limits configuration\n */\nexport function reconfigureLimits(\n logRecordLimits: LogRecordLimits\n): Required<LogRecordLimits> {\n const parsedEnvConfig = getEnvWithoutDefaults();\n\n return {\n /**\n * Reassign log record attribute count limit to use first non null value defined by user or use default value\n */\n attributeCountLimit:\n logRecordLimits.attributeCountLimit ??\n parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT ??\n parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT ??\n DEFAULT_ATTRIBUTE_COUNT_LIMIT,\n /**\n * Reassign log record attribute value length limit to use first non null value defined by user or use default value\n */\n attributeValueLengthLimit:\n logRecordLimits.attributeValueLengthLimit ??\n parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT ??\n parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ??\n DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,\n };\n}\n"]}

View File

@@ -0,0 +1,33 @@
import type { BufferConfig } from '../types';
import type { LogRecord } from '../LogRecord';
import type { LogRecordExporter } from './LogRecordExporter';
import type { LogRecordProcessor } from '../LogRecordProcessor';
export declare abstract class BatchLogRecordProcessorBase<T extends BufferConfig> implements LogRecordProcessor {
private readonly _exporter;
private readonly _maxExportBatchSize;
private readonly _maxQueueSize;
private readonly _scheduledDelayMillis;
private readonly _exportTimeoutMillis;
private _finishedLogRecords;
private _timer;
private _shutdownOnce;
constructor(_exporter: LogRecordExporter, config?: T);
onEmit(logRecord: LogRecord): void;
forceFlush(): Promise<void>;
shutdown(): Promise<void>;
private _shutdown;
/** Add a LogRecord in the buffer. */
private _addToBuffer;
/**
* Send all LogRecords to the exporter respecting the batch size limit
* This function is used only on forceFlush or shutdown,
* for all other cases _flush should be used
* */
private _flushAll;
private _flushOneBatch;
private _maybeStartTimer;
private _clearTimer;
private _export;
protected abstract onShutdown(): void;
}
//# sourceMappingURL=BatchLogRecordProcessorBase.d.ts.map

View File

@@ -0,0 +1,197 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { diag } from '@opentelemetry/api';
import { ExportResultCode, getEnv, globalErrorHandler, unrefTimer, BindOnceFuture, internal, callWithTimeout, } from '@opentelemetry/core';
var BatchLogRecordProcessorBase = /** @class */ (function () {
function BatchLogRecordProcessorBase(_exporter, config) {
var _a, _b, _c, _d;
this._exporter = _exporter;
this._finishedLogRecords = [];
var env = getEnv();
this._maxExportBatchSize =
(_a = config === null || config === void 0 ? void 0 : config.maxExportBatchSize) !== null && _a !== void 0 ? _a : env.OTEL_BLRP_MAX_EXPORT_BATCH_SIZE;
this._maxQueueSize = (_b = config === null || config === void 0 ? void 0 : config.maxQueueSize) !== null && _b !== void 0 ? _b : env.OTEL_BLRP_MAX_QUEUE_SIZE;
this._scheduledDelayMillis =
(_c = config === null || config === void 0 ? void 0 : config.scheduledDelayMillis) !== null && _c !== void 0 ? _c : env.OTEL_BLRP_SCHEDULE_DELAY;
this._exportTimeoutMillis =
(_d = config === null || config === void 0 ? void 0 : config.exportTimeoutMillis) !== null && _d !== void 0 ? _d : env.OTEL_BLRP_EXPORT_TIMEOUT;
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
if (this._maxExportBatchSize > this._maxQueueSize) {
diag.warn('BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize');
this._maxExportBatchSize = this._maxQueueSize;
}
}
BatchLogRecordProcessorBase.prototype.onEmit = function (logRecord) {
if (this._shutdownOnce.isCalled) {
return;
}
this._addToBuffer(logRecord);
};
BatchLogRecordProcessorBase.prototype.forceFlush = function () {
if (this._shutdownOnce.isCalled) {
return this._shutdownOnce.promise;
}
return this._flushAll();
};
BatchLogRecordProcessorBase.prototype.shutdown = function () {
return this._shutdownOnce.call();
};
BatchLogRecordProcessorBase.prototype._shutdown = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.onShutdown();
return [4 /*yield*/, this._flushAll()];
case 1:
_a.sent();
return [4 /*yield*/, this._exporter.shutdown()];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
};
/** Add a LogRecord in the buffer. */
BatchLogRecordProcessorBase.prototype._addToBuffer = function (logRecord) {
if (this._finishedLogRecords.length >= this._maxQueueSize) {
return;
}
this._finishedLogRecords.push(logRecord);
this._maybeStartTimer();
};
/**
* Send all LogRecords to the exporter respecting the batch size limit
* This function is used only on forceFlush or shutdown,
* for all other cases _flush should be used
* */
BatchLogRecordProcessorBase.prototype._flushAll = function () {
var _this = this;
return new Promise(function (resolve, reject) {
var promises = [];
var batchCount = Math.ceil(_this._finishedLogRecords.length / _this._maxExportBatchSize);
for (var i = 0; i < batchCount; i++) {
promises.push(_this._flushOneBatch());
}
Promise.all(promises)
.then(function () {
resolve();
})
.catch(reject);
});
};
BatchLogRecordProcessorBase.prototype._flushOneBatch = function () {
var _this = this;
this._clearTimer();
if (this._finishedLogRecords.length === 0) {
return Promise.resolve();
}
return new Promise(function (resolve, reject) {
callWithTimeout(_this._export(_this._finishedLogRecords.splice(0, _this._maxExportBatchSize)), _this._exportTimeoutMillis)
.then(function () { return resolve(); })
.catch(reject);
});
};
BatchLogRecordProcessorBase.prototype._maybeStartTimer = function () {
var _this = this;
if (this._timer !== undefined) {
return;
}
this._timer = setTimeout(function () {
_this._flushOneBatch()
.then(function () {
if (_this._finishedLogRecords.length > 0) {
_this._clearTimer();
_this._maybeStartTimer();
}
})
.catch(function (e) {
globalErrorHandler(e);
});
}, this._scheduledDelayMillis);
unrefTimer(this._timer);
};
BatchLogRecordProcessorBase.prototype._clearTimer = function () {
if (this._timer !== undefined) {
clearTimeout(this._timer);
this._timer = undefined;
}
};
BatchLogRecordProcessorBase.prototype._export = function (logRecords) {
var _this = this;
var doExport = function () {
return internal
._export(_this._exporter, logRecords)
.then(function (result) {
var _a;
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler((_a = result.error) !== null && _a !== void 0 ? _a : new Error("BatchLogRecordProcessor: log record export failed (status " + result + ")"));
}
})
.catch(globalErrorHandler);
};
var pendingResources = logRecords
.map(function (logRecord) { return logRecord.resource; })
.filter(function (resource) { return resource.asyncAttributesPending; });
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (pendingResources.length === 0) {
return doExport();
}
else {
return Promise.all(pendingResources.map(function (resource) { var _a; return (_a = resource.waitForAsyncAttributes) === null || _a === void 0 ? void 0 : _a.call(resource); })).then(doExport, globalErrorHandler);
}
};
return BatchLogRecordProcessorBase;
}());
export { BatchLogRecordProcessorBase };
//# sourceMappingURL=BatchLogRecordProcessorBase.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
import { ExportResult } from '@opentelemetry/core';
import type { ReadableLogRecord } from './ReadableLogRecord';
import type { LogRecordExporter } from './LogRecordExporter';
/**
* This is implementation of {@link LogRecordExporter} that prints LogRecords to the
* console. This class can be used for diagnostic purposes.
*
* NOTE: This {@link LogRecordExporter} is intended for diagnostics use only, output rendered to the console may change at any time.
*/
export declare class ConsoleLogRecordExporter implements LogRecordExporter {
/**
* Export logs.
* @param logs
* @param resultCallback
*/
export(logs: ReadableLogRecord[], resultCallback: (result: ExportResult) => void): void;
/**
* Shutdown the exporter.
*/
shutdown(): Promise<void>;
/**
* converts logRecord info into more readable format
* @param logRecord
*/
private _exportInfo;
/**
* Showing logs in console
* @param logRecords
* @param done
*/
private _sendLogRecords;
}
//# sourceMappingURL=ConsoleLogRecordExporter.d.ts.map

View File

@@ -0,0 +1,99 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
import { hrTimeToMicroseconds } from '@opentelemetry/core';
import { ExportResultCode } from '@opentelemetry/core';
/**
* This is implementation of {@link LogRecordExporter} that prints LogRecords to the
* console. This class can be used for diagnostic purposes.
*
* NOTE: This {@link LogRecordExporter} is intended for diagnostics use only, output rendered to the console may change at any time.
*/
/* eslint-disable no-console */
var ConsoleLogRecordExporter = /** @class */ (function () {
function ConsoleLogRecordExporter() {
}
/**
* Export logs.
* @param logs
* @param resultCallback
*/
ConsoleLogRecordExporter.prototype.export = function (logs, resultCallback) {
this._sendLogRecords(logs, resultCallback);
};
/**
* Shutdown the exporter.
*/
ConsoleLogRecordExporter.prototype.shutdown = function () {
return Promise.resolve();
};
/**
* converts logRecord info into more readable format
* @param logRecord
*/
ConsoleLogRecordExporter.prototype._exportInfo = function (logRecord) {
var _a, _b, _c;
return {
resource: {
attributes: logRecord.resource.attributes,
},
instrumentationScope: logRecord.instrumentationScope,
timestamp: hrTimeToMicroseconds(logRecord.hrTime),
traceId: (_a = logRecord.spanContext) === null || _a === void 0 ? void 0 : _a.traceId,
spanId: (_b = logRecord.spanContext) === null || _b === void 0 ? void 0 : _b.spanId,
traceFlags: (_c = logRecord.spanContext) === null || _c === void 0 ? void 0 : _c.traceFlags,
severityText: logRecord.severityText,
severityNumber: logRecord.severityNumber,
body: logRecord.body,
attributes: logRecord.attributes,
};
};
/**
* Showing logs in console
* @param logRecords
* @param done
*/
ConsoleLogRecordExporter.prototype._sendLogRecords = function (logRecords, done) {
var e_1, _a;
try {
for (var logRecords_1 = __values(logRecords), logRecords_1_1 = logRecords_1.next(); !logRecords_1_1.done; logRecords_1_1 = logRecords_1.next()) {
var logRecord = logRecords_1_1.value;
console.dir(this._exportInfo(logRecord), { depth: 3 });
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (logRecords_1_1 && !logRecords_1_1.done && (_a = logRecords_1.return)) _a.call(logRecords_1);
}
finally { if (e_1) throw e_1.error; }
}
done === null || done === void 0 ? void 0 : done({ code: ExportResultCode.SUCCESS });
};
return ConsoleLogRecordExporter;
}());
export { ConsoleLogRecordExporter };
//# sourceMappingURL=ConsoleLogRecordExporter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConsoleLogRecordExporter.js","sourceRoot":"","sources":["../../../src/export/ConsoleLogRecordExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,OAAO,EAAgB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;;GAKG;AAEH,+BAA+B;AAC/B;IAAA;IAuDA,CAAC;IAtDC;;;;OAIG;IACI,yCAAM,GAAb,UACE,IAAyB,EACzB,cAA8C;QAE9C,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,2CAAQ,GAAf;QACE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACK,8CAAW,GAAnB,UAAoB,SAA4B;;QAC9C,OAAO;YACL,QAAQ,EAAE;gBACR,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,UAAU;aAC1C;YACD,oBAAoB,EAAE,SAAS,CAAC,oBAAoB;YACpD,SAAS,EAAE,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC;YACjD,OAAO,EAAE,MAAA,SAAS,CAAC,WAAW,0CAAE,OAAO;YACvC,MAAM,EAAE,MAAA,SAAS,CAAC,WAAW,0CAAE,MAAM;YACrC,UAAU,EAAE,MAAA,SAAS,CAAC,WAAW,0CAAE,UAAU;YAC7C,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,cAAc,EAAE,SAAS,CAAC,cAAc;YACxC,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,UAAU,EAAE,SAAS,CAAC,UAAU;SACjC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACK,kDAAe,GAAvB,UACE,UAA+B,EAC/B,IAAqC;;;YAErC,KAAwB,IAAA,eAAA,SAAA,UAAU,CAAA,sCAAA,8DAAE;gBAA/B,IAAM,SAAS,uBAAA;gBAClB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;aACxD;;;;;;;;;QACD,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;IACH,+BAAC;AAAD,CAAC,AAvDD,IAuDC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExportResult, hrTimeToMicroseconds } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\nimport type { LogRecordExporter } from './LogRecordExporter';\n\n/**\n * This is implementation of {@link LogRecordExporter} that prints LogRecords to the\n * console. This class can be used for diagnostic purposes.\n *\n * NOTE: This {@link LogRecordExporter} is intended for diagnostics use only, output rendered to the console may change at any time.\n */\n\n/* eslint-disable no-console */\nexport class ConsoleLogRecordExporter implements LogRecordExporter {\n /**\n * Export logs.\n * @param logs\n * @param resultCallback\n */\n public export(\n logs: ReadableLogRecord[],\n resultCallback: (result: ExportResult) => void\n ) {\n this._sendLogRecords(logs, resultCallback);\n }\n\n /**\n * Shutdown the exporter.\n */\n public shutdown(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * converts logRecord info into more readable format\n * @param logRecord\n */\n private _exportInfo(logRecord: ReadableLogRecord) {\n return {\n resource: {\n attributes: logRecord.resource.attributes,\n },\n instrumentationScope: logRecord.instrumentationScope,\n timestamp: hrTimeToMicroseconds(logRecord.hrTime),\n traceId: logRecord.spanContext?.traceId,\n spanId: logRecord.spanContext?.spanId,\n traceFlags: logRecord.spanContext?.traceFlags,\n severityText: logRecord.severityText,\n severityNumber: logRecord.severityNumber,\n body: logRecord.body,\n attributes: logRecord.attributes,\n };\n }\n\n /**\n * Showing logs in console\n * @param logRecords\n * @param done\n */\n private _sendLogRecords(\n logRecords: ReadableLogRecord[],\n done?: (result: ExportResult) => void\n ): void {\n for (const logRecord of logRecords) {\n console.dir(this._exportInfo(logRecord), { depth: 3 });\n }\n done?.({ code: ExportResultCode.SUCCESS });\n }\n}\n"]}

View File

@@ -0,0 +1,21 @@
import type { ExportResult } from '@opentelemetry/core';
import type { ReadableLogRecord } from './ReadableLogRecord';
import type { LogRecordExporter } from './LogRecordExporter';
/**
* This class can be used for testing purposes. It stores the exported LogRecords
* in a list in memory that can be retrieved using the `getFinishedLogRecords()`
* method.
*/
export declare class InMemoryLogRecordExporter implements LogRecordExporter {
private _finishedLogRecords;
/**
* Indicates if the exporter has been "shutdown."
* When false, exported log records will not be stored in-memory.
*/
protected _stopped: boolean;
export(logs: ReadableLogRecord[], resultCallback: (result: ExportResult) => void): void;
shutdown(): Promise<void>;
getFinishedLogRecords(): ReadableLogRecord[];
reset(): void;
}
//# sourceMappingURL=InMemoryLogRecordExporter.d.ts.map

View File

@@ -0,0 +1,81 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import { ExportResultCode } from '@opentelemetry/core';
/**
* This class can be used for testing purposes. It stores the exported LogRecords
* in a list in memory that can be retrieved using the `getFinishedLogRecords()`
* method.
*/
var InMemoryLogRecordExporter = /** @class */ (function () {
function InMemoryLogRecordExporter() {
this._finishedLogRecords = [];
/**
* Indicates if the exporter has been "shutdown."
* When false, exported log records will not be stored in-memory.
*/
this._stopped = false;
}
InMemoryLogRecordExporter.prototype.export = function (logs, resultCallback) {
var _a;
if (this._stopped) {
return resultCallback({
code: ExportResultCode.FAILED,
error: new Error('Exporter has been stopped'),
});
}
(_a = this._finishedLogRecords).push.apply(_a, __spreadArray([], __read(logs), false));
resultCallback({ code: ExportResultCode.SUCCESS });
};
InMemoryLogRecordExporter.prototype.shutdown = function () {
this._stopped = true;
this.reset();
return Promise.resolve();
};
InMemoryLogRecordExporter.prototype.getFinishedLogRecords = function () {
return this._finishedLogRecords;
};
InMemoryLogRecordExporter.prototype.reset = function () {
this._finishedLogRecords = [];
};
return InMemoryLogRecordExporter;
}());
export { InMemoryLogRecordExporter };
//# sourceMappingURL=InMemoryLogRecordExporter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"InMemoryLogRecordExporter.js","sourceRoot":"","sources":["../../../src/export/InMemoryLogRecordExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;GAIG;AACH;IAAA;QACU,wBAAmB,GAAwB,EAAE,CAAC;QAEtD;;;WAGG;QACO,aAAQ,GAAG,KAAK,CAAC;IA8B7B,CAAC;IA5BQ,0CAAM,GAAb,UACE,IAAyB,EACzB,cAA8C;;QAE9C,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,cAAc,CAAC;gBACpB,IAAI,EAAE,gBAAgB,CAAC,MAAM;gBAC7B,KAAK,EAAE,IAAI,KAAK,CAAC,2BAA2B,CAAC;aAC9C,CAAC,CAAC;SACJ;QAED,CAAA,KAAA,IAAI,CAAC,mBAAmB,CAAA,CAAC,IAAI,oCAAI,IAAI,WAAE;QACvC,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,4CAAQ,GAAf;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEM,yDAAqB,GAA5B;QACE,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAEM,yCAAK,GAAZ;QACE,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;IAChC,CAAC;IACH,gCAAC;AAAD,CAAC,AArCD,IAqCC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\nimport type { LogRecordExporter } from './LogRecordExporter';\n\n/**\n * This class can be used for testing purposes. It stores the exported LogRecords\n * in a list in memory that can be retrieved using the `getFinishedLogRecords()`\n * method.\n */\nexport class InMemoryLogRecordExporter implements LogRecordExporter {\n private _finishedLogRecords: ReadableLogRecord[] = [];\n\n /**\n * Indicates if the exporter has been \"shutdown.\"\n * When false, exported log records will not be stored in-memory.\n */\n protected _stopped = false;\n\n public export(\n logs: ReadableLogRecord[],\n resultCallback: (result: ExportResult) => void\n ) {\n if (this._stopped) {\n return resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been stopped'),\n });\n }\n\n this._finishedLogRecords.push(...logs);\n resultCallback({ code: ExportResultCode.SUCCESS });\n }\n\n public shutdown(): Promise<void> {\n this._stopped = true;\n this.reset();\n return Promise.resolve();\n }\n\n public getFinishedLogRecords(): ReadableLogRecord[] {\n return this._finishedLogRecords;\n }\n\n public reset(): void {\n this._finishedLogRecords = [];\n }\n}\n"]}

View File

@@ -0,0 +1,12 @@
import type { ExportResult } from '@opentelemetry/core';
import type { ReadableLogRecord } from './ReadableLogRecord';
export interface LogRecordExporter {
/**
* Called to export {@link ReadableLogRecord}s.
* @param logs the list of sampled LogRecords to be exported.
*/
export(logs: ReadableLogRecord[], resultCallback: (result: ExportResult) => void): void;
/** Stops the exporter. */
shutdown(): Promise<void>;
}
//# sourceMappingURL=LogRecordExporter.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"LogRecordExporter.js","sourceRoot":"","sources":["../../../src/export/LogRecordExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\n\nexport interface LogRecordExporter {\n /**\n * Called to export {@link ReadableLogRecord}s.\n * @param logs the list of sampled LogRecords to be exported.\n */\n export(\n logs: ReadableLogRecord[],\n resultCallback: (result: ExportResult) => void\n ): void;\n\n /** Stops the exporter. */\n shutdown(): Promise<void>;\n}\n"]}

View File

@@ -0,0 +1,9 @@
import { Context } from '@opentelemetry/api';
import { LogRecordProcessor } from '../LogRecordProcessor';
import { ReadableLogRecord } from './ReadableLogRecord';
export declare class NoopLogRecordProcessor implements LogRecordProcessor {
forceFlush(): Promise<void>;
onEmit(_logRecord: ReadableLogRecord, _context: Context): void;
shutdown(): Promise<void>;
}
//# sourceMappingURL=NoopLogRecordProcessor.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"NoopLogRecordProcessor.js","sourceRoot":"","sources":["../../../src/export/NoopLogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH;IAAA;IAUA,CAAC;IATC,2CAAU,GAAV;QACE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,uCAAM,GAAN,UAAO,UAA6B,EAAE,QAAiB,IAAS,CAAC;IAEjE,yCAAQ,GAAR;QACE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACH,6BAAC;AAAD,CAAC,AAVD,IAUC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context } from '@opentelemetry/api';\nimport { LogRecordProcessor } from '../LogRecordProcessor';\nimport { ReadableLogRecord } from './ReadableLogRecord';\n\nexport class NoopLogRecordProcessor implements LogRecordProcessor {\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n onEmit(_logRecord: ReadableLogRecord, _context: Context): void {}\n\n shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n"]}

View File

@@ -0,0 +1,17 @@
import type { IResource } from '@opentelemetry/resources';
import type { HrTime, SpanContext } from '@opentelemetry/api';
import type { InstrumentationScope } from '@opentelemetry/core';
import type { LogBody, LogAttributes, SeverityNumber } from '@opentelemetry/api-logs';
export interface ReadableLogRecord {
readonly hrTime: HrTime;
readonly hrTimeObserved: HrTime;
readonly spanContext?: SpanContext;
readonly severityText?: string;
readonly severityNumber?: SeverityNumber;
readonly body?: LogBody;
readonly resource: IResource;
readonly instrumentationScope: InstrumentationScope;
readonly attributes: LogAttributes;
readonly droppedAttributesCount: number;
}
//# sourceMappingURL=ReadableLogRecord.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"ReadableLogRecord.js","sourceRoot":"","sources":["../../../src/export/ReadableLogRecord.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { IResource } from '@opentelemetry/resources';\nimport type { HrTime, SpanContext } from '@opentelemetry/api';\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport type {\n LogBody,\n LogAttributes,\n SeverityNumber,\n} from '@opentelemetry/api-logs';\n\nexport interface ReadableLogRecord {\n readonly hrTime: HrTime;\n readonly hrTimeObserved: HrTime;\n readonly spanContext?: SpanContext;\n readonly severityText?: string;\n readonly severityNumber?: SeverityNumber;\n readonly body?: LogBody;\n readonly resource: IResource;\n readonly instrumentationScope: InstrumentationScope;\n readonly attributes: LogAttributes;\n readonly droppedAttributesCount: number;\n}\n"]}

View File

@@ -0,0 +1,14 @@
import type { LogRecordExporter } from './LogRecordExporter';
import type { LogRecordProcessor } from '../LogRecordProcessor';
import type { LogRecord } from './../LogRecord';
export declare class SimpleLogRecordProcessor implements LogRecordProcessor {
private readonly _exporter;
private _shutdownOnce;
private _unresolvedExports;
constructor(_exporter: LogRecordExporter);
onEmit(logRecord: LogRecord): void;
forceFlush(): Promise<void>;
shutdown(): Promise<void>;
private _shutdown;
}
//# sourceMappingURL=SimpleLogRecordProcessor.d.ts.map

View File

@@ -0,0 +1,118 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { BindOnceFuture, ExportResultCode, globalErrorHandler, internal, } from '@opentelemetry/core';
var SimpleLogRecordProcessor = /** @class */ (function () {
function SimpleLogRecordProcessor(_exporter) {
this._exporter = _exporter;
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
this._unresolvedExports = new Set();
}
SimpleLogRecordProcessor.prototype.onEmit = function (logRecord) {
var _this = this;
var _a, _b;
if (this._shutdownOnce.isCalled) {
return;
}
var doExport = function () {
return internal
._export(_this._exporter, [logRecord])
.then(function (result) {
var _a;
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler((_a = result.error) !== null && _a !== void 0 ? _a : new Error("SimpleLogRecordProcessor: log record export failed (status " + result + ")"));
}
})
.catch(globalErrorHandler);
};
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (logRecord.resource.asyncAttributesPending) {
var exportPromise_1 = (_b = (_a = logRecord.resource).waitForAsyncAttributes) === null || _b === void 0 ? void 0 : _b.call(_a).then(function () {
// Using TS Non-null assertion operator because exportPromise could not be null in here
// if waitForAsyncAttributes is not present this code will never be reached
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_this._unresolvedExports.delete(exportPromise_1);
return doExport();
}, globalErrorHandler);
// store the unresolved exports
if (exportPromise_1 != null) {
this._unresolvedExports.add(exportPromise_1);
}
}
else {
void doExport();
}
};
SimpleLogRecordProcessor.prototype.forceFlush = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// await unresolved resources before resolving
return [4 /*yield*/, Promise.all(Array.from(this._unresolvedExports))];
case 1:
// await unresolved resources before resolving
_a.sent();
return [2 /*return*/];
}
});
});
};
SimpleLogRecordProcessor.prototype.shutdown = function () {
return this._shutdownOnce.call();
};
SimpleLogRecordProcessor.prototype._shutdown = function () {
return this._exporter.shutdown();
};
return SimpleLogRecordProcessor;
}());
export { SimpleLogRecordProcessor };
//# sourceMappingURL=SimpleLogRecordProcessor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SimpleLogRecordProcessor.js","sourceRoot":"","sources":["../../../src/export/SimpleLogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAK7B;IAIE,kCAA6B,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;QACvD,IAAI,CAAC,aAAa,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,kBAAkB,GAAG,IAAI,GAAG,EAAiB,CAAC;IACrD,CAAC;IAEM,yCAAM,GAAb,UAAc,SAAoB;QAAlC,iBAuCC;;QAtCC,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC/B,OAAO;SACR;QAED,IAAM,QAAQ,GAAG;YACf,OAAA,QAAQ;iBACL,OAAO,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC;iBACpC,IAAI,CAAC,UAAC,MAAoB;;gBACzB,IAAI,MAAM,CAAC,IAAI,KAAK,gBAAgB,CAAC,OAAO,EAAE;oBAC5C,kBAAkB,CAChB,MAAA,MAAM,CAAC,KAAK,mCACV,IAAI,KAAK,CACP,gEAA8D,MAAM,MAAG,CACxE,CACJ,CAAC;iBACH;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,kBAAkB,CAAC;QAZ5B,CAY4B,CAAC;QAE/B,sFAAsF;QACtF,IAAI,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE;YAC7C,IAAM,eAAa,GAAG,MAAA,MAAA,SAAS,CAAC,QAAQ,EACrC,sBAAsB,mDACtB,IAAI,CAAC;gBACJ,uFAAuF;gBACvF,2EAA2E;gBAC3E,oEAAoE;gBACpE,KAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,eAAc,CAAC,CAAC;gBAC/C,OAAO,QAAQ,EAAE,CAAC;YACpB,CAAC,EAAE,kBAAkB,CAAC,CAAC;YAEzB,+BAA+B;YAC/B,IAAI,eAAa,IAAI,IAAI,EAAE;gBACzB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,eAAa,CAAC,CAAC;aAC5C;SACF;aAAM;YACL,KAAK,QAAQ,EAAE,CAAC;SACjB;IACH,CAAC;IAEY,6CAAU,GAAvB;;;;;oBACE,8CAA8C;oBAC9C,qBAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAA;;wBADtD,8CAA8C;wBAC9C,SAAsD,CAAC;;;;;KACxD;IAEM,2CAAQ,GAAf;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAEO,4CAAS,GAAjB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IACH,+BAAC;AAAD,CAAC,AA9DD,IA8DC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport {\n BindOnceFuture,\n ExportResultCode,\n globalErrorHandler,\n internal,\n} from '@opentelemetry/core';\nimport type { LogRecordExporter } from './LogRecordExporter';\nimport type { LogRecordProcessor } from '../LogRecordProcessor';\nimport type { LogRecord } from './../LogRecord';\n\nexport class SimpleLogRecordProcessor implements LogRecordProcessor {\n private _shutdownOnce: BindOnceFuture<void>;\n private _unresolvedExports: Set<Promise<void>>;\n\n constructor(private readonly _exporter: LogRecordExporter) {\n this._shutdownOnce = new BindOnceFuture(this._shutdown, this);\n this._unresolvedExports = new Set<Promise<void>>();\n }\n\n public onEmit(logRecord: LogRecord): void {\n if (this._shutdownOnce.isCalled) {\n return;\n }\n\n const doExport = () =>\n internal\n ._export(this._exporter, [logRecord])\n .then((result: ExportResult) => {\n if (result.code !== ExportResultCode.SUCCESS) {\n globalErrorHandler(\n result.error ??\n new Error(\n `SimpleLogRecordProcessor: log record export failed (status ${result})`\n )\n );\n }\n })\n .catch(globalErrorHandler);\n\n // Avoid scheduling a promise to make the behavior more predictable and easier to test\n if (logRecord.resource.asyncAttributesPending) {\n const exportPromise = logRecord.resource\n .waitForAsyncAttributes?.()\n .then(() => {\n // Using TS Non-null assertion operator because exportPromise could not be null in here\n // if waitForAsyncAttributes is not present this code will never be reached\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._unresolvedExports.delete(exportPromise!);\n return doExport();\n }, globalErrorHandler);\n\n // store the unresolved exports\n if (exportPromise != null) {\n this._unresolvedExports.add(exportPromise);\n }\n } else {\n void doExport();\n }\n }\n\n public async forceFlush(): Promise<void> {\n // await unresolved resources before resolving\n await Promise.all(Array.from(this._unresolvedExports));\n }\n\n public shutdown(): Promise<void> {\n return this._shutdownOnce.call();\n }\n\n private _shutdown(): Promise<void> {\n return this._exporter.shutdown();\n }\n}\n"]}

View File

@@ -0,0 +1,12 @@
export { LoggerProviderConfig, LogRecordLimits, BufferConfig, BatchLogRecordProcessorBrowserConfig, } from './types';
export { LoggerProvider } from './LoggerProvider';
export { LogRecord } from './LogRecord';
export { LogRecordProcessor } from './LogRecordProcessor';
export { ReadableLogRecord } from './export/ReadableLogRecord';
export { NoopLogRecordProcessor } from './export/NoopLogRecordProcessor';
export { ConsoleLogRecordExporter } from './export/ConsoleLogRecordExporter';
export { LogRecordExporter } from './export/LogRecordExporter';
export { SimpleLogRecordProcessor } from './export/SimpleLogRecordProcessor';
export { InMemoryLogRecordExporter } from './export/InMemoryLogRecordExporter';
export { BatchLogRecordProcessor } from './platform';
//# sourceMappingURL=index.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport {\n LoggerProviderConfig,\n LogRecordLimits,\n BufferConfig,\n BatchLogRecordProcessorBrowserConfig,\n} from './types';\nexport { LoggerProvider } from './LoggerProvider';\nexport { LogRecord } from './LogRecord';\nexport { LogRecordProcessor } from './LogRecordProcessor';\nexport { ReadableLogRecord } from './export/ReadableLogRecord';\nexport { NoopLogRecordProcessor } from './export/NoopLogRecordProcessor';\nexport { ConsoleLogRecordExporter } from './export/ConsoleLogRecordExporter';\nexport { LogRecordExporter } from './export/LogRecordExporter';\nexport { SimpleLogRecordProcessor } from './export/SimpleLogRecordProcessor';\nexport { InMemoryLogRecordExporter } from './export/InMemoryLogRecordExporter';\nexport { BatchLogRecordProcessor } from './platform';\n"]}

View File

@@ -0,0 +1,14 @@
import { Logger } from '@opentelemetry/api-logs';
import { IResource } from '@opentelemetry/resources';
import { LogRecordProcessor } from '../LogRecordProcessor';
import { LogRecordLimits } from '../types';
export declare class LoggerProviderSharedState {
readonly resource: IResource;
readonly forceFlushTimeoutMillis: number;
readonly logRecordLimits: Required<LogRecordLimits>;
readonly loggers: Map<string, Logger>;
activeProcessor: LogRecordProcessor;
readonly registeredLogRecordProcessors: LogRecordProcessor[];
constructor(resource: IResource, forceFlushTimeoutMillis: number, logRecordLimits: Required<LogRecordLimits>);
}
//# sourceMappingURL=LoggerProviderSharedState.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"LoggerProviderSharedState.js","sourceRoot":"","sources":["../../../src/internal/LoggerProviderSharedState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E;IAKE,mCACW,QAAmB,EACnB,uBAA+B,EAC/B,eAA0C;QAF1C,aAAQ,GAAR,QAAQ,CAAW;QACnB,4BAAuB,GAAvB,uBAAuB,CAAQ;QAC/B,oBAAe,GAAf,eAAe,CAA2B;QAP5C,YAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;QAEzC,kCAA6B,GAAyB,EAAE,CAAC;QAOhE,IAAI,CAAC,eAAe,GAAG,IAAI,sBAAsB,EAAE,CAAC;IACtD,CAAC;IACH,gCAAC;AAAD,CAAC,AAZD,IAYC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Logger } from '@opentelemetry/api-logs';\nimport { IResource } from '@opentelemetry/resources';\nimport { LogRecordProcessor } from '../LogRecordProcessor';\nimport { LogRecordLimits } from '../types';\nimport { NoopLogRecordProcessor } from '../export/NoopLogRecordProcessor';\n\nexport class LoggerProviderSharedState {\n readonly loggers: Map<string, Logger> = new Map();\n activeProcessor: LogRecordProcessor;\n readonly registeredLogRecordProcessors: LogRecordProcessor[] = [];\n\n constructor(\n readonly resource: IResource,\n readonly forceFlushTimeoutMillis: number,\n readonly logRecordLimits: Required<LogRecordLimits>\n ) {\n this.activeProcessor = new NoopLogRecordProcessor();\n }\n}\n"]}

View File

@@ -0,0 +1,11 @@
import type { LogRecordExporter } from './../../../export/LogRecordExporter';
import type { BatchLogRecordProcessorBrowserConfig } from '../../../types';
import { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';
export declare class BatchLogRecordProcessor extends BatchLogRecordProcessorBase<BatchLogRecordProcessorBrowserConfig> {
private _visibilityChangeListener?;
private _pageHideListener?;
constructor(exporter: LogRecordExporter, config?: BatchLogRecordProcessorBrowserConfig);
protected onShutdown(): void;
private _onInit;
}
//# sourceMappingURL=BatchLogRecordProcessor.d.ts.map

View File

@@ -0,0 +1,71 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';
var BatchLogRecordProcessor = /** @class */ (function (_super) {
__extends(BatchLogRecordProcessor, _super);
function BatchLogRecordProcessor(exporter, config) {
var _this = _super.call(this, exporter, config) || this;
_this._onInit(config);
return _this;
}
BatchLogRecordProcessor.prototype.onShutdown = function () {
if (typeof document === 'undefined') {
return;
}
if (this._visibilityChangeListener) {
document.removeEventListener('visibilitychange', this._visibilityChangeListener);
}
if (this._pageHideListener) {
document.removeEventListener('pagehide', this._pageHideListener);
}
};
BatchLogRecordProcessor.prototype._onInit = function (config) {
var _this = this;
if ((config === null || config === void 0 ? void 0 : config.disableAutoFlushOnDocumentHide) === true ||
typeof document === 'undefined') {
return;
}
this._visibilityChangeListener = function () {
if (document.visibilityState === 'hidden') {
void _this.forceFlush();
}
};
this._pageHideListener = function () {
void _this.forceFlush();
};
document.addEventListener('visibilitychange', this._visibilityChangeListener);
// use 'pagehide' event as a fallback for Safari; see https://bugs.webkit.org/show_bug.cgi?id=116769
document.addEventListener('pagehide', this._pageHideListener);
};
return BatchLogRecordProcessor;
}(BatchLogRecordProcessorBase));
export { BatchLogRecordProcessor };
//# sourceMappingURL=BatchLogRecordProcessor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BatchLogRecordProcessor.js","sourceRoot":"","sources":["../../../../../src/platform/browser/export/BatchLogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAIH,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAE1F;IAA6C,2CAAiE;IAI5G,iCACE,QAA2B,EAC3B,MAA6C;QAF/C,YAIE,kBAAM,QAAQ,EAAE,MAAM,CAAC,SAExB;QADC,KAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;;IACvB,CAAC;IAES,4CAAU,GAApB;QACE,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YACnC,OAAO;SACR;QACD,IAAI,IAAI,CAAC,yBAAyB,EAAE;YAClC,QAAQ,CAAC,mBAAmB,CAC1B,kBAAkB,EAClB,IAAI,CAAC,yBAAyB,CAC/B,CAAC;SACH;QACD,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,QAAQ,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;SAClE;IACH,CAAC;IAEO,yCAAO,GAAf,UAAgB,MAA6C;QAA7D,iBAsBC;QArBC,IACE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,8BAA8B,MAAK,IAAI;YAC/C,OAAO,QAAQ,KAAK,WAAW,EAC/B;YACA,OAAO;SACR;QACD,IAAI,CAAC,yBAAyB,GAAG;YAC/B,IAAI,QAAQ,CAAC,eAAe,KAAK,QAAQ,EAAE;gBACzC,KAAK,KAAI,CAAC,UAAU,EAAE,CAAC;aACxB;QACH,CAAC,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG;YACvB,KAAK,KAAI,CAAC,UAAU,EAAE,CAAC;QACzB,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CACvB,kBAAkB,EAClB,IAAI,CAAC,yBAAyB,CAC/B,CAAC;QAEF,oGAAoG;QACpG,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC;IACH,8BAAC;AAAD,CAAC,AAlDD,CAA6C,2BAA2B,GAkDvE","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { LogRecordExporter } from './../../../export/LogRecordExporter';\nimport type { BatchLogRecordProcessorBrowserConfig } from '../../../types';\nimport { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';\n\nexport class BatchLogRecordProcessor extends BatchLogRecordProcessorBase<BatchLogRecordProcessorBrowserConfig> {\n private _visibilityChangeListener?: () => void;\n private _pageHideListener?: () => void;\n\n constructor(\n exporter: LogRecordExporter,\n config?: BatchLogRecordProcessorBrowserConfig\n ) {\n super(exporter, config);\n this._onInit(config);\n }\n\n protected onShutdown(): void {\n if (typeof document === 'undefined') {\n return;\n }\n if (this._visibilityChangeListener) {\n document.removeEventListener(\n 'visibilitychange',\n this._visibilityChangeListener\n );\n }\n if (this._pageHideListener) {\n document.removeEventListener('pagehide', this._pageHideListener);\n }\n }\n\n private _onInit(config?: BatchLogRecordProcessorBrowserConfig): void {\n if (\n config?.disableAutoFlushOnDocumentHide === true ||\n typeof document === 'undefined'\n ) {\n return;\n }\n this._visibilityChangeListener = () => {\n if (document.visibilityState === 'hidden') {\n void this.forceFlush();\n }\n };\n this._pageHideListener = () => {\n void this.forceFlush();\n };\n document.addEventListener(\n 'visibilitychange',\n this._visibilityChangeListener\n );\n\n // use 'pagehide' event as a fallback for Safari; see https://bugs.webkit.org/show_bug.cgi?id=116769\n document.addEventListener('pagehide', this._pageHideListener);\n }\n}\n"]}

View File

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

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { BatchLogRecordProcessor } from './export/BatchLogRecordProcessor';\n"]}

View File

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

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { BatchLogRecordProcessor } from './node';\n"]}

View File

@@ -0,0 +1,6 @@
import type { BufferConfig } from '../../../types';
import { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';
export declare class BatchLogRecordProcessor extends BatchLogRecordProcessorBase<BufferConfig> {
protected onShutdown(): void;
}
//# sourceMappingURL=BatchLogRecordProcessor.d.ts.map

View File

@@ -0,0 +1,41 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';
var BatchLogRecordProcessor = /** @class */ (function (_super) {
__extends(BatchLogRecordProcessor, _super);
function BatchLogRecordProcessor() {
return _super !== null && _super.apply(this, arguments) || this;
}
BatchLogRecordProcessor.prototype.onShutdown = function () { };
return BatchLogRecordProcessor;
}(BatchLogRecordProcessorBase));
export { BatchLogRecordProcessor };
//# sourceMappingURL=BatchLogRecordProcessor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BatchLogRecordProcessor.js","sourceRoot":"","sources":["../../../../../src/platform/node/export/BatchLogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAE1F;IAA6C,2CAAyC;IAAtF;;IAEA,CAAC;IADW,4CAAU,GAApB,cAA8B,CAAC;IACjC,8BAAC;AAAD,CAAC,AAFD,CAA6C,2BAA2B,GAEvE","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { BufferConfig } from '../../../types';\nimport { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';\n\nexport class BatchLogRecordProcessor extends BatchLogRecordProcessorBase<BufferConfig> {\n protected onShutdown(): void {}\n}\n"]}

View File

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

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { BatchLogRecordProcessor } from './export/BatchLogRecordProcessor';\n"]}

View File

@@ -0,0 +1,44 @@
import type { IResource } from '@opentelemetry/resources';
export interface LoggerProviderConfig {
/** Resource associated with trace telemetry */
resource?: IResource;
/**
* How long the forceFlush can run before it is cancelled.
* The default value is 30000ms
*/
forceFlushTimeoutMillis?: number;
/** Log Record Limits*/
logRecordLimits?: LogRecordLimits;
/**
* Merge resource with {@link Resource.default()}?
* Default: {@code true}
*/
mergeResourceWithDefaults?: boolean;
}
export interface LogRecordLimits {
/** attributeValueLengthLimit is maximum allowed attribute value size */
attributeValueLengthLimit?: number;
/** attributeCountLimit is number of attributes per LogRecord */
attributeCountLimit?: number;
}
/** Interface configuration for a buffer. */
export interface BufferConfig {
/** The maximum batch size of every export. It must be smaller or equal to
* maxQueueSize. The default value is 512. */
maxExportBatchSize?: number;
/** The delay interval in milliseconds between two consecutive exports.
* The default value is 5000ms. */
scheduledDelayMillis?: number;
/** How long the export can run before it is cancelled.
* The default value is 30000ms */
exportTimeoutMillis?: number;
/** The maximum queue size. After the size is reached log records are dropped.
* The default value is 2048. */
maxQueueSize?: number;
}
export interface BatchLogRecordProcessorBrowserConfig extends BufferConfig {
/** Disable flush when a user navigates to a new page, closes the tab or the browser, or,
* on mobile, switches to a different app. Auto flush is enabled by default. */
disableAutoFlushOnDocumentHide?: boolean;
}
//# sourceMappingURL=types.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { IResource } from '@opentelemetry/resources';\n\nexport interface LoggerProviderConfig {\n /** Resource associated with trace telemetry */\n resource?: IResource;\n\n /**\n * How long the forceFlush can run before it is cancelled.\n * The default value is 30000ms\n */\n forceFlushTimeoutMillis?: number;\n\n /** Log Record Limits*/\n logRecordLimits?: LogRecordLimits;\n\n /**\n * Merge resource with {@link Resource.default()}?\n * Default: {@code true}\n */\n mergeResourceWithDefaults?: boolean;\n}\n\nexport interface LogRecordLimits {\n /** attributeValueLengthLimit is maximum allowed attribute value size */\n attributeValueLengthLimit?: number;\n\n /** attributeCountLimit is number of attributes per LogRecord */\n attributeCountLimit?: number;\n}\n\n/** Interface configuration for a buffer. */\nexport interface BufferConfig {\n /** The maximum batch size of every export. It must be smaller or equal to\n * maxQueueSize. The default value is 512. */\n maxExportBatchSize?: number;\n\n /** The delay interval in milliseconds between two consecutive exports.\n * The default value is 5000ms. */\n scheduledDelayMillis?: number;\n\n /** How long the export can run before it is cancelled.\n * The default value is 30000ms */\n exportTimeoutMillis?: number;\n\n /** The maximum queue size. After the size is reached log records are dropped.\n * The default value is 2048. */\n maxQueueSize?: number;\n}\n\nexport interface BatchLogRecordProcessorBrowserConfig extends BufferConfig {\n /** Disable flush when a user navigates to a new page, closes the tab or the browser, or,\n * on mobile, switches to a different app. Auto flush is enabled by default. */\n disableAutoFlushOnDocumentHide?: boolean;\n}\n"]}

View File

@@ -0,0 +1,2 @@
export declare const VERSION = "0.57.2";
//# sourceMappingURL=version.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.57.2';\n"]}

View File

@@ -0,0 +1,44 @@
import type * as logsAPI from '@opentelemetry/api-logs';
import * as api from '@opentelemetry/api';
import { InstrumentationScope } from '@opentelemetry/core';
import type { IResource } from '@opentelemetry/resources';
import type { ReadableLogRecord } from './export/ReadableLogRecord';
import { AnyValue, LogAttributes, LogBody } from '@opentelemetry/api-logs';
import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';
export declare class LogRecord implements ReadableLogRecord {
readonly hrTime: api.HrTime;
readonly hrTimeObserved: api.HrTime;
readonly spanContext?: api.SpanContext;
readonly resource: IResource;
readonly instrumentationScope: InstrumentationScope;
readonly attributes: logsAPI.LogAttributes;
private _severityText?;
private _severityNumber?;
private _body?;
private totalAttributesCount;
private _isReadonly;
private readonly _logRecordLimits;
set severityText(severityText: string | undefined);
get severityText(): string | undefined;
set severityNumber(severityNumber: logsAPI.SeverityNumber | undefined);
get severityNumber(): logsAPI.SeverityNumber | undefined;
set body(body: LogBody | undefined);
get body(): LogBody | undefined;
get droppedAttributesCount(): number;
constructor(_sharedState: LoggerProviderSharedState, instrumentationScope: InstrumentationScope, logRecord: logsAPI.LogRecord);
setAttribute(key: string, value?: AnyValue): this;
setAttributes(attributes: LogAttributes): this;
setBody(body: LogBody): this;
setSeverityNumber(severityNumber: logsAPI.SeverityNumber): this;
setSeverityText(severityText: string): this;
/**
* @internal
* A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.
* If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.
*/
_makeReadonly(): void;
private _truncateToSize;
private _truncateToLimitUtil;
private _isLogRecordReadonly;
}
//# sourceMappingURL=LogRecord.d.ts.map

View File

@@ -0,0 +1,166 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { diag } from '@opentelemetry/api';
import * as api from '@opentelemetry/api';
import { timeInputToHrTime, isAttributeValue, } from '@opentelemetry/core';
export class LogRecord {
constructor(_sharedState, instrumentationScope, logRecord) {
this.attributes = {};
this.totalAttributesCount = 0;
this._isReadonly = false;
const { timestamp, observedTimestamp, severityNumber, severityText, body, attributes = {}, context, } = logRecord;
const now = Date.now();
this.hrTime = timeInputToHrTime(timestamp !== null && timestamp !== void 0 ? timestamp : now);
this.hrTimeObserved = timeInputToHrTime(observedTimestamp !== null && observedTimestamp !== void 0 ? observedTimestamp : now);
if (context) {
const spanContext = api.trace.getSpanContext(context);
if (spanContext && api.isSpanContextValid(spanContext)) {
this.spanContext = spanContext;
}
}
this.severityNumber = severityNumber;
this.severityText = severityText;
this.body = body;
this.resource = _sharedState.resource;
this.instrumentationScope = instrumentationScope;
this._logRecordLimits = _sharedState.logRecordLimits;
this.setAttributes(attributes);
}
set severityText(severityText) {
if (this._isLogRecordReadonly()) {
return;
}
this._severityText = severityText;
}
get severityText() {
return this._severityText;
}
set severityNumber(severityNumber) {
if (this._isLogRecordReadonly()) {
return;
}
this._severityNumber = severityNumber;
}
get severityNumber() {
return this._severityNumber;
}
set body(body) {
if (this._isLogRecordReadonly()) {
return;
}
this._body = body;
}
get body() {
return this._body;
}
get droppedAttributesCount() {
return this.totalAttributesCount - Object.keys(this.attributes).length;
}
setAttribute(key, value) {
if (this._isLogRecordReadonly()) {
return this;
}
if (value === null) {
return this;
}
if (key.length === 0) {
api.diag.warn(`Invalid attribute key: ${key}`);
return this;
}
if (!isAttributeValue(value) &&
!(typeof value === 'object' &&
!Array.isArray(value) &&
Object.keys(value).length > 0)) {
api.diag.warn(`Invalid attribute value set for key: ${key}`);
return this;
}
this.totalAttributesCount += 1;
if (Object.keys(this.attributes).length >=
this._logRecordLimits.attributeCountLimit &&
!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
// This logic is to create drop message at most once per LogRecord to prevent excessive logging.
if (this.droppedAttributesCount === 1) {
api.diag.warn('Dropping extra attributes.');
}
return this;
}
if (isAttributeValue(value)) {
this.attributes[key] = this._truncateToSize(value);
}
else {
this.attributes[key] = value;
}
return this;
}
setAttributes(attributes) {
for (const [k, v] of Object.entries(attributes)) {
this.setAttribute(k, v);
}
return this;
}
setBody(body) {
this.body = body;
return this;
}
setSeverityNumber(severityNumber) {
this.severityNumber = severityNumber;
return this;
}
setSeverityText(severityText) {
this.severityText = severityText;
return this;
}
/**
* @internal
* A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.
* If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.
*/
_makeReadonly() {
this._isReadonly = true;
}
_truncateToSize(value) {
const limit = this._logRecordLimits.attributeValueLengthLimit;
// Check limit
if (limit <= 0) {
// Negative values are invalid, so do not truncate
api.diag.warn(`Attribute value limit must be positive, got ${limit}`);
return value;
}
// String
if (typeof value === 'string') {
return this._truncateToLimitUtil(value, limit);
}
// Array of strings
if (Array.isArray(value)) {
return value.map(val => typeof val === 'string' ? this._truncateToLimitUtil(val, limit) : val);
}
// Other types, no need to apply value length limit
return value;
}
_truncateToLimitUtil(value, limit) {
if (value.length <= limit) {
return value;
}
return value.substring(0, limit);
}
_isLogRecordReadonly() {
if (this._isReadonly) {
diag.warn('Can not execute the operation on emitted log record');
}
return this._isReadonly;
}
}
//# sourceMappingURL=LogRecord.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import { Context } from '@opentelemetry/api';
import { LogRecord } from './LogRecord';
export interface LogRecordProcessor {
/**
* Forces to export all finished log records
*/
forceFlush(): Promise<void>;
/**
* Called when a {@link LogRecord} is emit
* @param logRecord the ReadWriteLogRecord that just emitted.
* @param context the current Context, or an empty Context if the Logger was obtained with include_trace_context=false
*/
onEmit(logRecord: LogRecord, context?: Context): void;
/**
* Shuts down the processor. Called when SDK is shut down. This is an
* opportunity for processor to do any cleanup required.
*/
shutdown(): Promise<void>;
}
//# sourceMappingURL=LogRecordProcessor.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"LogRecordProcessor.js","sourceRoot":"","sources":["../../src/LogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context } from '@opentelemetry/api';\n\nimport { LogRecord } from './LogRecord';\n\nexport interface LogRecordProcessor {\n /**\n * Forces to export all finished log records\n */\n forceFlush(): Promise<void>;\n\n /**\n * Called when a {@link LogRecord} is emit\n * @param logRecord the ReadWriteLogRecord that just emitted.\n * @param context the current Context, or an empty Context if the Logger was obtained with include_trace_context=false\n */\n onEmit(logRecord: LogRecord, context?: Context): void;\n\n /**\n * Shuts down the processor. Called when SDK is shut down. This is an\n * opportunity for processor to do any cleanup required.\n */\n shutdown(): Promise<void>;\n}\n"]}

View File

@@ -0,0 +1,10 @@
import type * as logsAPI from '@opentelemetry/api-logs';
import type { InstrumentationScope } from '@opentelemetry/core';
import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';
export declare class Logger implements logsAPI.Logger {
readonly instrumentationScope: InstrumentationScope;
private _sharedState;
constructor(instrumentationScope: InstrumentationScope, _sharedState: LoggerProviderSharedState);
emit(logRecord: logsAPI.LogRecord): void;
}
//# sourceMappingURL=Logger.d.ts.map

View File

@@ -0,0 +1,43 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { context } from '@opentelemetry/api';
import { LogRecord } from './LogRecord';
export class Logger {
constructor(instrumentationScope, _sharedState) {
this.instrumentationScope = instrumentationScope;
this._sharedState = _sharedState;
}
emit(logRecord) {
const currentContext = logRecord.context || context.active();
/**
* If a Logger was obtained with include_trace_context=true,
* the LogRecords it emits MUST automatically include the Trace Context from the active Context,
* if Context has not been explicitly set.
*/
const logRecordInstance = new LogRecord(this._sharedState, this.instrumentationScope, Object.assign({ context: currentContext }, logRecord));
/**
* the explicitly passed Context,
* the current Context, or an empty Context if the Logger was obtained with include_trace_context=false
*/
this._sharedState.activeProcessor.onEmit(logRecordInstance, currentContext);
/**
* A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.
* If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.
*/
logRecordInstance._makeReadonly();
}
}
//# sourceMappingURL=Logger.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,OAAO,MAAM;IACjB,YACkB,oBAA0C,EAClD,YAAuC;QAD/B,yBAAoB,GAApB,oBAAoB,CAAsB;QAClD,iBAAY,GAAZ,YAAY,CAA2B;IAC9C,CAAC;IAEG,IAAI,CAAC,SAA4B;QACtC,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QAC7D;;;;WAIG;QACH,MAAM,iBAAiB,GAAG,IAAI,SAAS,CACrC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,oBAAoB,kBAEvB,OAAO,EAAE,cAAc,IACpB,SAAS,EAEf,CAAC;QACF;;;WAGG;QACH,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;QAC5E;;;WAGG;QACH,iBAAiB,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as logsAPI from '@opentelemetry/api-logs';\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport { context } from '@opentelemetry/api';\n\nimport { LogRecord } from './LogRecord';\nimport { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';\n\nexport class Logger implements logsAPI.Logger {\n constructor(\n public readonly instrumentationScope: InstrumentationScope,\n private _sharedState: LoggerProviderSharedState\n ) {}\n\n public emit(logRecord: logsAPI.LogRecord): void {\n const currentContext = logRecord.context || context.active();\n /**\n * If a Logger was obtained with include_trace_context=true,\n * the LogRecords it emits MUST automatically include the Trace Context from the active Context,\n * if Context has not been explicitly set.\n */\n const logRecordInstance = new LogRecord(\n this._sharedState,\n this.instrumentationScope,\n {\n context: currentContext,\n ...logRecord,\n }\n );\n /**\n * the explicitly passed Context,\n * the current Context, or an empty Context if the Logger was obtained with include_trace_context=false\n */\n this._sharedState.activeProcessor.onEmit(logRecordInstance, currentContext);\n /**\n * A LogRecordProcessor may freely modify logRecord for the duration of the OnEmit call.\n * If logRecord is needed after OnEmit returns (i.e. for asynchronous processing) only reads are permitted.\n */\n logRecordInstance._makeReadonly();\n }\n}\n"]}

View File

@@ -0,0 +1,33 @@
import type * as logsAPI from '@opentelemetry/api-logs';
import type { LoggerProviderConfig } from './types';
import type { LogRecordProcessor } from './LogRecordProcessor';
export declare const DEFAULT_LOGGER_NAME = "unknown";
export declare class LoggerProvider implements logsAPI.LoggerProvider {
private _shutdownOnce;
private readonly _sharedState;
constructor(config?: LoggerProviderConfig);
/**
* Get a logger with the configuration of the LoggerProvider.
*/
getLogger(name: string, version?: string, options?: logsAPI.LoggerOptions): logsAPI.Logger;
/**
* Adds a new {@link LogRecordProcessor} to this logger.
* @param processor the new LogRecordProcessor to be added.
*/
addLogRecordProcessor(processor: LogRecordProcessor): void;
/**
* Notifies all registered LogRecordProcessor to flush any buffered data.
*
* Returns a promise which is resolved when all flushes are complete.
*/
forceFlush(): Promise<void>;
/**
* Flush all buffered data and shut down the LoggerProvider and all registered
* LogRecordProcessor.
*
* Returns a promise which is resolved when all flushes are complete.
*/
shutdown(): Promise<void>;
private _shutdown;
}
//# sourceMappingURL=LoggerProvider.d.ts.map

View File

@@ -0,0 +1,103 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { diag } from '@opentelemetry/api';
import { NOOP_LOGGER } from '@opentelemetry/api-logs';
import { Resource } from '@opentelemetry/resources';
import { BindOnceFuture, merge } from '@opentelemetry/core';
import { Logger } from './Logger';
import { loadDefaultConfig, reconfigureLimits } from './config';
import { MultiLogRecordProcessor } from './MultiLogRecordProcessor';
import { LoggerProviderSharedState } from './internal/LoggerProviderSharedState';
export const DEFAULT_LOGGER_NAME = 'unknown';
function prepareResource(mergeWithDefaults, providedResource) {
const resource = providedResource !== null && providedResource !== void 0 ? providedResource : Resource.empty();
if (mergeWithDefaults) {
return Resource.default().merge(resource);
}
return resource;
}
export class LoggerProvider {
constructor(config = {}) {
const mergedConfig = merge({}, loadDefaultConfig(), config);
const resource = prepareResource(mergedConfig.mergeResourceWithDefaults, config.resource);
this._sharedState = new LoggerProviderSharedState(resource, mergedConfig.forceFlushTimeoutMillis, reconfigureLimits(mergedConfig.logRecordLimits));
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
}
/**
* Get a logger with the configuration of the LoggerProvider.
*/
getLogger(name, version, options) {
if (this._shutdownOnce.isCalled) {
diag.warn('A shutdown LoggerProvider cannot provide a Logger');
return NOOP_LOGGER;
}
if (!name) {
diag.warn('Logger requested without instrumentation scope name.');
}
const loggerName = name || DEFAULT_LOGGER_NAME;
const key = `${loggerName}@${version || ''}:${(options === null || options === void 0 ? void 0 : options.schemaUrl) || ''}`;
if (!this._sharedState.loggers.has(key)) {
this._sharedState.loggers.set(key, new Logger({ name: loggerName, version, schemaUrl: options === null || options === void 0 ? void 0 : options.schemaUrl }, this._sharedState));
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this._sharedState.loggers.get(key);
}
/**
* Adds a new {@link LogRecordProcessor} to this logger.
* @param processor the new LogRecordProcessor to be added.
*/
addLogRecordProcessor(processor) {
if (this._sharedState.registeredLogRecordProcessors.length === 0) {
// since we might have enabled by default a batchProcessor, we disable it
// before adding the new one
this._sharedState.activeProcessor
.shutdown()
.catch(err => diag.error('Error while trying to shutdown current log record processor', err));
}
this._sharedState.registeredLogRecordProcessors.push(processor);
this._sharedState.activeProcessor = new MultiLogRecordProcessor(this._sharedState.registeredLogRecordProcessors, this._sharedState.forceFlushTimeoutMillis);
}
/**
* Notifies all registered LogRecordProcessor to flush any buffered data.
*
* Returns a promise which is resolved when all flushes are complete.
*/
forceFlush() {
// do not flush after shutdown
if (this._shutdownOnce.isCalled) {
diag.warn('invalid attempt to force flush after LoggerProvider shutdown');
return this._shutdownOnce.promise;
}
return this._sharedState.activeProcessor.forceFlush();
}
/**
* Flush all buffered data and shut down the LoggerProvider and all registered
* LogRecordProcessor.
*
* Returns a promise which is resolved when all flushes are complete.
*/
shutdown() {
if (this._shutdownOnce.isCalled) {
diag.warn('shutdown may only be called once per LoggerProvider');
return this._shutdownOnce.promise;
}
return this._shutdownOnce.call();
}
_shutdown() {
return this._sharedState.activeProcessor.shutdown();
}
}
//# sourceMappingURL=LoggerProvider.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
import type { Context } from '@opentelemetry/api';
import type { LogRecordProcessor } from './LogRecordProcessor';
import type { LogRecord } from './LogRecord';
/**
* Implementation of the {@link LogRecordProcessor} that simply forwards all
* received events to a list of {@link LogRecordProcessor}s.
*/
export declare class MultiLogRecordProcessor implements LogRecordProcessor {
readonly processors: LogRecordProcessor[];
readonly forceFlushTimeoutMillis: number;
constructor(processors: LogRecordProcessor[], forceFlushTimeoutMillis: number);
forceFlush(): Promise<void>;
onEmit(logRecord: LogRecord, context?: Context): void;
shutdown(): Promise<void>;
}
//# sourceMappingURL=MultiLogRecordProcessor.d.ts.map

View File

@@ -0,0 +1,37 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { callWithTimeout } from '@opentelemetry/core';
/**
* Implementation of the {@link LogRecordProcessor} that simply forwards all
* received events to a list of {@link LogRecordProcessor}s.
*/
export class MultiLogRecordProcessor {
constructor(processors, forceFlushTimeoutMillis) {
this.processors = processors;
this.forceFlushTimeoutMillis = forceFlushTimeoutMillis;
}
async forceFlush() {
const timeout = this.forceFlushTimeoutMillis;
await Promise.all(this.processors.map(processor => callWithTimeout(processor.forceFlush(), timeout)));
}
onEmit(logRecord, context) {
this.processors.forEach(processors => processors.onEmit(logRecord, context));
}
async shutdown() {
await Promise.all(this.processors.map(processor => processor.shutdown()));
}
}
//# sourceMappingURL=MultiLogRecordProcessor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MultiLogRecordProcessor.js","sourceRoot":"","sources":["../../src/MultiLogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAClC,YACkB,UAAgC,EAChC,uBAA+B;QAD/B,eAAU,GAAV,UAAU,CAAsB;QAChC,4BAAuB,GAAvB,uBAAuB,CAAQ;IAC9C,CAAC;IAEG,KAAK,CAAC,UAAU;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC;QAC7C,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAC9B,eAAe,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,CACjD,CACF,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,SAAoB,EAAE,OAAiB;QACnD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CACnC,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CACtC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { callWithTimeout } from '@opentelemetry/core';\nimport type { Context } from '@opentelemetry/api';\nimport type { LogRecordProcessor } from './LogRecordProcessor';\nimport type { LogRecord } from './LogRecord';\n\n/**\n * Implementation of the {@link LogRecordProcessor} that simply forwards all\n * received events to a list of {@link LogRecordProcessor}s.\n */\nexport class MultiLogRecordProcessor implements LogRecordProcessor {\n constructor(\n public readonly processors: LogRecordProcessor[],\n public readonly forceFlushTimeoutMillis: number\n ) {}\n\n public async forceFlush(): Promise<void> {\n const timeout = this.forceFlushTimeoutMillis;\n await Promise.all(\n this.processors.map(processor =>\n callWithTimeout(processor.forceFlush(), timeout)\n )\n );\n }\n\n public onEmit(logRecord: LogRecord, context?: Context): void {\n this.processors.forEach(processors =>\n processors.onEmit(logRecord, context)\n );\n }\n\n public async shutdown(): Promise<void> {\n await Promise.all(this.processors.map(processor => processor.shutdown()));\n }\n}\n"]}

View File

@@ -0,0 +1,17 @@
import { LogRecordLimits } from './types';
export declare function loadDefaultConfig(): {
forceFlushTimeoutMillis: number;
logRecordLimits: {
attributeValueLengthLimit: number;
attributeCountLimit: number;
};
includeTraceContext: boolean;
mergeResourceWithDefaults: boolean;
};
/**
* When general limits are provided and model specific limits are not,
* configures the model specific limits by using the values from the general ones.
* @param logRecordLimits User provided limits configuration
*/
export declare function reconfigureLimits(logRecordLimits: LogRecordLimits): Required<LogRecordLimits>;
//# sourceMappingURL=config.d.ts.map

View File

@@ -0,0 +1,47 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, getEnv, getEnvWithoutDefaults, } from '@opentelemetry/core';
export function loadDefaultConfig() {
return {
forceFlushTimeoutMillis: 30000,
logRecordLimits: {
attributeValueLengthLimit: getEnv().OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT,
},
includeTraceContext: true,
mergeResourceWithDefaults: true,
};
}
/**
* When general limits are provided and model specific limits are not,
* configures the model specific limits by using the values from the general ones.
* @param logRecordLimits User provided limits configuration
*/
export function reconfigureLimits(logRecordLimits) {
var _a, _b, _c, _d, _e, _f;
const parsedEnvConfig = getEnvWithoutDefaults();
return {
/**
* Reassign log record attribute count limit to use first non null value defined by user or use default value
*/
attributeCountLimit: (_c = (_b = (_a = logRecordLimits.attributeCountLimit) !== null && _a !== void 0 ? _a : parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT) !== null && _b !== void 0 ? _b : parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT) !== null && _c !== void 0 ? _c : DEFAULT_ATTRIBUTE_COUNT_LIMIT,
/**
* Reassign log record attribute value length limit to use first non null value defined by user or use default value
*/
attributeValueLengthLimit: (_f = (_e = (_d = logRecordLimits.attributeValueLengthLimit) !== null && _d !== void 0 ? _d : parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _e !== void 0 ? _e : parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _f !== void 0 ? _f : DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,
};
}
//# sourceMappingURL=config.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,EACpC,MAAM,EACN,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,uBAAuB,EAAE,KAAK;QAC9B,eAAe,EAAE;YACf,yBAAyB,EACvB,MAAM,EAAE,CAAC,2CAA2C;YACtD,mBAAmB,EAAE,MAAM,EAAE,CAAC,oCAAoC;SACnE;QACD,mBAAmB,EAAE,IAAI;QACzB,yBAAyB,EAAE,IAAI;KAChC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,eAAgC;;IAEhC,MAAM,eAAe,GAAG,qBAAqB,EAAE,CAAC;IAEhD,OAAO;QACL;;WAEG;QACH,mBAAmB,EACjB,MAAA,MAAA,MAAA,eAAe,CAAC,mBAAmB,mCACnC,eAAe,CAAC,oCAAoC,mCACpD,eAAe,CAAC,0BAA0B,mCAC1C,6BAA6B;QAC/B;;WAEG;QACH,yBAAyB,EACvB,MAAA,MAAA,MAAA,eAAe,CAAC,yBAAyB,mCACzC,eAAe,CAAC,2CAA2C,mCAC3D,eAAe,CAAC,iCAAiC,mCACjD,oCAAoC;KACvC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DEFAULT_ATTRIBUTE_COUNT_LIMIT,\n DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,\n getEnv,\n getEnvWithoutDefaults,\n} from '@opentelemetry/core';\nimport { LogRecordLimits } from './types';\n\nexport function loadDefaultConfig() {\n return {\n forceFlushTimeoutMillis: 30000,\n logRecordLimits: {\n attributeValueLengthLimit:\n getEnv().OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT,\n attributeCountLimit: getEnv().OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT,\n },\n includeTraceContext: true,\n mergeResourceWithDefaults: true,\n };\n}\n\n/**\n * When general limits are provided and model specific limits are not,\n * configures the model specific limits by using the values from the general ones.\n * @param logRecordLimits User provided limits configuration\n */\nexport function reconfigureLimits(\n logRecordLimits: LogRecordLimits\n): Required<LogRecordLimits> {\n const parsedEnvConfig = getEnvWithoutDefaults();\n\n return {\n /**\n * Reassign log record attribute count limit to use first non null value defined by user or use default value\n */\n attributeCountLimit:\n logRecordLimits.attributeCountLimit ??\n parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT ??\n parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT ??\n DEFAULT_ATTRIBUTE_COUNT_LIMIT,\n /**\n * Reassign log record attribute value length limit to use first non null value defined by user or use default value\n */\n attributeValueLengthLimit:\n logRecordLimits.attributeValueLengthLimit ??\n parsedEnvConfig.OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT ??\n parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ??\n DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,\n };\n}\n"]}

View File

@@ -0,0 +1,33 @@
import type { BufferConfig } from '../types';
import type { LogRecord } from '../LogRecord';
import type { LogRecordExporter } from './LogRecordExporter';
import type { LogRecordProcessor } from '../LogRecordProcessor';
export declare abstract class BatchLogRecordProcessorBase<T extends BufferConfig> implements LogRecordProcessor {
private readonly _exporter;
private readonly _maxExportBatchSize;
private readonly _maxQueueSize;
private readonly _scheduledDelayMillis;
private readonly _exportTimeoutMillis;
private _finishedLogRecords;
private _timer;
private _shutdownOnce;
constructor(_exporter: LogRecordExporter, config?: T);
onEmit(logRecord: LogRecord): void;
forceFlush(): Promise<void>;
shutdown(): Promise<void>;
private _shutdown;
/** Add a LogRecord in the buffer. */
private _addToBuffer;
/**
* Send all LogRecords to the exporter respecting the batch size limit
* This function is used only on forceFlush or shutdown,
* for all other cases _flush should be used
* */
private _flushAll;
private _flushOneBatch;
private _maybeStartTimer;
private _clearTimer;
private _export;
protected abstract onShutdown(): void;
}
//# sourceMappingURL=BatchLogRecordProcessorBase.d.ts.map

View File

@@ -0,0 +1,141 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { diag } from '@opentelemetry/api';
import { ExportResultCode, getEnv, globalErrorHandler, unrefTimer, BindOnceFuture, internal, callWithTimeout, } from '@opentelemetry/core';
export class BatchLogRecordProcessorBase {
constructor(_exporter, config) {
var _a, _b, _c, _d;
this._exporter = _exporter;
this._finishedLogRecords = [];
const env = getEnv();
this._maxExportBatchSize =
(_a = config === null || config === void 0 ? void 0 : config.maxExportBatchSize) !== null && _a !== void 0 ? _a : env.OTEL_BLRP_MAX_EXPORT_BATCH_SIZE;
this._maxQueueSize = (_b = config === null || config === void 0 ? void 0 : config.maxQueueSize) !== null && _b !== void 0 ? _b : env.OTEL_BLRP_MAX_QUEUE_SIZE;
this._scheduledDelayMillis =
(_c = config === null || config === void 0 ? void 0 : config.scheduledDelayMillis) !== null && _c !== void 0 ? _c : env.OTEL_BLRP_SCHEDULE_DELAY;
this._exportTimeoutMillis =
(_d = config === null || config === void 0 ? void 0 : config.exportTimeoutMillis) !== null && _d !== void 0 ? _d : env.OTEL_BLRP_EXPORT_TIMEOUT;
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
if (this._maxExportBatchSize > this._maxQueueSize) {
diag.warn('BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize');
this._maxExportBatchSize = this._maxQueueSize;
}
}
onEmit(logRecord) {
if (this._shutdownOnce.isCalled) {
return;
}
this._addToBuffer(logRecord);
}
forceFlush() {
if (this._shutdownOnce.isCalled) {
return this._shutdownOnce.promise;
}
return this._flushAll();
}
shutdown() {
return this._shutdownOnce.call();
}
async _shutdown() {
this.onShutdown();
await this._flushAll();
await this._exporter.shutdown();
}
/** Add a LogRecord in the buffer. */
_addToBuffer(logRecord) {
if (this._finishedLogRecords.length >= this._maxQueueSize) {
return;
}
this._finishedLogRecords.push(logRecord);
this._maybeStartTimer();
}
/**
* Send all LogRecords to the exporter respecting the batch size limit
* This function is used only on forceFlush or shutdown,
* for all other cases _flush should be used
* */
_flushAll() {
return new Promise((resolve, reject) => {
const promises = [];
const batchCount = Math.ceil(this._finishedLogRecords.length / this._maxExportBatchSize);
for (let i = 0; i < batchCount; i++) {
promises.push(this._flushOneBatch());
}
Promise.all(promises)
.then(() => {
resolve();
})
.catch(reject);
});
}
_flushOneBatch() {
this._clearTimer();
if (this._finishedLogRecords.length === 0) {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
callWithTimeout(this._export(this._finishedLogRecords.splice(0, this._maxExportBatchSize)), this._exportTimeoutMillis)
.then(() => resolve())
.catch(reject);
});
}
_maybeStartTimer() {
if (this._timer !== undefined) {
return;
}
this._timer = setTimeout(() => {
this._flushOneBatch()
.then(() => {
if (this._finishedLogRecords.length > 0) {
this._clearTimer();
this._maybeStartTimer();
}
})
.catch(e => {
globalErrorHandler(e);
});
}, this._scheduledDelayMillis);
unrefTimer(this._timer);
}
_clearTimer() {
if (this._timer !== undefined) {
clearTimeout(this._timer);
this._timer = undefined;
}
}
_export(logRecords) {
const doExport = () => internal
._export(this._exporter, logRecords)
.then((result) => {
var _a;
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler((_a = result.error) !== null && _a !== void 0 ? _a : new Error(`BatchLogRecordProcessor: log record export failed (status ${result})`));
}
})
.catch(globalErrorHandler);
const pendingResources = logRecords
.map(logRecord => logRecord.resource)
.filter(resource => resource.asyncAttributesPending);
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (pendingResources.length === 0) {
return doExport();
}
else {
return Promise.all(pendingResources.map(resource => { var _a; return (_a = resource.waitForAsyncAttributes) === null || _a === void 0 ? void 0 : _a.call(resource); })).then(doExport, globalErrorHandler);
}
}
}
//# sourceMappingURL=BatchLogRecordProcessorBase.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
import { ExportResult } from '@opentelemetry/core';
import type { ReadableLogRecord } from './ReadableLogRecord';
import type { LogRecordExporter } from './LogRecordExporter';
/**
* This is implementation of {@link LogRecordExporter} that prints LogRecords to the
* console. This class can be used for diagnostic purposes.
*
* NOTE: This {@link LogRecordExporter} is intended for diagnostics use only, output rendered to the console may change at any time.
*/
export declare class ConsoleLogRecordExporter implements LogRecordExporter {
/**
* Export logs.
* @param logs
* @param resultCallback
*/
export(logs: ReadableLogRecord[], resultCallback: (result: ExportResult) => void): void;
/**
* Shutdown the exporter.
*/
shutdown(): Promise<void>;
/**
* converts logRecord info into more readable format
* @param logRecord
*/
private _exportInfo;
/**
* Showing logs in console
* @param logRecords
* @param done
*/
private _sendLogRecords;
}
//# sourceMappingURL=ConsoleLogRecordExporter.d.ts.map

View File

@@ -0,0 +1,73 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { hrTimeToMicroseconds } from '@opentelemetry/core';
import { ExportResultCode } from '@opentelemetry/core';
/**
* This is implementation of {@link LogRecordExporter} that prints LogRecords to the
* console. This class can be used for diagnostic purposes.
*
* NOTE: This {@link LogRecordExporter} is intended for diagnostics use only, output rendered to the console may change at any time.
*/
/* eslint-disable no-console */
export class ConsoleLogRecordExporter {
/**
* Export logs.
* @param logs
* @param resultCallback
*/
export(logs, resultCallback) {
this._sendLogRecords(logs, resultCallback);
}
/**
* Shutdown the exporter.
*/
shutdown() {
return Promise.resolve();
}
/**
* converts logRecord info into more readable format
* @param logRecord
*/
_exportInfo(logRecord) {
var _a, _b, _c;
return {
resource: {
attributes: logRecord.resource.attributes,
},
instrumentationScope: logRecord.instrumentationScope,
timestamp: hrTimeToMicroseconds(logRecord.hrTime),
traceId: (_a = logRecord.spanContext) === null || _a === void 0 ? void 0 : _a.traceId,
spanId: (_b = logRecord.spanContext) === null || _b === void 0 ? void 0 : _b.spanId,
traceFlags: (_c = logRecord.spanContext) === null || _c === void 0 ? void 0 : _c.traceFlags,
severityText: logRecord.severityText,
severityNumber: logRecord.severityNumber,
body: logRecord.body,
attributes: logRecord.attributes,
};
}
/**
* Showing logs in console
* @param logRecords
* @param done
*/
_sendLogRecords(logRecords, done) {
for (const logRecord of logRecords) {
console.dir(this._exportInfo(logRecord), { depth: 3 });
}
done === null || done === void 0 ? void 0 : done({ code: ExportResultCode.SUCCESS });
}
}
//# sourceMappingURL=ConsoleLogRecordExporter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConsoleLogRecordExporter.js","sourceRoot":"","sources":["../../../src/export/ConsoleLogRecordExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAgB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;;GAKG;AAEH,+BAA+B;AAC/B,MAAM,OAAO,wBAAwB;IACnC;;;;OAIG;IACI,MAAM,CACX,IAAyB,EACzB,cAA8C;QAE9C,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACK,WAAW,CAAC,SAA4B;;QAC9C,OAAO;YACL,QAAQ,EAAE;gBACR,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,UAAU;aAC1C;YACD,oBAAoB,EAAE,SAAS,CAAC,oBAAoB;YACpD,SAAS,EAAE,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC;YACjD,OAAO,EAAE,MAAA,SAAS,CAAC,WAAW,0CAAE,OAAO;YACvC,MAAM,EAAE,MAAA,SAAS,CAAC,WAAW,0CAAE,MAAM;YACrC,UAAU,EAAE,MAAA,SAAS,CAAC,WAAW,0CAAE,UAAU;YAC7C,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,cAAc,EAAE,SAAS,CAAC,cAAc;YACxC,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,UAAU,EAAE,SAAS,CAAC,UAAU;SACjC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACK,eAAe,CACrB,UAA+B,EAC/B,IAAqC;QAErC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;SACxD;QACD,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExportResult, hrTimeToMicroseconds } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\nimport type { LogRecordExporter } from './LogRecordExporter';\n\n/**\n * This is implementation of {@link LogRecordExporter} that prints LogRecords to the\n * console. This class can be used for diagnostic purposes.\n *\n * NOTE: This {@link LogRecordExporter} is intended for diagnostics use only, output rendered to the console may change at any time.\n */\n\n/* eslint-disable no-console */\nexport class ConsoleLogRecordExporter implements LogRecordExporter {\n /**\n * Export logs.\n * @param logs\n * @param resultCallback\n */\n public export(\n logs: ReadableLogRecord[],\n resultCallback: (result: ExportResult) => void\n ) {\n this._sendLogRecords(logs, resultCallback);\n }\n\n /**\n * Shutdown the exporter.\n */\n public shutdown(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * converts logRecord info into more readable format\n * @param logRecord\n */\n private _exportInfo(logRecord: ReadableLogRecord) {\n return {\n resource: {\n attributes: logRecord.resource.attributes,\n },\n instrumentationScope: logRecord.instrumentationScope,\n timestamp: hrTimeToMicroseconds(logRecord.hrTime),\n traceId: logRecord.spanContext?.traceId,\n spanId: logRecord.spanContext?.spanId,\n traceFlags: logRecord.spanContext?.traceFlags,\n severityText: logRecord.severityText,\n severityNumber: logRecord.severityNumber,\n body: logRecord.body,\n attributes: logRecord.attributes,\n };\n }\n\n /**\n * Showing logs in console\n * @param logRecords\n * @param done\n */\n private _sendLogRecords(\n logRecords: ReadableLogRecord[],\n done?: (result: ExportResult) => void\n ): void {\n for (const logRecord of logRecords) {\n console.dir(this._exportInfo(logRecord), { depth: 3 });\n }\n done?.({ code: ExportResultCode.SUCCESS });\n }\n}\n"]}

View File

@@ -0,0 +1,21 @@
import type { ExportResult } from '@opentelemetry/core';
import type { ReadableLogRecord } from './ReadableLogRecord';
import type { LogRecordExporter } from './LogRecordExporter';
/**
* This class can be used for testing purposes. It stores the exported LogRecords
* in a list in memory that can be retrieved using the `getFinishedLogRecords()`
* method.
*/
export declare class InMemoryLogRecordExporter implements LogRecordExporter {
private _finishedLogRecords;
/**
* Indicates if the exporter has been "shutdown."
* When false, exported log records will not be stored in-memory.
*/
protected _stopped: boolean;
export(logs: ReadableLogRecord[], resultCallback: (result: ExportResult) => void): void;
shutdown(): Promise<void>;
getFinishedLogRecords(): ReadableLogRecord[];
reset(): void;
}
//# sourceMappingURL=InMemoryLogRecordExporter.d.ts.map

View File

@@ -0,0 +1,53 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ExportResultCode } from '@opentelemetry/core';
/**
* This class can be used for testing purposes. It stores the exported LogRecords
* in a list in memory that can be retrieved using the `getFinishedLogRecords()`
* method.
*/
export class InMemoryLogRecordExporter {
constructor() {
this._finishedLogRecords = [];
/**
* Indicates if the exporter has been "shutdown."
* When false, exported log records will not be stored in-memory.
*/
this._stopped = false;
}
export(logs, resultCallback) {
if (this._stopped) {
return resultCallback({
code: ExportResultCode.FAILED,
error: new Error('Exporter has been stopped'),
});
}
this._finishedLogRecords.push(...logs);
resultCallback({ code: ExportResultCode.SUCCESS });
}
shutdown() {
this._stopped = true;
this.reset();
return Promise.resolve();
}
getFinishedLogRecords() {
return this._finishedLogRecords;
}
reset() {
this._finishedLogRecords = [];
}
}
//# sourceMappingURL=InMemoryLogRecordExporter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"InMemoryLogRecordExporter.js","sourceRoot":"","sources":["../../../src/export/InMemoryLogRecordExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;GAIG;AACH,MAAM,OAAO,yBAAyB;IAAtC;QACU,wBAAmB,GAAwB,EAAE,CAAC;QAEtD;;;WAGG;QACO,aAAQ,GAAG,KAAK,CAAC;IA8B7B,CAAC;IA5BQ,MAAM,CACX,IAAyB,EACzB,cAA8C;QAE9C,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,cAAc,CAAC;gBACpB,IAAI,EAAE,gBAAgB,CAAC,MAAM;gBAC7B,KAAK,EAAE,IAAI,KAAK,CAAC,2BAA2B,CAAC;aAC9C,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACvC,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,QAAQ;QACb,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEM,qBAAqB;QAC1B,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;IAChC,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\nimport type { LogRecordExporter } from './LogRecordExporter';\n\n/**\n * This class can be used for testing purposes. It stores the exported LogRecords\n * in a list in memory that can be retrieved using the `getFinishedLogRecords()`\n * method.\n */\nexport class InMemoryLogRecordExporter implements LogRecordExporter {\n private _finishedLogRecords: ReadableLogRecord[] = [];\n\n /**\n * Indicates if the exporter has been \"shutdown.\"\n * When false, exported log records will not be stored in-memory.\n */\n protected _stopped = false;\n\n public export(\n logs: ReadableLogRecord[],\n resultCallback: (result: ExportResult) => void\n ) {\n if (this._stopped) {\n return resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been stopped'),\n });\n }\n\n this._finishedLogRecords.push(...logs);\n resultCallback({ code: ExportResultCode.SUCCESS });\n }\n\n public shutdown(): Promise<void> {\n this._stopped = true;\n this.reset();\n return Promise.resolve();\n }\n\n public getFinishedLogRecords(): ReadableLogRecord[] {\n return this._finishedLogRecords;\n }\n\n public reset(): void {\n this._finishedLogRecords = [];\n }\n}\n"]}

View File

@@ -0,0 +1,12 @@
import type { ExportResult } from '@opentelemetry/core';
import type { ReadableLogRecord } from './ReadableLogRecord';
export interface LogRecordExporter {
/**
* Called to export {@link ReadableLogRecord}s.
* @param logs the list of sampled LogRecords to be exported.
*/
export(logs: ReadableLogRecord[], resultCallback: (result: ExportResult) => void): void;
/** Stops the exporter. */
shutdown(): Promise<void>;
}
//# sourceMappingURL=LogRecordExporter.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"LogRecordExporter.js","sourceRoot":"","sources":["../../../src/export/LogRecordExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\n\nexport interface LogRecordExporter {\n /**\n * Called to export {@link ReadableLogRecord}s.\n * @param logs the list of sampled LogRecords to be exported.\n */\n export(\n logs: ReadableLogRecord[],\n resultCallback: (result: ExportResult) => void\n ): void;\n\n /** Stops the exporter. */\n shutdown(): Promise<void>;\n}\n"]}

View File

@@ -0,0 +1,9 @@
import { Context } from '@opentelemetry/api';
import { LogRecordProcessor } from '../LogRecordProcessor';
import { ReadableLogRecord } from './ReadableLogRecord';
export declare class NoopLogRecordProcessor implements LogRecordProcessor {
forceFlush(): Promise<void>;
onEmit(_logRecord: ReadableLogRecord, _context: Context): void;
shutdown(): Promise<void>;
}
//# sourceMappingURL=NoopLogRecordProcessor.d.ts.map

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"NoopLogRecordProcessor.js","sourceRoot":"","sources":["../../../src/export/NoopLogRecordProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,MAAM,OAAO,sBAAsB;IACjC,UAAU;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE,QAAiB,IAAS,CAAC;IAEjE,QAAQ;QACN,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context } from '@opentelemetry/api';\nimport { LogRecordProcessor } from '../LogRecordProcessor';\nimport { ReadableLogRecord } from './ReadableLogRecord';\n\nexport class NoopLogRecordProcessor implements LogRecordProcessor {\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n onEmit(_logRecord: ReadableLogRecord, _context: Context): void {}\n\n shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n"]}

View File

@@ -0,0 +1,17 @@
import type { IResource } from '@opentelemetry/resources';
import type { HrTime, SpanContext } from '@opentelemetry/api';
import type { InstrumentationScope } from '@opentelemetry/core';
import type { LogBody, LogAttributes, SeverityNumber } from '@opentelemetry/api-logs';
export interface ReadableLogRecord {
readonly hrTime: HrTime;
readonly hrTimeObserved: HrTime;
readonly spanContext?: SpanContext;
readonly severityText?: string;
readonly severityNumber?: SeverityNumber;
readonly body?: LogBody;
readonly resource: IResource;
readonly instrumentationScope: InstrumentationScope;
readonly attributes: LogAttributes;
readonly droppedAttributesCount: number;
}
//# sourceMappingURL=ReadableLogRecord.d.ts.map

Some files were not shown because too many files have changed in this diff Show More