Update test framework: fix run_tests.py to support all test files, add auto-import-check for test files

This commit is contained in:
qiaoxinjiu
2026-05-09 15:11:30 +08:00
parent eb053a347f
commit eaba8328da
21739 changed files with 2236758 additions and 719 deletions

201
node_modules/@opentelemetry/sdk-logs/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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
http://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.

79
node_modules/@opentelemetry/sdk-logs/README.md generated vendored Normal file
View File

@@ -0,0 +1,79 @@
# OpenTelemetry Logs SDK
[![NPM Published Version][npm-img]][npm-url]
[![Apache License][license-image]][license-image]
**Note: This is an experimental package under active development. New releases may include breaking changes.**
OpenTelemetry logs module contains the foundation for all logs SDKs of [opentelemetry-js](https://github.com/open-telemetry/opentelemetry-js).
Used standalone, this module provides methods for manual instrumentation of code, offering full control over recording logs for client-side JavaScript (browser) and Node.js.
It does **not** provide automated instrumentation of known libraries or host environment logs out-of-the-box.
## Installation
```bash
npm install --save @opentelemetry/api-logs
npm install --save @opentelemetry/sdk-logs
```
## Usage
The basic setup of the SDK can be seen as followings:
```js
const logsAPI = require('@opentelemetry/api-logs');
const {
LoggerProvider,
SimpleLogRecordProcessor,
ConsoleLogRecordExporter,
} = require('@opentelemetry/sdk-logs');
// To start a logger, you first need to initialize the Logger provider.
const loggerProvider = new LoggerProvider();
// Add a processor to export log record
loggerProvider.addLogRecordProcessor(
new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())
);
// To create a log record, you first need to get a Logger instance
const logger = loggerProvider.getLogger('default');
// You can also use global singleton
logsAPI.logs.setGlobalLoggerProvider(loggerProvider);
const logger = logsAPI.logs.getLogger('default');
// emit a log record
logger.emit({
severityNumber: logsAPI.SeverityNumber.INFO,
severityText: 'INFO',
body: 'this is a log record body',
attributes: { 'log.type': 'LogRecord' },
});
```
## Config
Logs configuration is a merge of both the user supplied configuration and the default
configuration as specified in [config.ts](./src/config.ts)
## Example
See [examples/logs](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/examples/logs)
## Useful links
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
## License
Apache 2.0 - See [LICENSE][license-url] for more information.
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@opentelemetry/sdk-logs
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fsdk%2Dlogs.svg

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 { Resource } 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: Resource;
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,175 @@
/*
* 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 {
hrTime;
hrTimeObserved;
spanContext;
resource;
instrumentationScope;
attributes = {};
_severityText;
_severityNumber;
_body;
totalAttributesCount = 0;
_isReadonly = false;
_logRecordLimits;
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;
}
constructor(_sharedState, instrumentationScope, logRecord) {
const { timestamp, observedTimestamp, severityNumber, severityText, body, attributes = {}, context, } = logRecord;
const now = Date.now();
this.hrTime = timeInputToHrTime(timestamp ?? now);
this.hrTimeObserved = timeInputToHrTime(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);
}
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,48 @@
/*
* 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 {
instrumentationScope;
_sharedState;
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, {
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;IAEC;IACR;IAFV,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,EACzB;YACE,OAAO,EAAE,cAAc;YACvB,GAAG,SAAS;SACb,CACF,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,98 @@
/*
* 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 { defaultResource } 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';
export class LoggerProvider {
_shutdownOnce;
_sharedState;
constructor(config = {}) {
const mergedConfig = merge({}, loadDefaultConfig(), config);
const resource = config.resource ?? defaultResource();
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?.schemaUrl || ''}`;
if (!this._sharedState.loggers.has(key)) {
this._sharedState.loggers.set(key, new Logger({ name: loggerName, version, schemaUrl: 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,39 @@
/*
* 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 {
processors;
forceFlushTimeoutMillis;
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;IAEhB;IACA;IAFlB,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,16 @@
import { LogRecordLimits } from './types';
export declare function loadDefaultConfig(): {
forceFlushTimeoutMillis: number;
logRecordLimits: {
attributeValueLengthLimit: number;
attributeCountLimit: number;
};
includeTraceContext: 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,51 @@
/*
* 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 { getNumberFromEnv } from '@opentelemetry/core';
export function loadDefaultConfig() {
return {
forceFlushTimeoutMillis: 30000,
logRecordLimits: {
attributeValueLengthLimit: getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??
Infinity,
attributeCountLimit: getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ?? 128,
},
includeTraceContext: 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) {
return {
/**
* Reassign log record attribute count limit to use first non null value defined by user or use default value
*/
attributeCountLimit: logRecordLimits.attributeCountLimit ??
getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ??
getNumberFromEnv('OTEL_ATTRIBUTE_COUNT_LIMIT') ??
128,
/**
* Reassign log record attribute value length limit to use first non null value defined by user or use default value
*/
attributeValueLengthLimit: logRecordLimits.attributeValueLengthLimit ??
getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??
getNumberFromEnv('OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??
Infinity,
};
}
//# 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,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,uBAAuB,EAAE,KAAK;QAC9B,eAAe,EAAE;YACf,yBAAyB,EACvB,gBAAgB,CAAC,6CAA6C,CAAC;gBAC/D,QAAQ;YACV,mBAAmB,EACjB,gBAAgB,CAAC,sCAAsC,CAAC,IAAI,GAAG;SAClE;QACD,mBAAmB,EAAE,IAAI;KAC1B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,eAAgC;IAEhC,OAAO;QACL;;WAEG;QACH,mBAAmB,EACjB,eAAe,CAAC,mBAAmB;YACnC,gBAAgB,CAAC,sCAAsC,CAAC;YACxD,gBAAgB,CAAC,4BAA4B,CAAC;YAC9C,GAAG;QACL;;WAEG;QACH,yBAAyB,EACvB,eAAe,CAAC,yBAAyB;YACzC,gBAAgB,CAAC,6CAA6C,CAAC;YAC/D,gBAAgB,CAAC,mCAAmC,CAAC;YACrD,QAAQ;KACX,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 { getNumberFromEnv } from '@opentelemetry/core';\nimport { LogRecordLimits } from './types';\n\nexport function loadDefaultConfig() {\n return {\n forceFlushTimeoutMillis: 30000,\n logRecordLimits: {\n attributeValueLengthLimit:\n getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??\n Infinity,\n attributeCountLimit:\n getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ?? 128,\n },\n includeTraceContext: 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 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 getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ??\n getNumberFromEnv('OTEL_ATTRIBUTE_COUNT_LIMIT') ??\n 128,\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 getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??\n getNumberFromEnv('OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??\n Infinity,\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,156 @@
/*
* 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 { getNumberFromEnv } from '@opentelemetry/core';
import { diag } from '@opentelemetry/api';
import { ExportResultCode, globalErrorHandler, unrefTimer, BindOnceFuture, internal, callWithTimeout, } from '@opentelemetry/core';
export class BatchLogRecordProcessorBase {
_exporter;
_maxExportBatchSize;
_maxQueueSize;
_scheduledDelayMillis;
_exportTimeoutMillis;
_finishedLogRecords = [];
_timer;
_shutdownOnce;
constructor(_exporter, config) {
this._exporter = _exporter;
this._maxExportBatchSize =
config?.maxExportBatchSize ??
getNumberFromEnv('OTEL_BLRP_MAX_EXPORT_BATCH_SIZE') ??
512;
this._maxQueueSize =
config?.maxQueueSize ??
getNumberFromEnv('OTEL_BLRP_MAX_QUEUE_SIZE') ??
2048;
this._scheduledDelayMillis =
config?.scheduledDelayMillis ??
getNumberFromEnv('OTEL_BLRP_SCHEDULE_DELAY') ??
5000;
this._exportTimeoutMillis =
config?.exportTimeoutMillis ??
getNumberFromEnv('OTEL_BLRP_EXPORT_TIMEOUT') ??
30000;
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) => {
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler(result.error ??
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 => resource.waitForAsyncAttributes?.())).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,72 @@
/*
* 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) {
return {
resource: {
attributes: logRecord.resource.attributes,
},
instrumentationScope: logRecord.instrumentationScope,
timestamp: hrTimeToMicroseconds(logRecord.hrTime),
traceId: logRecord.spanContext?.traceId,
spanId: logRecord.spanContext?.spanId,
traceFlags: logRecord.spanContext?.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?.({ 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,SAAS,CAAC,WAAW,EAAE,OAAO;YACvC,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE,MAAM;YACrC,UAAU,EAAE,SAAS,CAAC,WAAW,EAAE,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,EAAE,CAAC,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,51 @@
/*
* 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 {
_finishedLogRecords = [];
/**
* Indicates if the exporter has been "shutdown."
* When false, exported log records will not be stored in-memory.
*/
_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;IAC5B,mBAAmB,GAAwB,EAAE,CAAC;IAEtD;;;OAGG;IACO,QAAQ,GAAG,KAAK,CAAC;IAEpB,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 { Resource } 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: Resource;
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 { Resource } 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: Resource;\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,70 @@
/*
* 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 { BindOnceFuture, ExportResultCode, globalErrorHandler, internal, } from '@opentelemetry/core';
export class SimpleLogRecordProcessor {
_exporter;
_shutdownOnce;
_unresolvedExports;
constructor(_exporter) {
this._exporter = _exporter;
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
this._unresolvedExports = new Set();
}
onEmit(logRecord) {
if (this._shutdownOnce.isCalled) {
return;
}
const doExport = () => internal
._export(this._exporter, [logRecord])
.then((result) => {
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler(result.error ??
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) {
const exportPromise = logRecord.resource
.waitForAsyncAttributes?.()
.then(() => {
// 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);
return doExport();
}, globalErrorHandler);
// store the unresolved exports
if (exportPromise != null) {
this._unresolvedExports.add(exportPromise);
}
}
else {
void doExport();
}
}
async forceFlush() {
// await unresolved resources before resolving
await Promise.all(Array.from(this._unresolvedExports));
}
shutdown() {
return this._shutdownOnce.call();
}
_shutdown() {
return this._exporter.shutdown();
}
}
//# 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,MAAM,OAAO,wBAAwB;IAIN;IAHrB,aAAa,CAAuB;IACpC,kBAAkB,CAAqB;IAE/C,YAA6B,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,MAAM,CAAC,SAAoB;QAChC,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC/B,OAAO;SACR;QAED,MAAM,QAAQ,GAAG,GAAG,EAAE,CACpB,QAAQ;aACL,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC;aACpC,IAAI,CAAC,CAAC,MAAoB,EAAE,EAAE;YAC7B,IAAI,MAAM,CAAC,IAAI,KAAK,gBAAgB,CAAC,OAAO,EAAE;gBAC5C,kBAAkB,CAChB,MAAM,CAAC,KAAK;oBACV,IAAI,KAAK,CACP,8DAA8D,MAAM,GAAG,CACxE,CACJ,CAAC;aACH;QACH,CAAC,CAAC;aACD,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE/B,sFAAsF;QACtF,IAAI,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE;YAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ;iBACrC,sBAAsB,EAAE,EAAE;iBAC1B,IAAI,CAAC,GAAG,EAAE;gBACT,uFAAuF;gBACvF,2EAA2E;gBAC3E,oEAAoE;gBACpE,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,aAAc,CAAC,CAAC;gBAC/C,OAAO,QAAQ,EAAE,CAAC;YACpB,CAAC,EAAE,kBAAkB,CAAC,CAAC;YAEzB,+BAA+B;YAC/B,IAAI,aAAa,IAAI,IAAI,EAAE;gBACzB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;aAC5C;SACF;aAAM;YACL,KAAK,QAAQ,EAAE,CAAC;SACjB;IACH,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,8CAA8C;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACzD,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAEO,SAAS;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,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 {\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 { Resource } from '@opentelemetry/resources';
import { LogRecordProcessor } from '../LogRecordProcessor';
import { LogRecordLimits } from '../types';
export declare class LoggerProviderSharedState {
readonly resource: Resource;
readonly forceFlushTimeoutMillis: number;
readonly logRecordLimits: Required<LogRecordLimits>;
readonly loggers: Map<string, Logger>;
activeProcessor: LogRecordProcessor;
readonly registeredLogRecordProcessors: LogRecordProcessor[];
constructor(resource: Resource, forceFlushTimeoutMillis: number, logRecordLimits: Required<LogRecordLimits>);
}
//# sourceMappingURL=LoggerProviderSharedState.d.ts.map

View File

@@ -0,0 +1,31 @@
/*
* 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';
export class LoggerProviderSharedState {
resource;
forceFlushTimeoutMillis;
logRecordLimits;
loggers = new Map();
activeProcessor;
registeredLogRecordProcessors = [];
constructor(resource, forceFlushTimeoutMillis, logRecordLimits) {
this.resource = resource;
this.forceFlushTimeoutMillis = forceFlushTimeoutMillis;
this.logRecordLimits = logRecordLimits;
this.activeProcessor = new NoopLogRecordProcessor();
}
}
//# 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,MAAM,OAAO,yBAAyB;IAMzB;IACA;IACA;IAPF,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IAClD,eAAe,CAAqB;IAC3B,6BAA6B,GAAyB,EAAE,CAAC;IAElE,YACW,QAAkB,EAClB,uBAA+B,EAC/B,eAA0C;QAF1C,aAAQ,GAAR,QAAQ,CAAU;QAClB,4BAAuB,GAAvB,uBAAuB,CAAQ;QAC/B,oBAAe,GAAf,eAAe,CAA2B;QAEnD,IAAI,CAAC,eAAe,GAAG,IAAI,sBAAsB,EAAE,CAAC;IACtD,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 { Logger } from '@opentelemetry/api-logs';\nimport { Resource } 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: Resource,\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,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 { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';
export class BatchLogRecordProcessor extends BatchLogRecordProcessorBase {
_visibilityChangeListener;
_pageHideListener;
constructor(exporter, config) {
super(exporter, config);
this._onInit(config);
}
onShutdown() {
if (typeof document === 'undefined') {
return;
}
if (this._visibilityChangeListener) {
document.removeEventListener('visibilitychange', this._visibilityChangeListener);
}
if (this._pageHideListener) {
document.removeEventListener('pagehide', this._pageHideListener);
}
}
_onInit(config) {
if (config?.disableAutoFlushOnDocumentHide === true ||
typeof document === 'undefined') {
return;
}
this._visibilityChangeListener = () => {
if (document.visibilityState === 'hidden') {
void this.forceFlush();
}
};
this._pageHideListener = () => {
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);
}
}
//# 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,MAAM,OAAO,uBAAwB,SAAQ,2BAAiE;IACpG,yBAAyB,CAAc;IACvC,iBAAiB,CAAc;IAEvC,YACE,QAA2B,EAC3B,MAA6C;QAE7C,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAES,UAAU;QAClB,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,OAAO,CAAC,MAA6C;QAC3D,IACE,MAAM,EAAE,8BAA8B,KAAK,IAAI;YAC/C,OAAO,QAAQ,KAAK,WAAW,EAC/B;YACA,OAAO;SACR;QACD,IAAI,CAAC,yBAAyB,GAAG,GAAG,EAAE;YACpC,IAAI,QAAQ,CAAC,eAAe,KAAK,QAAQ,EAAE;gBACzC,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;aACxB;QACH,CAAC,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,GAAG,EAAE;YAC5B,KAAK,IAAI,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;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 { 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,20 @@
/*
* 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 { BatchLogRecordProcessorBase } from '../../../export/BatchLogRecordProcessorBase';
export class BatchLogRecordProcessor extends BatchLogRecordProcessorBase {
onShutdown() { }
}
//# 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,MAAM,OAAO,uBAAwB,SAAQ,2BAAyC;IAC1E,UAAU,KAAU,CAAC;CAChC","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,39 @@
import type { Resource } from '@opentelemetry/resources';
export interface LoggerProviderConfig {
/** Resource associated with trace telemetry */
resource?: Resource;
/**
* How long the forceFlush can run before it is cancelled.
* The default value is 30000ms
*/
forceFlushTimeoutMillis?: number;
/** Log Record Limits*/
logRecordLimits?: LogRecordLimits;
}
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 { Resource } from '@opentelemetry/resources';\n\nexport interface LoggerProviderConfig {\n /** Resource associated with trace telemetry */\n resource?: Resource;\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\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.200.0";
//# 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 const VERSION = '0.200.0';
//# 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,MAAM,OAAO,GAAG,SAAS,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.200.0';\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 { Resource } 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: Resource;
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,175 @@
/*
* 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 {
hrTime;
hrTimeObserved;
spanContext;
resource;
instrumentationScope;
attributes = {};
_severityText;
_severityNumber;
_body;
totalAttributesCount = 0;
_isReadonly = false;
_logRecordLimits;
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;
}
constructor(_sharedState, instrumentationScope, logRecord) {
const { timestamp, observedTimestamp, severityNumber, severityText, body, attributes = {}, context, } = logRecord;
const now = Date.now();
this.hrTime = timeInputToHrTime(timestamp ?? now);
this.hrTimeObserved = timeInputToHrTime(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);
}
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,48 @@
/*
* 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 {
instrumentationScope;
_sharedState;
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, {
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;IAEC;IACR;IAFV,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,EACzB;YACE,OAAO,EAAE,cAAc;YACvB,GAAG,SAAS;SACb,CACF,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,98 @@
/*
* 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 { defaultResource } 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';
export class LoggerProvider {
_shutdownOnce;
_sharedState;
constructor(config = {}) {
const mergedConfig = merge({}, loadDefaultConfig(), config);
const resource = config.resource ?? defaultResource();
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?.schemaUrl || ''}`;
if (!this._sharedState.loggers.has(key)) {
this._sharedState.loggers.set(key, new Logger({ name: loggerName, version, schemaUrl: 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,39 @@
/*
* 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 {
processors;
forceFlushTimeoutMillis;
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;IAEhB;IACA;IAFlB,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,16 @@
import { LogRecordLimits } from './types';
export declare function loadDefaultConfig(): {
forceFlushTimeoutMillis: number;
logRecordLimits: {
attributeValueLengthLimit: number;
attributeCountLimit: number;
};
includeTraceContext: 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,51 @@
/*
* 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 { getNumberFromEnv } from '@opentelemetry/core';
export function loadDefaultConfig() {
return {
forceFlushTimeoutMillis: 30000,
logRecordLimits: {
attributeValueLengthLimit: getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??
Infinity,
attributeCountLimit: getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ?? 128,
},
includeTraceContext: 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) {
return {
/**
* Reassign log record attribute count limit to use first non null value defined by user or use default value
*/
attributeCountLimit: logRecordLimits.attributeCountLimit ??
getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ??
getNumberFromEnv('OTEL_ATTRIBUTE_COUNT_LIMIT') ??
128,
/**
* Reassign log record attribute value length limit to use first non null value defined by user or use default value
*/
attributeValueLengthLimit: logRecordLimits.attributeValueLengthLimit ??
getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??
getNumberFromEnv('OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??
Infinity,
};
}
//# 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,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,uBAAuB,EAAE,KAAK;QAC9B,eAAe,EAAE;YACf,yBAAyB,EACvB,gBAAgB,CAAC,6CAA6C,CAAC;gBAC/D,QAAQ;YACV,mBAAmB,EACjB,gBAAgB,CAAC,sCAAsC,CAAC,IAAI,GAAG;SAClE;QACD,mBAAmB,EAAE,IAAI;KAC1B,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,eAAgC;IAEhC,OAAO;QACL;;WAEG;QACH,mBAAmB,EACjB,eAAe,CAAC,mBAAmB;YACnC,gBAAgB,CAAC,sCAAsC,CAAC;YACxD,gBAAgB,CAAC,4BAA4B,CAAC;YAC9C,GAAG;QACL;;WAEG;QACH,yBAAyB,EACvB,eAAe,CAAC,yBAAyB;YACzC,gBAAgB,CAAC,6CAA6C,CAAC;YAC/D,gBAAgB,CAAC,mCAAmC,CAAC;YACrD,QAAQ;KACX,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 { getNumberFromEnv } from '@opentelemetry/core';\nimport { LogRecordLimits } from './types';\n\nexport function loadDefaultConfig() {\n return {\n forceFlushTimeoutMillis: 30000,\n logRecordLimits: {\n attributeValueLengthLimit:\n getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??\n Infinity,\n attributeCountLimit:\n getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ?? 128,\n },\n includeTraceContext: 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 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 getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT') ??\n getNumberFromEnv('OTEL_ATTRIBUTE_COUNT_LIMIT') ??\n 128,\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 getNumberFromEnv('OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??\n getNumberFromEnv('OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT') ??\n Infinity,\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,156 @@
/*
* 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 { getNumberFromEnv } from '@opentelemetry/core';
import { diag } from '@opentelemetry/api';
import { ExportResultCode, globalErrorHandler, unrefTimer, BindOnceFuture, internal, callWithTimeout, } from '@opentelemetry/core';
export class BatchLogRecordProcessorBase {
_exporter;
_maxExportBatchSize;
_maxQueueSize;
_scheduledDelayMillis;
_exportTimeoutMillis;
_finishedLogRecords = [];
_timer;
_shutdownOnce;
constructor(_exporter, config) {
this._exporter = _exporter;
this._maxExportBatchSize =
config?.maxExportBatchSize ??
getNumberFromEnv('OTEL_BLRP_MAX_EXPORT_BATCH_SIZE') ??
512;
this._maxQueueSize =
config?.maxQueueSize ??
getNumberFromEnv('OTEL_BLRP_MAX_QUEUE_SIZE') ??
2048;
this._scheduledDelayMillis =
config?.scheduledDelayMillis ??
getNumberFromEnv('OTEL_BLRP_SCHEDULE_DELAY') ??
5000;
this._exportTimeoutMillis =
config?.exportTimeoutMillis ??
getNumberFromEnv('OTEL_BLRP_EXPORT_TIMEOUT') ??
30000;
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) => {
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler(result.error ??
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 => resource.waitForAsyncAttributes?.())).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,72 @@
/*
* 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) {
return {
resource: {
attributes: logRecord.resource.attributes,
},
instrumentationScope: logRecord.instrumentationScope,
timestamp: hrTimeToMicroseconds(logRecord.hrTime),
traceId: logRecord.spanContext?.traceId,
spanId: logRecord.spanContext?.spanId,
traceFlags: logRecord.spanContext?.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?.({ 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,SAAS,CAAC,WAAW,EAAE,OAAO;YACvC,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE,MAAM;YACrC,UAAU,EAAE,SAAS,CAAC,WAAW,EAAE,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,EAAE,CAAC,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,51 @@
/*
* 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 {
_finishedLogRecords = [];
/**
* Indicates if the exporter has been "shutdown."
* When false, exported log records will not be stored in-memory.
*/
_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;IAC5B,mBAAmB,GAAwB,EAAE,CAAC;IAEtD;;;OAGG;IACO,QAAQ,GAAG,KAAK,CAAC;IAEpB,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

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