Skip to content

Commit

Permalink
reduce log options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankcorn committed Feb 12, 2024
1 parent 6bdbf73 commit 5a36da3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.


The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

* adjust log options to reduce noise

## [0.3.5] - 2024-02-12

Expand Down
33 changes: 22 additions & 11 deletions src/baselime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type BaselimeSDKOpts = {
collectorUrl?: string,
baselimeKey?: string,
service?: string,
log?: boolean,
namespace?: string,
serverless?: boolean
sampler?: Sampler
Expand All @@ -31,6 +32,7 @@ type BaselimeSDKOpts = {
* @param {string} options.namespace - The namespace of the service.
* @param {boolean} options.serverless - Whether or not the service is running in a serverless environment. Defaults to false.
* @param {Sampler} options.sampler - The OpenTelemetry sampler to use. Defaults to No Sampling.
* @param {boolean} options.log - Whether or not to enable the log exporter. Defaults to false.
*
*/
export class BaselimeSDK {
Expand Down Expand Up @@ -60,12 +62,14 @@ export class BaselimeSDK {

// configure exporters

let exporter
let exporter: OTLPTraceExporter | ConsoleSpanExporter | undefined = undefined;

if (!this.options.baselimeKey) {
console.warn('BaselimeSDK: No Baselime API key provided. Traces will be logged to the console');
exporter = new ConsoleSpanExporter();
} else {
if(!this.options.baselimeKey) {
console.warn("No Baselime API key provided. Traces will not be sent to Baselime.")
}


if (this.options.baselimeKey) {
let collectorUrl = this.options.collectorUrl;

// If the baselime extension is running, we need to use the sandbox collector.
Expand All @@ -82,13 +86,20 @@ export class BaselimeSDK {
});
}

const spanProcessor = this.options.serverless ? new SimpleSpanProcessor(exporter) : new BatchSpanProcessor(exporter, {
maxQueueSize: 100,
maxExportBatchSize: 5,
});
if (this.options.log) {
exporter = new ConsoleSpanExporter();
}


provider.addSpanProcessor(spanProcessor);
if(exporter) {
const spanProcessor = this.options.serverless ? new SimpleSpanProcessor(exporter) : new BatchSpanProcessor(exporter, {
maxQueueSize: 100,
maxExportBatchSize: 5,
});


provider.addSpanProcessor(spanProcessor);
}

provider.register();

registerInstrumentations({
Expand Down

0 comments on commit 5a36da3

Please sign in to comment.