@@ -22,7 +22,7 @@ import * as fs from 'fs';
22
22
import * as grpc from '@grpc/grpc-js' ;
23
23
import * as path from 'path' ;
24
24
import * as sinon from 'sinon' ;
25
- import { OTLPLogsExporter } from '../src' ;
25
+ import { OTLPLogExporter } from '../src' ;
26
26
27
27
import {
28
28
ensureExportedLogRecordIsCorrect ,
@@ -55,10 +55,10 @@ const metadata = new grpc.Metadata();
55
55
metadata . set ( 'k' , 'v' ) ;
56
56
57
57
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 ;
62
62
let server : grpc . Server ;
63
63
let exportedData : IResourceLogs | undefined ;
64
64
let reqMetadata : grpc . Metadata | undefined ;
@@ -122,7 +122,7 @@ const testCollectorExporter = (params: TestParams) =>
122
122
fs . readFileSync ( './test/certs/client.crt' )
123
123
)
124
124
: grpc . credentials . createInsecure ( ) ;
125
- collectorExporter = new OTLPLogsExporter ( {
125
+ collectorExporter = new OTLPLogExporter ( {
126
126
url : 'https://' + address ,
127
127
credentials,
128
128
metadata : params . metadata ,
@@ -140,7 +140,7 @@ const testCollectorExporter = (params: TestParams) =>
140
140
it ( 'should warn about headers when using grpc' , ( ) => {
141
141
// Need to stub/spy on the underlying logger as the 'diag' instance is global
142
142
const spyLoggerWarn = sinon . stub ( diag , 'warn' ) ;
143
- collectorExporter = new OTLPLogsExporter ( {
143
+ collectorExporter = new OTLPLogExporter ( {
144
144
url : `http://${ address } ` ,
145
145
headers : {
146
146
foo : 'bar' ,
@@ -151,7 +151,7 @@ const testCollectorExporter = (params: TestParams) =>
151
151
} ) ;
152
152
it ( 'should warn about path in url' , ( ) => {
153
153
const spyLoggerWarn = sinon . stub ( diag , 'warn' ) ;
154
- collectorExporter = new OTLPLogsExporter ( {
154
+ collectorExporter = new OTLPLogExporter ( {
155
155
url : `http://${ address } /v1/logs` ,
156
156
} ) ;
157
157
const args = spyLoggerWarn . args [ 0 ] ;
@@ -198,7 +198,7 @@ const testCollectorExporter = (params: TestParams) =>
198
198
)
199
199
: grpc . credentials . createInsecure ( ) ;
200
200
201
- const collectorExporterWithTimeout = new OTLPLogsExporter ( {
201
+ const collectorExporterWithTimeout = new OTLPLogExporter ( {
202
202
url : 'grpcs://' + address ,
203
203
credentials,
204
204
metadata : params . metadata ,
@@ -229,7 +229,7 @@ const testCollectorExporter = (params: TestParams) =>
229
229
fs . readFileSync ( './test/certs/client.crt' )
230
230
)
231
231
: grpc . credentials . createInsecure ( ) ;
232
- collectorExporter = new OTLPLogsExporter ( {
232
+ collectorExporter = new OTLPLogExporter ( {
233
233
url : 'https://' + address ,
234
234
credentials,
235
235
metadata : params . metadata ,
@@ -272,7 +272,7 @@ const testCollectorExporter = (params: TestParams) =>
272
272
: grpc . credentials . createInsecure ( ) ;
273
273
274
274
envSource . OTEL_EXPORTER_OTLP_COMPRESSION = 'gzip' ;
275
- collectorExporter = new OTLPLogsExporter ( {
275
+ collectorExporter = new OTLPLogExporter ( {
276
276
url : 'https://' + address ,
277
277
credentials,
278
278
metadata : params . metadata ,
@@ -286,17 +286,17 @@ const testCollectorExporter = (params: TestParams) =>
286
286
} ) ;
287
287
} ) ;
288
288
289
- describe ( 'OTLPLogsExporter - node (getDefaultUrl)' , ( ) => {
289
+ describe ( 'OTLPLogExporter - node (getDefaultUrl)' , ( ) => {
290
290
it ( 'should default to localhost' , done => {
291
- const collectorExporter = new OTLPLogsExporter ( { } ) ;
291
+ const collectorExporter = new OTLPLogExporter ( { } ) ;
292
292
setTimeout ( ( ) => {
293
293
assert . strictEqual ( collectorExporter [ 'url' ] , 'localhost:4317' ) ;
294
294
done ( ) ;
295
295
} ) ;
296
296
} ) ;
297
297
it ( 'should keep the URL if included' , done => {
298
298
const url = 'http://foo.bar.com' ;
299
- const collectorExporter = new OTLPLogsExporter ( { url } ) ;
299
+ const collectorExporter = new OTLPLogExporter ( { url } ) ;
300
300
setTimeout ( ( ) => {
301
301
assert . strictEqual ( collectorExporter [ 'url' ] , 'foo.bar.com' ) ;
302
302
done ( ) ;
@@ -308,21 +308,21 @@ describe('when configuring via environment', () => {
308
308
const envSource = process . env ;
309
309
it ( 'should use url defined in env' , ( ) => {
310
310
envSource . OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar' ;
311
- const collectorExporter = new OTLPLogsExporter ( ) ;
311
+ const collectorExporter = new OTLPLogExporter ( ) ;
312
312
assert . strictEqual ( collectorExporter . url , 'foo.bar' ) ;
313
313
envSource . OTEL_EXPORTER_OTLP_ENDPOINT = '' ;
314
314
} ) ;
315
315
it ( 'should override global exporter url with signal url defined in env' , ( ) => {
316
316
envSource . OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar' ;
317
317
envSource . OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.logs' ;
318
- const collectorExporter = new OTLPLogsExporter ( ) ;
318
+ const collectorExporter = new OTLPLogExporter ( ) ;
319
319
assert . strictEqual ( collectorExporter . url , 'foo.logs' ) ;
320
320
envSource . OTEL_EXPORTER_OTLP_ENDPOINT = '' ;
321
321
envSource . OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = '' ;
322
322
} ) ;
323
323
it ( 'should use headers defined via env' , ( ) => {
324
324
envSource . OTEL_EXPORTER_OTLP_HEADERS = 'foo=bar' ;
325
- const collectorExporter = new OTLPLogsExporter ( ) ;
325
+ const collectorExporter = new OTLPLogExporter ( ) ;
326
326
assert . deepStrictEqual ( collectorExporter . metadata ?. get ( 'foo' ) , [ 'bar' ] ) ;
327
327
envSource . OTEL_EXPORTER_OTLP_HEADERS = '' ;
328
328
} ) ;
@@ -332,7 +332,7 @@ describe('when configuring via environment', () => {
332
332
metadata . set ( 'goo' , 'lol' ) ;
333
333
envSource . OTEL_EXPORTER_OTLP_HEADERS = 'foo=jar,bar=foo' ;
334
334
envSource . OTEL_EXPORTER_OTLP_LOGS_HEADERS = 'foo=boo' ;
335
- const collectorExporter = new OTLPLogsExporter ( { metadata } ) ;
335
+ const collectorExporter = new OTLPLogExporter ( { metadata } ) ;
336
336
assert . deepStrictEqual ( collectorExporter . metadata ?. get ( 'foo' ) , [ 'boo' ] ) ;
337
337
assert . deepStrictEqual ( collectorExporter . metadata ?. get ( 'bar' ) , [ 'foo' ] ) ;
338
338
assert . deepStrictEqual ( collectorExporter . metadata ?. get ( 'goo' ) , [ 'lol' ] ) ;
0 commit comments