Skip to content
Draft
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
445 changes: 176 additions & 269 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* (c) Copyright IBM Corp. 2025
*/

'use strict';

// NOTE: c8 bug https://github.com/bcoe/c8/issues/166
process.on('SIGTERM', () => {
process.disconnect();
process.exit(0);
});

require('../../../../src')();

const express = require('express');
const fs = require('fs');
const path = require('path');
const port = require('../../../test_util/app-port')();
const app = express();
const logPrefix = `FS Express App (${process.pid}):\t`;

app.get('/', (req, res) => {
res.sendStatus(200);
});

app.get('/fs-read', (req, res) => {
try {
const content = fs.readFileSync(path.join(__dirname, '../test.js'), 'utf8');
log(`Read file with size: ${content.length}`);

const stats = fs.statSync(path.join(__dirname, '../test.js'));
log(`File stats: ${JSON.stringify(stats.size)}`);

res.send({ success: true, size: content.length });
} catch (err) {
res.status(500).send({ error: err.message });
}
});

app.listen(port, () => {
log(`Listening on port: ${port}`);
});

function log() {
const args = Array.prototype.slice.call(arguments);
args[0] = logPrefix + args[0];
// eslint-disable-next-line no-console
console.log.apply(console, args);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "opentelemetry-api-version-conflict-test",
"version": "1.0.0",
"description": "Test with different OpenTelemetry API version than our collector package",
"main": "app.js",
"private": true,
"dependencies": {
"@opentelemetry/api": "1.0.0"
}
}
9 changes: 1 addition & 8 deletions packages/collector/test/tracing/opentelemetry/fs-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ process.on('SIGTERM', () => {
process.exit(0);
});

const expect = require('chai').expect;

/**
* We install the latest version of the collector here locally.
* This ensures we are using the Opentelemetry production dependencies.
*/
expect(require.resolve('@instana/collector')).to.contain('opentelemetry/node_modules/@instana/collector');
require('@instana/collector')();
require('../../../src')();

const express = require('express');
const fs = require('fs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ process.on('SIGTERM', () => {

const opentelemetryDisabled = process.env.INSTANA_DISABLE_USE_OPENTELEMETRY === 'true';

require('@instana/collector')({
require('../../../src')({
tracing: {
useOpentelemetry: !opentelemetryDisabled
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* (c) Copyright IBM Corp. 2025
*/

'use strict';

// NOTE: c8 bug https://github.com/bcoe/c8/issues/166
process.on('SIGTERM', () => {
process.disconnect();
process.exit(0);
});

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const { FsInstrumentation } = require('@opentelemetry/instrumentation-fs');
const { Resource } = require('@opentelemetry/resources');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
const api = require('@opentelemetry/api');

const provider = new NodeTracerProvider({
resource: new Resource({
[ATTR_SERVICE_NAME]: 'otel-sdk-test-service'
})
});

provider.register();

registerInstrumentations({
instrumentations: [new HttpInstrumentation(), new FsInstrumentation()]
});

const tracer = api.trace.getTracer('otel-sdk-app-tracer');

require('../../../../src')();

const express = require('express');
const fs = require('fs');
const path = require('path');
const port = require('../../../test_util/app-port')();
const app = express();
const logPrefix = `OTel SDK App (${process.pid}):\t`;

app.get('/', (req, res) => {
res.sendStatus(200);
});

app.get('/otel-sdk-fs', (req, res) => {
// To verify the OpenTelemetry SDK is active, we create an explicit span
// We assert in the test that this span is present in the response
const span = tracer.startSpan('explicit-otel-operation');

try {
// Use fs operation which should be traced by both OpenTelemetry SDK and Instana
const content = fs.readFileSync(path.join(__dirname, '../test.js'), 'utf8');
log(`Read file with size: ${content.length}`);

const stats = fs.statSync(path.join(__dirname, '../test.js'));
log(`File stats: ${JSON.stringify(stats.size)}`);
span.end();
res.send({ success: true, size: content.length, otelspan: span });
} catch (err) {
span.recordException(err);
span.end();
res.status(500).send({ error: err.message });
}
});

app.listen(port, () => {
log(`Listening on port: ${port}`);
});

function log() {
const args = Array.prototype.slice.call(arguments);
args[0] = logPrefix + args[0];
// eslint-disable-next-line no-console
console.log.apply(console, args);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "instana-opentelemetry-sdk-test",
"version": "1.0.0",
"description": "Test for our collector with active OpenTelemetry SDK",
"main": "app.js",
"private": true,
"dependencies": {
"@opentelemetry/api": "1.4.1",
"@opentelemetry/instrumentation": "^0.41.2",
"@opentelemetry/instrumentation-fs": "^0.7.2",
"@opentelemetry/instrumentation-http": "^0.41.2",
"@opentelemetry/resources": "^1.15.2",
"@opentelemetry/sdk-trace-node": "^1.15.2",
"@opentelemetry/semantic-conventions": "^1.15.2",
"express": "^4.17.1"
}
}
7 changes: 0 additions & 7 deletions packages/collector/test/tracing/opentelemetry/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/collector/test/tracing/opentelemetry/preinstall.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ process.on('SIGTERM', () => {
const agentPort = process.env.INSTANA_AGENT_PORT;
const opentelemetryDisabled = process.env.INSTANA_DISABLE_USE_OPENTELEMETRY === 'true';

require('@instana/collector')({
require('../../../src')({
tracing: {
useOpentelemetry: !opentelemetryDisabled
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ process.on('SIGTERM', () => {
process.exit(0);
});

require('@instana/collector')();
require('../../../src')();

const socketioclient = require('socket.io-client');
const express = require('express');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ process.on('SIGTERM', () => {
process.exit(0);
});

require('@instana/collector')();
require('../../../src')();

const express = require('express');
const port = require('../../test_util/app-port')();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ process.on('SIGTERM', () => {
});

/* eslint-disable no-console */
require('@instana/collector')({
require('../../../src')({
tracing: {
useOpentelemetry: process.env.OTEL_ENABLED
}
Expand Down
Loading