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

Validate maxExportBatchSize in BatchSpanProcessorBase #3232

Merged
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ All notable changes to this project will be documented in this file.
* fix(sdk-trace-base): make span start times resistant to hrtime clock drift
[#3129](https://github.com/open-telemetry/opentelemetry-js/issues/3129)

* fix(sdk-trace-base): validate maxExportBatchSize in BatchSpanProcessorBase
[#3232](https://github.com/open-telemetry/opentelemetry-js/issues/3232)

### :books: (Refine Doc)

* docs(metrics): add missing metrics packages to SDK reference documentation [#3239](https://github.com/open-telemetry/opentelemetry-js/pull/3239) @dyladan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

import { context, Context, TraceFlags } from '@opentelemetry/api';
import {context, Context, diag, TraceFlags} from '@opentelemetry/api';
import {
BindOnceFuture,
ExportResultCode,
getEnv,
globalErrorHandler,
suppressTracing,
unrefTimer,
unrefTimer
} from '@opentelemetry/core';
import { Span } from '../Span';
import { SpanProcessor } from '../SpanProcessor';
Expand Down Expand Up @@ -63,6 +63,11 @@ export abstract class BatchSpanProcessorBase<T extends BufferConfig> implements
: env.OTEL_BSP_EXPORT_TIMEOUT;

this._shutdownOnce = new BindOnceFuture(this._shutdown, this);

if (this._maxExportBatchSize > this._maxQueueSize) {
diag.warn('BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize');
this._maxExportBatchSize = this._maxQueueSize;
}
}

forceFlush(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { diag, ROOT_CONTEXT } from '@opentelemetry/api';
import {
ExportResultCode,
loggingErrorHandler,
setGlobalErrorHandler,
setGlobalErrorHandler
} from '@opentelemetry/core';
import * as assert from 'assert';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -435,4 +435,21 @@ describe('BatchSpanProcessorBase', () => {
});
});
});

describe('maxExportBatchSize', () => {
let processor: BatchSpanProcessor;

describe('when "maxExportBatchSize" is greater than "maxQueueSize"', () => {
beforeEach(() => {
processor = new BatchSpanProcessor(
exporter,{
maxExportBatchSize: 7,
maxQueueSize: 6,
});
});
it('should match maxQueueSize', () => {
assert.equal(processor['_maxExportBatchSize'], processor['_maxQueueSize']);
});
});
});
});