-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmark tests for trace OTLP transform and BatchSpanProcessor (#4218)
Co-authored-by: Marc Pichler <[email protected]>
- Loading branch information
1 parent
c478c11
commit 654638a
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
experimental/packages/otlp-transformer/test/performance/benchmark/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const Benchmark = require('benchmark'); | ||
const { createExportTraceServiceRequest } = require('../../../build/src'); | ||
const { BasicTracerProvider } = require('@opentelemetry/sdk-trace-base'); | ||
|
||
const tracerProvider = new BasicTracerProvider(); | ||
const tracer = tracerProvider.getTracer('test') | ||
|
||
const suite = new Benchmark.Suite(); | ||
|
||
const span = createSpan(); | ||
const spans = []; | ||
for (let i = 0; i < 100; i++) { | ||
spans.push(createSpan()); | ||
} | ||
|
||
suite.on('cycle', event => { | ||
console.log(String(event.target)); | ||
}); | ||
|
||
suite.add('transform 1 span', function() { | ||
createExportTraceServiceRequest([span]); | ||
}); | ||
|
||
suite.add('transform 100 spans', function() { | ||
createExportTraceServiceRequest(spans); | ||
}); | ||
|
||
suite.run(); | ||
|
||
function createSpan() { | ||
const span = tracer.startSpan('span'); | ||
span.setAttribute('aaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('bbbbbbbbbbbbbbbbbbbb', 'bbbbbbbbbbbbbbbbbbbb'); | ||
span.setAttribute('cccccccccccccccccccc', 'cccccccccccccccccccc'); | ||
span.setAttribute('dddddddddddddddddddd', 'dddddddddddddddddddd'); | ||
span.setAttribute('eeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeee'); | ||
span.setAttribute('ffffffffffffffffffff', 'ffffffffffffffffffff'); | ||
span.setAttribute('gggggggggggggggggggg', 'gggggggggggggggggggg'); | ||
span.setAttribute('hhhhhhhhhhhhhhhhhhhh', 'hhhhhhhhhhhhhhhhhhhh'); | ||
span.setAttribute('iiiiiiiiiiiiiiiiiiii', 'iiiiiiiiiiiiiiiiiiii'); | ||
span.setAttribute('jjjjjjjjjjjjjjjjjjjj', 'jjjjjjjjjjjjjjjjjjjj'); | ||
span.end(); | ||
|
||
return span; | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/opentelemetry-sdk-trace-base/test/performance/benchmark/BatchSpanProcessor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const Benchmark = require('benchmark'); | ||
const { BasicTracerProvider, BatchSpanProcessor } = require('../../../build/src'); | ||
const { ExportResultCode } = require('@opentelemetry/core'); | ||
|
||
class NoopExporter { | ||
export(spans, resultCallback) { | ||
setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0); | ||
} | ||
|
||
shutdown() { | ||
return this.forceFlush(); | ||
} | ||
|
||
forceFlush() { | ||
return Promise.resolve(); | ||
} | ||
} | ||
|
||
function createSpan() { | ||
const span = tracer.startSpan('span'); | ||
span.setAttribute('aaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('bbbbbbbbbbbbbbbbbbbb', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('cccccccccccccccccccc', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('dddddddddddddddddddd', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('eeeeeeeeeeeeeeeeeeee', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('ffffffffffffffffffff', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('gggggggggggggggggggg', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('hhhhhhhhhhhhhhhhhhhh', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('iiiiiiiiiiiiiiiiiiii', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.setAttribute('jjjjjjjjjjjjjjjjjjjj', 'aaaaaaaaaaaaaaaaaaaa'); | ||
span.end(); | ||
} | ||
|
||
const tracerProvider = new BasicTracerProvider(); | ||
tracerProvider.addSpanProcessor(new BatchSpanProcessor(new NoopExporter())); | ||
const tracer = tracerProvider.getTracer('test') | ||
|
||
const suite = new Benchmark.Suite('BatchSpanProcessor'); | ||
|
||
suite.on('cycle', event => { | ||
console.log(String(event.target)); | ||
}); | ||
|
||
suite.add('BatchSpanProcessor process span', function() { | ||
createSpan(); | ||
}); | ||
|
||
suite.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
*/ | ||
|
||
require('./span'); | ||
require('./BatchSpanProcessor'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters