From c3e36a6e4fef6309d0a6fbfa697ada824a089411 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Tue, 22 Feb 2022 15:48:43 -0600 Subject: [PATCH 1/9] feat(otlp-grpc-exporter): add compression configuration to exporter Signed-off-by: Svetlana Brennan --- .../src/OTLPExporterNodeBase.ts | 5 +++- .../exporter-trace-otlp-grpc/src/types.ts | 6 +++++ packages/exporter-trace-otlp-grpc/src/util.ts | 13 +++++++++- .../test/util.test.ts | 24 ++++++++++++++++++- .../src/utils/environment.ts | 8 +++++++ 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/packages/exporter-trace-otlp-grpc/src/OTLPExporterNodeBase.ts b/packages/exporter-trace-otlp-grpc/src/OTLPExporterNodeBase.ts index a992a4f259..4246d78e4f 100644 --- a/packages/exporter-trace-otlp-grpc/src/OTLPExporterNodeBase.ts +++ b/packages/exporter-trace-otlp-grpc/src/OTLPExporterNodeBase.ts @@ -25,8 +25,9 @@ import { GRPCQueueItem, ServiceClientType, } from './types'; -import { ServiceClient } from './types'; +import { ServiceClient, CompressionAlgorithm } from './types'; import { getEnv, baggageUtils } from '@opentelemetry/core'; +import { configureCompression } from './util'; /** * OTLP Metric Exporter abstract base class @@ -43,6 +44,7 @@ export abstract class OTLPExporterNodeBase< metadata?: Metadata; serviceClient?: ServiceClient = undefined; private _send!: Function; + compression: CompressionAlgorithm; constructor(config: OTLPExporterConfigNode = {}) { super(config); @@ -54,6 +56,7 @@ export abstract class OTLPExporterNodeBase< for (const [k, v] of Object.entries(headers)) { this.metadata.set(k, v); } + this.compression = configureCompression(config.compression); } private _sendPromise( diff --git a/packages/exporter-trace-otlp-grpc/src/types.ts b/packages/exporter-trace-otlp-grpc/src/types.ts index e9513819e7..f518be528b 100644 --- a/packages/exporter-trace-otlp-grpc/src/types.ts +++ b/packages/exporter-trace-otlp-grpc/src/types.ts @@ -45,9 +45,15 @@ export interface OTLPExporterConfigNode extends otlpTypes.OTLPExporterConfigBase { credentials?: grpc.ChannelCredentials; metadata?: grpc.Metadata; + compression?: CompressionAlgorithm; } export enum ServiceClientType { SPANS, METRICS, } + +export enum CompressionAlgorithm { + NONE = 0, + GZIP = 2 +} diff --git a/packages/exporter-trace-otlp-grpc/src/util.ts b/packages/exporter-trace-otlp-grpc/src/util.ts index e0021ce896..54c809d64c 100644 --- a/packages/exporter-trace-otlp-grpc/src/util.ts +++ b/packages/exporter-trace-otlp-grpc/src/util.ts @@ -17,7 +17,7 @@ import * as grpc from '@grpc/grpc-js'; import * as protoLoader from '@grpc/proto-loader'; import { diag } from '@opentelemetry/api'; -import { globalErrorHandler } from '@opentelemetry/core'; +import { globalErrorHandler, getEnv } from '@opentelemetry/core'; import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http'; import * as path from 'path'; import { OTLPExporterNodeBase } from './OTLPExporterNodeBase'; @@ -26,6 +26,7 @@ import { OTLPExporterConfigNode, GRPCQueueItem, ServiceClientType, + CompressionAlgorithm } from './types'; export function onInit( @@ -125,3 +126,13 @@ export function validateAndNormalizeUrl(url: string): string { } return target.host; } + +export function configureCompression(compression: CompressionAlgorithm | undefined): CompressionAlgorithm { + if (compression) { + return compression; + } else { + const definedCompression = getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION || getEnv().OTEL_EXPORTER_OTLP_COMPRESSION; + + return definedCompression === 'gzip' ? CompressionAlgorithm.GZIP: CompressionAlgorithm.NONE; + } +} diff --git a/packages/exporter-trace-otlp-grpc/test/util.test.ts b/packages/exporter-trace-otlp-grpc/test/util.test.ts index ba08009cd5..42452850ce 100644 --- a/packages/exporter-trace-otlp-grpc/test/util.test.ts +++ b/packages/exporter-trace-otlp-grpc/test/util.test.ts @@ -18,7 +18,8 @@ import * as sinon from 'sinon'; import * as assert from 'assert'; import { diag } from '@opentelemetry/api'; -import { validateAndNormalizeUrl } from '../src/util'; +import { validateAndNormalizeUrl, configureCompression } from '../src/util'; +import { CompressionAlgorithm} from '../src/types'; // Tests added to detect breakage released in #2130 describe('validateAndNormalizeUrl()', () => { @@ -79,3 +80,24 @@ describe('validateAndNormalizeUrl()', () => { }); }); }); + +describe('configureCompression', () => { + const envSource = process.env; + it('should return none for compression', () => { + const compression = CompressionAlgorithm.NONE; + assert.strictEqual(configureCompression(compression), CompressionAlgorithm.NONE); + }); + it('should return gzip compression defined via env', () => { + envSource.OTEL_EXPORTER_OTLP_TRACES_COMPRESSION = 'gzip'; + assert.strictEqual(configureCompression(undefined),CompressionAlgorithm.GZIP); + delete envSource.OTEL_EXPORTER_OTLP_TRACES_COMPRESSION; + }); + it('should return none for compression defined via env', () => { + envSource.OTEL_EXPORTER_OTLP_TRACES_COMPRESSION = 'none'; + assert.strictEqual(configureCompression(undefined),CompressionAlgorithm.NONE); + delete envSource.OTEL_EXPORTER_OTLP_TRACES_COMPRESSION; + }); + it('should return none for compression when no compression is set', () => { + assert.strictEqual(configureCompression(undefined),CompressionAlgorithm.NONE); + }); +}); diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index e3bcfd8623..1d4553a712 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -84,6 +84,10 @@ export type ENVIRONMENT = { OTEL_TRACES_EXPORTER?: string; OTEL_TRACES_SAMPLER_ARG?: string; OTEL_TRACES_SAMPLER?: string; + // temp + OTEL_EXPORTER_OTLP_COMPRESSION?: string, + OTEL_EXPORTER_OTLP_TRACES_COMPRESSION?: string, + OTEL_EXPORTER_OTLP_METRICS_COMPRESSION?: string } & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS; @@ -135,6 +139,10 @@ export const DEFAULT_ENVIRONMENT: Required = { OTEL_TRACES_EXPORTER: 'none', OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn, OTEL_TRACES_SAMPLER_ARG: '', + // temp + OTEL_EXPORTER_OTLP_COMPRESSION: '', + OTEL_EXPORTER_OTLP_TRACES_COMPRESSION: '', + OTEL_EXPORTER_OTLP_METRICS_COMPRESSION: '' }; /** From e9d3e04ccbc6361c14d0b418687339b76c5b9209 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Wed, 23 Feb 2022 14:35:01 -0600 Subject: [PATCH 2/9] feat(otlp-grpc-exporter): add compression to service client and add test Signed-off-by: Svetlana Brennan --- packages/exporter-trace-otlp-grpc/src/util.ts | 4 ++ .../test/OTLPTraceExporter.test.ts | 52 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/packages/exporter-trace-otlp-grpc/src/util.ts b/packages/exporter-trace-otlp-grpc/src/util.ts index 54c809d64c..30296e3ab8 100644 --- a/packages/exporter-trace-otlp-grpc/src/util.ts +++ b/packages/exporter-trace-otlp-grpc/src/util.ts @@ -51,17 +51,21 @@ export function onInit( .then(packageDefinition => { const packageObject: any = grpc.loadPackageDefinition(packageDefinition); + const selectedCompressionAlgo = { 'grpc.default_compression_algorithm': collector.compression }; + if (collector.getServiceClientType() === ServiceClientType.SPANS) { collector.serviceClient = new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( collector.url, credentials, + selectedCompressionAlgo, ); } else { collector.serviceClient = new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( collector.url, credentials, + selectedCompressionAlgo, ); } diff --git a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts index 2d17bf9f78..f1179b6552 100644 --- a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts +++ b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts @@ -36,6 +36,8 @@ import { mockedReadableSpan, } from './traceHelper'; +import { CompressionAlgorithm } from '../src/types'; + const traceServiceProtoPath = 'opentelemetry/proto/collector/trace/v1/trace_service.proto'; const includeDirs = [path.resolve(__dirname, '../protos')]; @@ -198,6 +200,56 @@ const testCollectorExporter = (params: TestParams) => }, 200); }); }); + describe('export - with gzip compression', () => { + beforeEach(() => { + const credentials = params.useTLS + ? grpc.credentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) + : undefined; + collectorExporter = new OTLPTraceExporter({ + url: 'grpcs://' + address, + credentials, + metadata: params.metadata, + compression: CompressionAlgorithm.GZIP, + }); + + const provider = new BasicTracerProvider(); + provider.addSpanProcessor(new SimpleSpanProcessor(collectorExporter)); + }); + it('should successfully send the spans', done => { + const responseSpy = sinon.spy(); + const spans = [Object.assign({}, mockedReadableSpan)]; + collectorExporter.export(spans, responseSpy); + setTimeout(() => { + assert.ok( + typeof exportedData !== 'undefined', + 'resource' + " doesn't exist" + ); + let spans; + let resource; + if (exportedData) { + spans = exportedData.instrumentationLibrarySpans[0].spans; + resource = exportedData.resource; + ensureExportedSpanIsCorrect(spans[0]); + + assert.ok( + typeof resource !== 'undefined', + "resource doesn't exist" + ); + if (resource) { + ensureResourceIsCorrect(resource); + } + } + if (params.metadata && reqMetadata) { + ensureMetadataIsCorrect(reqMetadata, params.metadata); + } + done(); + }, 200); + }); + }); }); describe('OTLPTraceExporter - node (getDefaultUrl)', () => { From 836254f842a77adee77f1d8d187edcace65b95aa Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Wed, 2 Mar 2022 15:42:55 -0600 Subject: [PATCH 3/9] feat(otlp-grpc-exporter): fix time on a test Signed-off-by: Svetlana Brennan --- .../exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts index f1179b6552..3bd68ccfe3 100644 --- a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts +++ b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts @@ -247,7 +247,7 @@ const testCollectorExporter = (params: TestParams) => ensureMetadataIsCorrect(reqMetadata, params.metadata); } done(); - }, 200); + }, 500); }); }); }); From 6aba7553edf2ef614dce02360b680bc8f85d4dd0 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Wed, 2 Mar 2022 16:07:07 -0600 Subject: [PATCH 4/9] feat(otlp-grpc-exporter): update readme Signed-off-by: Svetlana Brennan --- packages/exporter-trace-otlp-grpc/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/exporter-trace-otlp-grpc/README.md b/packages/exporter-trace-otlp-grpc/README.md index 85e7b66316..59ef47b0ca 100644 --- a/packages/exporter-trace-otlp-grpc/README.md +++ b/packages/exporter-trace-otlp-grpc/README.md @@ -107,6 +107,25 @@ provider.register(); Note, that this will only work if TLS is also configured on the server. +By default no compression will be used. To use compression, add it to the `collectorOptions` or with environment variables. Supported compression options: `gzip` and `none`. + +```js +// define compression via config +const { CompressionAlgorithm } = require('@opentelemetry/exporter-trace-otlp-grpc'); + +const collectorOptions = { + // url is optional and can be omitted - default is localhost:4317 + url: ':', + metadata, // // an optional grpc.Metadata object to be sent with each request + compression: CompressionAlgorithm.GZIP, +}; +const exporter = new OTLPTraceExporter(collectorOptions); + +// or define via environment variables +OTEL_EXPORTER_OTLP_TRACES_COMPRESSION=gzip +``` + > Providing `compression` with `collectorOptions` takes precedence and overrides compression set with environment variables. `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` takes precedence and overrides `OTEL_EXPORTER_OTLP_COMPRESSION`. + ## Running opentelemetry-collector locally to see the traces 1. Go to examples/otlp-exporter-node From 47895a8cb1f2c7358d47643839d57edb57a67345 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Wed, 2 Mar 2022 16:25:39 -0600 Subject: [PATCH 5/9] feat(otlp-grpc-exporter): lint fixes Signed-off-by: Svetlana Brennan --- packages/exporter-trace-otlp-grpc/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/exporter-trace-otlp-grpc/README.md b/packages/exporter-trace-otlp-grpc/README.md index 59ef47b0ca..20b56b79f7 100644 --- a/packages/exporter-trace-otlp-grpc/README.md +++ b/packages/exporter-trace-otlp-grpc/README.md @@ -107,7 +107,7 @@ provider.register(); Note, that this will only work if TLS is also configured on the server. -By default no compression will be used. To use compression, add it to the `collectorOptions` or with environment variables. Supported compression options: `gzip` and `none`. +By default no compression will be used. To use compression, add it to the `collectorOptions` or with environment variables. Supported compression options: `gzip` and `none`. ```js // define compression via config @@ -124,6 +124,7 @@ const exporter = new OTLPTraceExporter(collectorOptions); // or define via environment variables OTEL_EXPORTER_OTLP_TRACES_COMPRESSION=gzip ``` + > Providing `compression` with `collectorOptions` takes precedence and overrides compression set with environment variables. `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` takes precedence and overrides `OTEL_EXPORTER_OTLP_COMPRESSION`. ## Running opentelemetry-collector locally to see the traces From abf54e2d1c3e98abeff1020ca74b8fe039b4dbbc Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Wed, 9 Mar 2022 10:31:30 -0600 Subject: [PATCH 6/9] feat(otlp-grpc-exporter): update comments and notes in readme Signed-off-by: Svetlana Brennan --- packages/exporter-trace-otlp-grpc/README.md | 13 +++++++++---- packages/exporter-trace-otlp-grpc/src/types.ts | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/exporter-trace-otlp-grpc/README.md b/packages/exporter-trace-otlp-grpc/README.md index 20b56b79f7..28521d2ae2 100644 --- a/packages/exporter-trace-otlp-grpc/README.md +++ b/packages/exporter-trace-otlp-grpc/README.md @@ -107,10 +107,9 @@ provider.register(); Note, that this will only work if TLS is also configured on the server. -By default no compression will be used. To use compression, add it to the `collectorOptions` or with environment variables. Supported compression options: `gzip` and `none`. +By default no compression will be used. To use compression, set it programmatically in `collectorOptions` or with environment variables. Supported compression options: `gzip` and `none`. ```js -// define compression via config const { CompressionAlgorithm } = require('@opentelemetry/exporter-trace-otlp-grpc'); const collectorOptions = { @@ -120,12 +119,18 @@ const collectorOptions = { compression: CompressionAlgorithm.GZIP, }; const exporter = new OTLPTraceExporter(collectorOptions); +``` + + > Providing `compression` with `collectorOptions` takes precedence and overrides compression set with environment variables. + +## Environment Variable Configuration +Set compression with environment variables. -// or define via environment variables +```shell OTEL_EXPORTER_OTLP_TRACES_COMPRESSION=gzip ``` - > Providing `compression` with `collectorOptions` takes precedence and overrides compression set with environment variables. `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` takes precedence and overrides `OTEL_EXPORTER_OTLP_COMPRESSION`. + > Compression set programatically in `collectorOptions` takes precedence over compression set with environment variables. `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` takes precedence and overrides `OTEL_EXPORTER_OTLP_COMPRESSION`. ## Running opentelemetry-collector locally to see the traces diff --git a/packages/exporter-trace-otlp-grpc/src/types.ts b/packages/exporter-trace-otlp-grpc/src/types.ts index f518be528b..34977f8fd2 100644 --- a/packages/exporter-trace-otlp-grpc/src/types.ts +++ b/packages/exporter-trace-otlp-grpc/src/types.ts @@ -53,6 +53,9 @@ export enum ServiceClientType { METRICS, } +/** + * These values are defined by grpc client + */ export enum CompressionAlgorithm { NONE = 0, GZIP = 2 From 4a3d7d8032d041745286531c30eeb2a5bb0484ce Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Wed, 9 Mar 2022 15:56:32 -0600 Subject: [PATCH 7/9] feat(otlp-grpc-exporter): fix lint and add test Signed-off-by: Svetlana Brennan --- packages/exporter-trace-otlp-grpc/README.md | 5 +++-- .../test/OTLPTraceExporter.test.ts | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/exporter-trace-otlp-grpc/README.md b/packages/exporter-trace-otlp-grpc/README.md index 28521d2ae2..1ce3b37ada 100644 --- a/packages/exporter-trace-otlp-grpc/README.md +++ b/packages/exporter-trace-otlp-grpc/README.md @@ -121,16 +121,17 @@ const collectorOptions = { const exporter = new OTLPTraceExporter(collectorOptions); ``` - > Providing `compression` with `collectorOptions` takes precedence and overrides compression set with environment variables. + > Providing `compression` with `collectorOptions` takes precedence and overrides compression set with environment variables. ## Environment Variable Configuration + Set compression with environment variables. ```shell OTEL_EXPORTER_OTLP_TRACES_COMPRESSION=gzip ``` - > Compression set programatically in `collectorOptions` takes precedence over compression set with environment variables. `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` takes precedence and overrides `OTEL_EXPORTER_OTLP_COMPRESSION`. + > Compression set programatically in `collectorOptions` takes precedence over compression set with environment variables. `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` takes precedence and overrides `OTEL_EXPORTER_OTLP_COMPRESSION`. ## Running opentelemetry-collector locally to see the traces diff --git a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts index 3bd68ccfe3..5e47677285 100644 --- a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts +++ b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts @@ -250,6 +250,27 @@ const testCollectorExporter = (params: TestParams) => }, 500); }); }); + describe('Trace Exporter with compression', () => { + const envSource = process.env; + it('should return gzip compression algorithm on exporter', () => { + const credentials = params.useTLS + ? grpc.credentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) + : undefined; + + envSource.OTEL_EXPORTER_OTLP_COMPRESSION='gzip'; + collectorExporter = new OTLPTraceExporter({ + url: 'grpcs://' + address, + credentials, + metadata: params.metadata, + }); + assert.strictEqual(collectorExporter.compression, CompressionAlgorithm.GZIP); + delete envSource.OTEL_EXPORTER_OTLP_COMPRESSION; + }); + }); }); describe('OTLPTraceExporter - node (getDefaultUrl)', () => { From 7360d604cc50a4832bda9cb111ecc87f1bae41f2 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Tue, 15 Mar 2022 10:54:39 -0500 Subject: [PATCH 8/9] Update packages/exporter-trace-otlp-grpc/src/util.ts Co-authored-by: legendecas --- packages/exporter-trace-otlp-grpc/src/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/exporter-trace-otlp-grpc/src/util.ts b/packages/exporter-trace-otlp-grpc/src/util.ts index 30296e3ab8..b490d21a48 100644 --- a/packages/exporter-trace-otlp-grpc/src/util.ts +++ b/packages/exporter-trace-otlp-grpc/src/util.ts @@ -58,7 +58,7 @@ export function onInit( new packageObject.opentelemetry.proto.collector.trace.v1.TraceService( collector.url, credentials, - selectedCompressionAlgo, + options, ); } else { collector.serviceClient = From dbf78fcf1224d05eee78e32c0f4d2437fe733a43 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan Date: Tue, 15 Mar 2022 11:37:30 -0500 Subject: [PATCH 9/9] feat(otlp-grpc-exporter): fix lint Signed-off-by: Svetlana Brennan --- packages/exporter-trace-otlp-grpc/src/util.ts | 4 +-- .../test/OTLPTraceExporter.test.ts | 26 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/exporter-trace-otlp-grpc/src/util.ts b/packages/exporter-trace-otlp-grpc/src/util.ts index b490d21a48..8adc3dba01 100644 --- a/packages/exporter-trace-otlp-grpc/src/util.ts +++ b/packages/exporter-trace-otlp-grpc/src/util.ts @@ -51,7 +51,7 @@ export function onInit( .then(packageDefinition => { const packageObject: any = grpc.loadPackageDefinition(packageDefinition); - const selectedCompressionAlgo = { 'grpc.default_compression_algorithm': collector.compression }; + const options = { 'grpc.default_compression_algorithm': collector.compression }; if (collector.getServiceClientType() === ServiceClientType.SPANS) { collector.serviceClient = @@ -65,7 +65,7 @@ export function onInit( new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService( collector.url, credentials, - selectedCompressionAlgo, + options, ); } diff --git a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts index 5e47677285..412dfd822d 100644 --- a/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts +++ b/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts @@ -253,20 +253,20 @@ const testCollectorExporter = (params: TestParams) => describe('Trace Exporter with compression', () => { const envSource = process.env; it('should return gzip compression algorithm on exporter', () => { - const credentials = params.useTLS - ? grpc.credentials.createSsl( - fs.readFileSync('./test/certs/ca.crt'), - fs.readFileSync('./test/certs/client.key'), - fs.readFileSync('./test/certs/client.crt') - ) - : undefined; + const credentials = params.useTLS + ? grpc.credentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) + : undefined; - envSource.OTEL_EXPORTER_OTLP_COMPRESSION='gzip'; - collectorExporter = new OTLPTraceExporter({ - url: 'grpcs://' + address, - credentials, - metadata: params.metadata, - }); + envSource.OTEL_EXPORTER_OTLP_COMPRESSION='gzip'; + collectorExporter = new OTLPTraceExporter({ + url: 'grpcs://' + address, + credentials, + metadata: params.metadata, + }); assert.strictEqual(collectorExporter.compression, CompressionAlgorithm.GZIP); delete envSource.OTEL_EXPORTER_OTLP_COMPRESSION; });