Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(exporter-logs-otlp-proto): rename OTLPLogsExporter to OTLPLogEx… #4140

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to experimental packages in this project will be documented

### :boom: Breaking Change

* fix(exporter-logs-otlp-proto): change OTLPLogExporter to OTLPLogExporter [#4140](https://github.com/open-telemetry/opentelemetry-js/pull/4140) @Vunovati

### :rocket: (Enhancement)

### :bug: (Bug Fix)
Expand Down
10 changes: 5 additions & 5 deletions experimental/packages/exporter-logs-otlp-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To see documentation and sample code for the metric exporter, see the [exporter-

```js
const { LoggerProvider, SimpleLogRecordProcessor } = require('@opentelemetry/sdk-logs');
const { OTLPLogsExporter } = require('@opentelemetry/exporter-logs-otlp-proto');
const { OTLPLogExporter } = require('@opentelemetry/exporter-logs-otlp-proto');

const collectorOptions = {
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/logs
Expand All @@ -32,7 +32,7 @@ const collectorOptions = {
};

const logProvider = new LoggerProvider({resource: new Resource({'service.name': 'testApp'})});
const logExporter = new OTLPLogsExporter(collectorOptions);
const logExporter = new OTLPLogExporter(collectorOptions);
logProvider.addLogRecordProcessor(new SimpleLogRecordProcessor(exporter));

const logger = logProvider.getLogger('test_log_instrumentation');
Expand All @@ -44,7 +44,7 @@ logger.emit({

## Exporter Timeout Configuration

The OTLPLogsExporter has a timeout configuration option which is the maximum time, in milliseconds, the OTLP exporter will wait for each batch export. The default value is 10000ms.
The OTLPLogExporter has a timeout configuration option which is the maximum time, in milliseconds, the OTLP exporter will wait for each batch export. The default value is 10000ms.

To override the default timeout duration, use the following options:

Expand All @@ -57,7 +57,7 @@ To override the default timeout duration, use the following options:

> `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` takes precedence and overrides `OTEL_EXPORTER_OTLP_TIMEOUT`.

+ Provide `timeoutMillis` to OTLPLogsExporter with `collectorOptions`:
+ Provide `timeoutMillis` to OTLPLogExporter with `collectorOptions`:

```js
const collectorOptions = {
Expand All @@ -68,7 +68,7 @@ To override the default timeout duration, use the following options:
}, //an optional object containing custom headers to be sent with each request will only work with http
};

const exporter = new OTLPLogsExporter(collectorOptions);
const exporter = new OTLPLogExporter(collectorOptions);
```

> Providing `timeoutMillis` with `collectorOptions` takes precedence and overrides timeout set with environment variables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { OTLPLogsExporter } from './platform';
export { OTLPLogExporter } from './platform';
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC
/**
* Collector Trace Exporter for Web
*/
export class OTLPLogsExporter
export class OTLPLogExporter
extends OTLPProtoExporterBrowserBase<
ReadableLogRecord,
IExportLogsServiceRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { OTLPLogsExporter } from './OTLPLogsExporter';
export { OTLPLogExporter } from './OTLPLogExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { OTLPLogsExporter } from './node';
export { OTLPLogExporter } from './node';
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC
/**
* Collector Trace Exporter for Node
*/
export class OTLPLogsExporter
export class OTLPLogExporter
extends OTLPProtoExporterNodeBase<
ReadableLogRecord,
IExportLogsServiceRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

export { OTLPLogsExporter } from './OTLPLogsExporter';
export { OTLPLogExporter } from './OTLPLogExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

import * as assert from 'assert';
import * as sinon from 'sinon';
import { OTLPLogsExporter } from '../../src/platform/browser/index';
import { OTLPLogExporter } from '../../src/platform/browser/index';

describe('OTLPLogsExporter - web', () => {
let collectorLogsExporter: OTLPLogsExporter;
describe('OTLPLogExporter - web', () => {
let collectorLogsExporter: OTLPLogExporter;
describe('constructor', () => {
let onInitSpy: any;
beforeEach(() => {
onInitSpy = sinon.stub(OTLPLogsExporter.prototype, 'onInit');
onInitSpy = sinon.stub(OTLPLogExporter.prototype, 'onInit');
const collectorExporterConfig = {
hostname: 'foo',
url: 'http://foo.bar.com',
};
collectorLogsExporter = new OTLPLogsExporter(collectorExporterConfig);
collectorLogsExporter = new OTLPLogExporter(collectorExporterConfig);
});
afterEach(() => {
sinon.restore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as http from 'http';
import * as sinon from 'sinon';
import { Stream, PassThrough } from 'stream';
import * as zlib from 'zlib';
import { OTLPLogsExporter } from '../../src';
import { OTLPLogExporter } from '../../src';
import {
ensureExportLogsServiceRequestIsSet,
ensureExportedLogRecordIsCorrect,
Expand All @@ -42,8 +42,8 @@ import { ReadableLogRecord } from '@opentelemetry/sdk-logs';

let fakeRequest: PassThrough;

describe('OTLPLogsExporter - node with proto over http', () => {
let collectorExporter: OTLPLogsExporter;
describe('OTLPLogExporter - node with proto over http', () => {
let collectorExporter: OTLPLogExporter;
let collectorExporterConfig: OTLPExporterNodeConfigBase;
let logs: ReadableLogRecord[];

Expand All @@ -56,7 +56,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
const envSource = process.env;
it('should use url defined in env that ends with root path and append version and signal path', () => {
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar/';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
`${envSource.OTEL_EXPORTER_OTLP_ENDPOINT}v1/logs`
Expand All @@ -65,7 +65,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});
it('should use url defined in env without checking if path is already present', () => {
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar/v1/logs';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
`${envSource.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/logs`
Expand All @@ -74,7 +74,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});
it('should use url defined in env and append version and signal', () => {
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
`${envSource.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/logs`
Expand All @@ -84,7 +84,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
it('should override global exporter url with signal url defined in env', () => {
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar/';
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.logs/';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
Expand All @@ -94,7 +94,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});
it('should add root path when signal url defined in env contains no path and no root path', () => {
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.bar';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
`${envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT}/`
Expand All @@ -103,7 +103,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});
it('should not add root path when signal url defined in env contains root path but no path', () => {
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.bar/';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
`${envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT}`
Expand All @@ -112,7 +112,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});
it('should not add root path when signal url defined in env contains path', () => {
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.bar/v1/logs';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
`${envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT}`
Expand All @@ -121,7 +121,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});
it('should not add root path when signal url defined in env contains path and ends in /', () => {
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.bar/v1/logs/';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(
collectorExporter.url,
`${envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT}`
Expand All @@ -130,14 +130,14 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});
it('should use headers defined via env', () => {
envSource.OTEL_EXPORTER_OTLP_LOGS_HEADERS = 'foo=bar';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(collectorExporter.headers.foo, 'bar');
envSource.OTEL_EXPORTER_OTLP_HEADERS = '';
});
it('should override global headers config with signal headers defined via env', () => {
envSource.OTEL_EXPORTER_OTLP_HEADERS = 'foo=bar,bar=foo';
envSource.OTEL_EXPORTER_OTLP_LOGS_HEADERS = 'foo=boo';
const collectorExporter = new OTLPLogsExporter();
const collectorExporter = new OTLPLogExporter();
assert.strictEqual(collectorExporter.headers.foo, 'boo');
assert.strictEqual(collectorExporter.headers.bar, 'foo');
envSource.OTEL_EXPORTER_OTLP_LOGS_HEADERS = '';
Expand All @@ -156,7 +156,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
keepAlive: true,
httpAgentOptions: { keepAliveMsecs: 2000 },
};
collectorExporter = new OTLPLogsExporter(collectorExporterConfig);
collectorExporter = new OTLPLogExporter(collectorExporterConfig);
logs = [];
logs.push(Object.assign({}, mockedReadableLogRecord));
});
Expand Down Expand Up @@ -286,7 +286,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
compression: CompressionAlgorithm.GZIP,
httpAgentOptions: { keepAliveMsecs: 2000 },
};
collectorExporter = new OTLPLogsExporter(collectorExporterConfig);
collectorExporter = new OTLPLogExporter(collectorExporterConfig);
logs = [];
logs.push(Object.assign({}, mockedReadableLogRecord));
});
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('OTLPLogsExporter - node with proto over http', () => {
});

describe('export - real http request destroyed before response received', () => {
let collectorExporter: OTLPLogsExporter;
let collectorExporter: OTLPLogExporter;
let collectorExporterConfig: OTLPExporterNodeConfigBase;
let logs: ReadableLogRecord[];
const server = http.createServer((_, res) => {
Expand All @@ -351,7 +351,7 @@ describe('export - real http request destroyed before response received', () =>
url: 'http://localhost:8082',
timeoutMillis: 1,
};
collectorExporter = new OTLPLogsExporter(collectorExporterConfig);
collectorExporter = new OTLPLogExporter(collectorExporterConfig);
logs = [];
logs.push(Object.assign({}, mockedReadableLogRecord));

Expand All @@ -368,7 +368,7 @@ describe('export - real http request destroyed before response received', () =>
url: 'http://localhost:8082',
timeoutMillis: 100,
};
collectorExporter = new OTLPLogsExporter(collectorExporterConfig);
collectorExporter = new OTLPLogExporter(collectorExporterConfig);
logs = [];
logs.push(Object.assign({}, mockedReadableLogRecord));

Expand All @@ -383,7 +383,7 @@ describe('export - real http request destroyed before response received', () =>
});

describe('export - real http request destroyed after response received', () => {
let collectorExporter: OTLPLogsExporter;
let collectorExporter: OTLPLogExporter;
let collectorExporterConfig: OTLPExporterNodeConfigBase;
let logs: ReadableLogRecord[];

Expand All @@ -401,7 +401,7 @@ describe('export - real http request destroyed after response received', () => {
url: 'http://localhost:8082',
timeoutMillis: 300,
};
collectorExporter = new OTLPLogsExporter(collectorExporterConfig);
collectorExporter = new OTLPLogExporter(collectorExporterConfig);
logs = [];
logs.push(Object.assign({}, mockedReadableLogRecord));

Expand Down