Skip to content

chore: make dns and fs optional instrumentation #281

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

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ setupTracing({hostname: 'hostname', serviceName: 'service_name', url: 'endpoint'
| hostname | string | container / pod hostname |
| serviceName | string | service / application name |
| url | string | tracing endpoint i.e. `<schema>://<host>:<port>` |
| enableFsInstrumentation | boolean | enable FS instrumentation, default `false` |
| enableDnsInstrumentation | boolean | enable DNS instrumentation, default `false` |

## Source

Expand Down
2 changes: 1 addition & 1 deletion deployment/base/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ spec:
gitRepo:
directory: "."
repository: "https://github.com/saidsef/tracing-node.git"
revision: "dependabot-npm_and_yarn-opentelemetry-instrumentation-aws-sdk-0.50.0"
revision: "optional-dns-fs-instrumentation"
29 changes: 23 additions & 6 deletions libs/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
* @param {string} [options.serviceName=process.env.SERVICE_NAME] - The name of the service.
* @param {string} [options.url=process.env.ENDPOINT] - The endpoint URL for the tracing collector.
* @param {number} [options.concurrencyLimit=10] - The concurrency limit for the exporter.
* @param {boolean} [options.enableFsInstrumentation=false] - Enable file system instrumentation.
* @param {boolean} [options.enableDnsInstrumentation=false] - Enable DNS instrumentation.
*
* @returns {Tracer} - The tracer for the service.
*/
Expand All @@ -60,6 +62,8 @@ export function setupTracing(options = {}) {
serviceName = process.env.SERVICE_NAME,
url = process.env.ENDPOINT,
concurrencyLimit = 10,
enableFsInstrumentation = false,
enableDnsInstrumentation = false,
} = options;

// Configure exporter with the Collector endpoint - uses gRPC
Expand Down Expand Up @@ -103,18 +107,31 @@ export function setupTracing(options = {}) {
};

// Register instrumentations
registerInstrumentations({
tracerProvider: tracerProvider,
instrumentations: [
const instrumentations = [
new PinoInstrumentation(),
new HttpInstrumentation({ requireParentforOutgoingSpans: false, requireParentforIncomingSpans: false, ignoreIncomingRequestHook, }),
new ExpressInstrumentation({ ignoreIncomingRequestHook, }),
new ConnectInstrumentation(),
new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }),
new IORedisInstrumentation(),
new FsInstrumentation(),
new DnsInstrumentation(),
],
];

if (enableFsInstrumentation) {
// Enable fs instrumentation if specified
// This instrumentation is useful for tracing file system operations.
instrumentations.push(new FsInstrumentation());
}

if (enableDnsInstrumentation) {
// Enable DNS instrumentation if specified
// This instrumentation is useful for tracing DNS operations.
instrumentations.push(new DnsInstrumentation());
}

// Register instrumentations
registerInstrumentations({
tracerProvider: tracerProvider,
instrumentations: instrumentations,
});

// Return the tracer for the service
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saidsef/tracing-node",
"version": "3.4.5",
"version": "3.4.6",
"description": "tracing NodeJS - Wrapper for OpenTelemetry instrumentation packages",
"main": "libs/index.mjs",
"scripts": {
Expand Down