-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add test to tracing-node libs (#100)
* feat: add test to tracing-node libs * chore: application version bump * chore: updated JSDoc returns
- Loading branch information
Showing
4 changed files
with
182 additions
and
20 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
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,44 @@ | ||
const assert = require('assert'); | ||
const sinon = require('sinon'); | ||
|
||
// Mocking OpenTelemetry and its dependencies | ||
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); | ||
const { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } = require('@opentelemetry/core'); | ||
|
||
const { setupTracing } = require('./index'); | ||
|
||
// Mocking OpenTelemetry and its dependencies | ||
sinon.stub(NodeTracerProvider.prototype, 'addSpanProcessor'); | ||
sinon.stub(NodeTracerProvider.prototype, 'register'); | ||
sinon.stub(CompositePropagator.prototype, 'constructor'); | ||
sinon.stub(W3CBaggagePropagator.prototype, 'constructor'); | ||
sinon.stub(W3CTraceContextPropagator.prototype, 'constructor'); | ||
|
||
// Test case for setupTracing function | ||
function testSetupTracing() { | ||
const serviceName = 'test-service'; | ||
const tracer = setupTracing(serviceName); | ||
|
||
// Ensure that setupTracing returns a valid tracer | ||
assert(tracer, 'Tracer should exist'); | ||
|
||
console.log('Setup Tracing test passed successfully'); | ||
} | ||
|
||
// Test case for setupTracing function with optional parameters | ||
function testSetupTracingWithOptionalParams() { | ||
const serviceName = 'test-service'; | ||
const appName = 'test-app'; | ||
const endpoint = 'https://your-collector-endpoint'; // Provide your collector endpoint here | ||
|
||
const tracer = setupTracing(serviceName, appName, endpoint); | ||
|
||
// Ensure that setupTracing with optional parameters returns a valid tracer | ||
assert(tracer, 'Tracer should exist'); | ||
|
||
console.log('Setup Tracing with optional params test passed successfully'); | ||
} | ||
|
||
// Run the tests | ||
testSetupTracing(); | ||
testSetupTracingWithOptionalParams(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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