Skip to content

Commit

Permalink
chore(instrumentation-fs): incorporate changes from open-telemetry#1332
Browse files Browse the repository at this point in the history
  • Loading branch information
mhassan1 committed Feb 17, 2023
1 parent 5601545 commit 8af53f5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions plugins/node/instrumentation-fs/test/fsPromises.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Instrumentation from '../src';
import * as sinon from 'sinon';
import type * as FSPromisesType from 'fs/promises';
import tests, { FsFunction, TestCase, TestCreator } from './definitions';
import type { FPMember, EndHook } from '../src/types';
import type { FMember, FPMember, EndHook } from '../src/types';

const supportsPromises =
parseInt(process.versions.node.split('.')[0], 10) >= 14;
Expand Down Expand Up @@ -67,13 +67,25 @@ if (supportsPromises) {
context.disable();
});

const promiseTest: TestCreator = (
const makeRootSpanName = (name: FMember): string => {
let rsn: string;
if (Array.isArray(name)) {
rsn = `${name[0]}.${name[1]}`;
} else {
rsn = `${name}`;
}
rsn = `${rsn} test span`;
return rsn;
};

const promiseTest: TestCreator<FPMember> = (
name: FPMember,
args,
{ error, result, resultAsError = null },
{ error, result, resultAsError = null, hasPromiseVersion = true },
spans
) => {
const rootSpanName = `${name} test span`;
if (!hasPromiseVersion) return;
const rootSpanName = makeRootSpanName(name);
it(`promises.${name} ${error ? 'error' : 'success'}`, async () => {
const rootSpan = tracer.startSpan(rootSpanName);

Expand Down

0 comments on commit 8af53f5

Please sign in to comment.