Skip to content

Commit c065f7e

Browse files
authored
Merge branch 'main' into hectorhdzg/loggerconfig
2 parents 02216cb + 0471c54 commit c065f7e

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

experimental/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to experimental packages in this project will be documented
66

77
### :boom: Breaking Change
88

9+
* fix(exporter-logs-otlp-grpc): change OTLPLogsExporter to OTLPLogExporter [#3819](https://github.com/open-telemetry/opentelemetry-js/pull/3819) @fuaiyi
10+
911
### :rocket: (Enhancement)
1012

1113
* feat(instrumentation): add ESM support for instrumentation. [#3698](https://github.com/open-telemetry/opentelemetry-js/pull/3698) @JamieDanielson, @pkanal, @vmarchaud, @lizthegrey, @bengl

experimental/packages/exporter-logs-otlp-grpc/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ To see documentation and sample code for the metric exporter, see the [exporter-
2222

2323
## Logs in Node - GRPC
2424

25-
The OTLPLogsExporter in Node expects the URL to only be the hostname. It will not work with `/v1/logs`. All
25+
The OTLPLogExporter in Node expects the URL to only be the hostname. It will not work with `/v1/logs`. All
2626
options that work with trace also work with logs.
2727

2828
```js
2929
import {
3030
LoggerProvider,
3131
BatchLogRecordProcessor,
3232
} from '@opentelemetry/sdk-logs';
33-
import { OTLPLogsExporter } from '@opentelemetry/exporter-logs-otlp-grpc';
33+
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-grpc';
3434

3535
const collectorOptions = {
3636
// url is optional and can be omitted - default is http://localhost:4317
3737
url: 'http://<collector-hostname>:<port>',
3838
};
3939

40-
const loggerExporter = new OTLPLogsExporter(collectorOptions);
40+
const loggerExporter = new OTLPLogExporter(collectorOptions);
4141
const loggerProvider = new LoggerProvider();
4242

4343
loggerProvider.addLogRecordProcessor(

experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogsExporter.ts renamed to experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogExporter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
/**
3333
* OTLP Logs Exporter for Node
3434
*/
35-
export class OTLPLogsExporter
35+
export class OTLPLogExporter
3636
extends OTLPGRPCExporterNodeBase<ReadableLogRecord, IExportLogsServiceRequest>
3737
implements LogRecordExporter
3838
{

experimental/packages/exporter-logs-otlp-grpc/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
* limitations under the License.
1515
*/
1616

17-
export * from './OTLPLogsExporter';
17+
export * from './OTLPLogExporter';

experimental/packages/exporter-logs-otlp-grpc/test/OTLPLogsExporter.test.ts renamed to experimental/packages/exporter-logs-otlp-grpc/test/OTLPLogExporter.test.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as fs from 'fs';
2222
import * as grpc from '@grpc/grpc-js';
2323
import * as path from 'path';
2424
import * as sinon from 'sinon';
25-
import { OTLPLogsExporter } from '../src';
25+
import { OTLPLogExporter } from '../src';
2626

2727
import {
2828
ensureExportedLogRecordIsCorrect,
@@ -55,10 +55,10 @@ const metadata = new grpc.Metadata();
5555
metadata.set('k', 'v');
5656

5757
const testCollectorExporter = (params: TestParams) =>
58-
describe(`OTLPLogsExporter - node ${
59-
params.useTLS ? 'with' : 'without'
60-
} TLS, ${params.metadata ? 'with' : 'without'} metadata`, () => {
61-
let collectorExporter: OTLPLogsExporter;
58+
describe(`OTLPLogExporter - node ${params.useTLS ? 'with' : 'without'} TLS, ${
59+
params.metadata ? 'with' : 'without'
60+
} metadata`, () => {
61+
let collectorExporter: OTLPLogExporter;
6262
let server: grpc.Server;
6363
let exportedData: IResourceLogs | undefined;
6464
let reqMetadata: grpc.Metadata | undefined;
@@ -122,7 +122,7 @@ const testCollectorExporter = (params: TestParams) =>
122122
fs.readFileSync('./test/certs/client.crt')
123123
)
124124
: grpc.credentials.createInsecure();
125-
collectorExporter = new OTLPLogsExporter({
125+
collectorExporter = new OTLPLogExporter({
126126
url: 'https://' + address,
127127
credentials,
128128
metadata: params.metadata,
@@ -140,7 +140,7 @@ const testCollectorExporter = (params: TestParams) =>
140140
it('should warn about headers when using grpc', () => {
141141
// Need to stub/spy on the underlying logger as the 'diag' instance is global
142142
const spyLoggerWarn = sinon.stub(diag, 'warn');
143-
collectorExporter = new OTLPLogsExporter({
143+
collectorExporter = new OTLPLogExporter({
144144
url: `http://${address}`,
145145
headers: {
146146
foo: 'bar',
@@ -151,7 +151,7 @@ const testCollectorExporter = (params: TestParams) =>
151151
});
152152
it('should warn about path in url', () => {
153153
const spyLoggerWarn = sinon.stub(diag, 'warn');
154-
collectorExporter = new OTLPLogsExporter({
154+
collectorExporter = new OTLPLogExporter({
155155
url: `http://${address}/v1/logs`,
156156
});
157157
const args = spyLoggerWarn.args[0];
@@ -198,7 +198,7 @@ const testCollectorExporter = (params: TestParams) =>
198198
)
199199
: grpc.credentials.createInsecure();
200200

201-
const collectorExporterWithTimeout = new OTLPLogsExporter({
201+
const collectorExporterWithTimeout = new OTLPLogExporter({
202202
url: 'grpcs://' + address,
203203
credentials,
204204
metadata: params.metadata,
@@ -229,7 +229,7 @@ const testCollectorExporter = (params: TestParams) =>
229229
fs.readFileSync('./test/certs/client.crt')
230230
)
231231
: grpc.credentials.createInsecure();
232-
collectorExporter = new OTLPLogsExporter({
232+
collectorExporter = new OTLPLogExporter({
233233
url: 'https://' + address,
234234
credentials,
235235
metadata: params.metadata,
@@ -272,7 +272,7 @@ const testCollectorExporter = (params: TestParams) =>
272272
: grpc.credentials.createInsecure();
273273

274274
envSource.OTEL_EXPORTER_OTLP_COMPRESSION = 'gzip';
275-
collectorExporter = new OTLPLogsExporter({
275+
collectorExporter = new OTLPLogExporter({
276276
url: 'https://' + address,
277277
credentials,
278278
metadata: params.metadata,
@@ -286,17 +286,17 @@ const testCollectorExporter = (params: TestParams) =>
286286
});
287287
});
288288

289-
describe('OTLPLogsExporter - node (getDefaultUrl)', () => {
289+
describe('OTLPLogExporter - node (getDefaultUrl)', () => {
290290
it('should default to localhost', done => {
291-
const collectorExporter = new OTLPLogsExporter({});
291+
const collectorExporter = new OTLPLogExporter({});
292292
setTimeout(() => {
293293
assert.strictEqual(collectorExporter['url'], 'localhost:4317');
294294
done();
295295
});
296296
});
297297
it('should keep the URL if included', done => {
298298
const url = 'http://foo.bar.com';
299-
const collectorExporter = new OTLPLogsExporter({ url });
299+
const collectorExporter = new OTLPLogExporter({ url });
300300
setTimeout(() => {
301301
assert.strictEqual(collectorExporter['url'], 'foo.bar.com');
302302
done();
@@ -308,21 +308,21 @@ describe('when configuring via environment', () => {
308308
const envSource = process.env;
309309
it('should use url defined in env', () => {
310310
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar';
311-
const collectorExporter = new OTLPLogsExporter();
311+
const collectorExporter = new OTLPLogExporter();
312312
assert.strictEqual(collectorExporter.url, 'foo.bar');
313313
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = '';
314314
});
315315
it('should override global exporter url with signal url defined in env', () => {
316316
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar';
317317
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.logs';
318-
const collectorExporter = new OTLPLogsExporter();
318+
const collectorExporter = new OTLPLogExporter();
319319
assert.strictEqual(collectorExporter.url, 'foo.logs');
320320
envSource.OTEL_EXPORTER_OTLP_ENDPOINT = '';
321321
envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = '';
322322
});
323323
it('should use headers defined via env', () => {
324324
envSource.OTEL_EXPORTER_OTLP_HEADERS = 'foo=bar';
325-
const collectorExporter = new OTLPLogsExporter();
325+
const collectorExporter = new OTLPLogExporter();
326326
assert.deepStrictEqual(collectorExporter.metadata?.get('foo'), ['bar']);
327327
envSource.OTEL_EXPORTER_OTLP_HEADERS = '';
328328
});
@@ -332,7 +332,7 @@ describe('when configuring via environment', () => {
332332
metadata.set('goo', 'lol');
333333
envSource.OTEL_EXPORTER_OTLP_HEADERS = 'foo=jar,bar=foo';
334334
envSource.OTEL_EXPORTER_OTLP_LOGS_HEADERS = 'foo=boo';
335-
const collectorExporter = new OTLPLogsExporter({ metadata });
335+
const collectorExporter = new OTLPLogExporter({ metadata });
336336
assert.deepStrictEqual(collectorExporter.metadata?.get('foo'), ['boo']);
337337
assert.deepStrictEqual(collectorExporter.metadata?.get('bar'), ['foo']);
338338
assert.deepStrictEqual(collectorExporter.metadata?.get('goo'), ['lol']);

0 commit comments

Comments
 (0)