Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
gts fix, revert changes to mongodb instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Jul 20, 2021
1 parent 6fdf5ac commit d4c307e
Show file tree
Hide file tree
Showing 17 changed files with 146 additions and 317 deletions.
4 changes: 1 addition & 3 deletions packages/opencensus-core/src/exporters/console-exporter.ts
Expand Up @@ -67,9 +67,7 @@ export class ConsoleExporter implements Exporter {
*/
publish(spans: modelTypes.Span[]) {
spans.map(span => {
const ROOT_STR = `RootSpan: {traceId: ${span.traceId}, spanId: ${
span.id
}, name: ${span.name} }`;
const ROOT_STR = `RootSpan: {traceId: ${span.traceId}, spanId: ${span.id}, name: ${span.name} }`;
const SPANS_STR: string[] = span.spans.map(child =>
[`\t\t{spanId: ${child.id}, name: ${child.name}}`].join('\n')
);
Expand Down
24 changes: 6 additions & 18 deletions packages/opencensus-core/test/test-recorder.ts
Expand Up @@ -98,9 +98,7 @@ describe('Recorder', () => {
for (const measure of measures) {
describe(`for count aggregation data of ${measure.type} values`, () => {
for (const testCase of testCases) {
it(`should record measurements ${
testCase.description
} correctly`, () => {
it(`should record measurements ${testCase.description} correctly`, () => {
const countData: CountData = {
type: AggregationType.COUNT,
tagValues,
Expand All @@ -122,13 +120,9 @@ describe('Recorder', () => {
}
});

describe(`for last value aggregation data of ${
measure.type
} values`, () => {
describe(`for last value aggregation data of ${measure.type} values`, () => {
for (const testCase of testCases) {
it(`should record measurements ${
testCase.description
} correctly`, () => {
it(`should record measurements ${testCase.description} correctly`, () => {
const lastValueData: LastValueData = {
type: AggregationType.LAST_VALUE,
tagValues,
Expand All @@ -152,9 +146,7 @@ describe('Recorder', () => {

describe(`for sum aggregation data of ${measure.type} values`, () => {
for (const testCase of testCases) {
it(`should record measurements ${
testCase.description
} correctly`, () => {
it(`should record measurements ${testCase.description} correctly`, () => {
const sumData: SumData = {
type: AggregationType.SUM,
tagValues,
Expand All @@ -177,13 +169,9 @@ describe('Recorder', () => {
}
});

describe(`for distribution aggregation data of ${
measure.type
} values`, () => {
describe(`for distribution aggregation data of ${measure.type} values`, () => {
for (const testCase of testCases) {
it(`should record measurements ${
testCase.description
} correctly`, () => {
it(`should record measurements ${testCase.description} correctly`, () => {
const distributionData: DistributionData = {
type: AggregationType.DISTRIBUTION,
tagValues,
Expand Down
8 changes: 2 additions & 6 deletions packages/opencensus-core/test/test-view.ts
Expand Up @@ -189,9 +189,7 @@ describe('BaseView', () => {
tags.set(tagKey2, tagValue2);

for (const aggregationTestCase of aggregationTestCases) {
it(`should record measurements on a View with ${
aggregationTestCase.description
} Aggregation Data type`, () => {
it(`should record measurements on a View with ${aggregationTestCase.description} Aggregation Data type`, () => {
const view = new BaseView(
'test/view/name',
measure,
Expand Down Expand Up @@ -308,9 +306,7 @@ describe('BaseView', () => {

const { descriptor, timeseries } = view.getMetric(mockStartTime);

describe(`Aggregation type: ${
aggregationTestCase.aggregationType
}`, () => {
describe(`Aggregation type: ${aggregationTestCase.aggregationType}`, () => {
it('should have descriptor', () => {
assert.ok(descriptor);
assert.deepStrictEqual(descriptor, {
Expand Down
32 changes: 15 additions & 17 deletions packages/opencensus-exporter-jaeger/src/jaeger-driver/index.ts
Expand Up @@ -125,9 +125,9 @@ export function spanToThrift(span: Span): ThriftSpan {
? Utils.encodeInt64(span.parentSpanId)
: ThriftUtils.emptyBuffer;

const traceId = `00000000000000000000000000000000${
span.spanContext.traceId
}`.slice(-32);
const traceId = `00000000000000000000000000000000${span.spanContext.traceId}`.slice(
-32
);

const high = traceId.slice(0, 16);
const low = traceId.slice(16);
Expand All @@ -151,20 +151,18 @@ export function spanToThrift(span: Span): ThriftSpan {

function getThriftReference(links: Link[]): ThriftReference[] {
return links
.map(
(link): ThriftReference | null => {
const refType = getThriftType(link.type);
if (!refType) return null;

const traceId = `00000000000000000000000000000000${link.traceId}`.slice(
-32
);
const traceIdHigh = Utils.encodeInt64(traceId.slice(0, 16));
const traceIdLow = Utils.encodeInt64(traceId.slice(16));
const spanId = Utils.encodeInt64(link.spanId);
return { traceIdLow, traceIdHigh, spanId, refType };
}
)
.map((link): ThriftReference | null => {
const refType = getThriftType(link.type);
if (!refType) return null;

const traceId = `00000000000000000000000000000000${link.traceId}`.slice(
-32
);
const traceIdHigh = Utils.encodeInt64(traceId.slice(0, 16));
const traceIdLow = Utils.encodeInt64(traceId.slice(16));
const spanId = Utils.encodeInt64(link.spanId);
return { traceIdLow, traceIdHigh, spanId, refType };
})
.filter(ref => !!ref) as ThriftReference[];
}

Expand Down
Expand Up @@ -251,9 +251,7 @@ export class PrometheusStatsExporter implements StatsEventListener {
labels.forEach(label => {
if (label === PrometheusStatsExporter.RESERVED_HISTOGRAM_LABEL) {
throw new Error(
`${
PrometheusStatsExporter.RESERVED_HISTOGRAM_LABEL
} is a reserved label keyword`
`${PrometheusStatsExporter.RESERVED_HISTOGRAM_LABEL} is a reserved label keyword`
);
}
});
Expand Down
9 changes: 6 additions & 3 deletions packages/opencensus-instrumentation-grpc/src/grpc.ts
Expand Up @@ -425,9 +425,12 @@ export class GrpcPlugin extends BasePlugin {
name: traceOptions.name,
kind: traceOptions.kind,
});
return plugin.makeGrpcClientRemoteCall(original, args, this, plugin)(
span
);
return plugin.makeGrpcClientRemoteCall(
original,
args,
this,
plugin
)(span);
}
};
};
Expand Down
28 changes: 7 additions & 21 deletions packages/opencensus-instrumentation-grpc/test/test-grpc.ts
Expand Up @@ -481,12 +481,8 @@ describe('GrpcPlugin() ', function() {
}

methodList.map(method => {
describe(`Test automatic tracing for grpc remote method ${
method.description
}`, () => {
it(`should create a rootSpan for client and for server - ${
method.description
}`, async () => {
describe(`Test automatic tracing for grpc remote method ${method.description}`, () => {
it(`should create a rootSpan for client and for server - ${method.description}`, async () => {
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0);
const spanName = `grpc.pkg_test.GrpcTester/${method.methodName}`;
const args = [client, method.request];
Expand Down Expand Up @@ -518,9 +514,7 @@ describe('GrpcPlugin() ', function() {
});
});

it(`should create a rootSpan for client and for server with tag context- ${
method.description
}`, () => {
it(`should create a rootSpan for client and for server with tag context- ${method.description}`, () => {
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0);
const spanName = `grpc.pkg_test.GrpcTester/${method.methodName}`;
const args = [client, method.request];
Expand Down Expand Up @@ -559,9 +553,7 @@ describe('GrpcPlugin() ', function() {
});
});

it(`should create a childSpan for client and rootSpan for server - ${
method.description
}`, () => {
it(`should create a childSpan for client and rootSpan for server - ${method.description}`, () => {
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0);
const options = { name: 'TestRootSpan' };
const spanName = `grpc.pkg_test.GrpcTester/${method.methodName}`;
Expand Down Expand Up @@ -598,9 +590,7 @@ describe('GrpcPlugin() ', function() {
});
});

it(`should create a childSpan for client and rootSpan for server with tag context - ${
method.description
}`, () => {
it(`should create a childSpan for client and rootSpan for server with tag context - ${method.description}`, () => {
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0);
const options = { name: 'TestRootSpan' };
const spanName = `grpc.pkg_test.GrpcTester/${method.methodName}`;
Expand Down Expand Up @@ -661,9 +651,7 @@ describe('GrpcPlugin() ', function() {
// tslint:disable-next-line:no-any
const errorCode = Number(grpcModule.status[key as any]);
if (errorCode > grpcModule.status.OK) {
it(`should raise an error for client/server rootSpans - ${
method.description
} - status = ${key}`, async () => {
it(`should raise an error for client/server rootSpans - ${method.description} - status = ${key}`, async () => {
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0);
const spanName = `grpc.pkg_test.GrpcTester/${method.methodName}`;
const errRequest =
Expand All @@ -685,9 +673,7 @@ describe('GrpcPlugin() ', function() {
});
});

it(`should raise an error for client childSpan/server rootSpan - ${
method.description
} - status = ${key}`, () => {
it(`should raise an error for client childSpan/server rootSpan - ${method.description} - status = ${key}`, () => {
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0);
const options = { name: 'TestRootSpan' };
const spanName = `grpc.pkg_test.GrpcTester/${method.methodName}`;
Expand Down
8 changes: 5 additions & 3 deletions packages/opencensus-instrumentation-http/src/http.ts
Expand Up @@ -422,9 +422,11 @@ export class HttpPlugin extends BasePlugin {
name: traceOptions.name,
kind: traceOptions.kind,
});
return plugin.getMakeRequestTraceFunction(request, options, plugin)(
span
);
return plugin.getMakeRequestTraceFunction(
request,
options,
plugin
)(span);
}
};
};
Expand Down
8 changes: 2 additions & 6 deletions packages/opencensus-instrumentation-http/test/test-http.ts
Expand Up @@ -309,9 +309,7 @@ describe('HttpPlugin', () => {
const httpErrorCodes = [400, 401, 403, 404, 429, 501, 503, 504, 500];

for (let i = 0; i < httpErrorCodes.length; i++) {
it(`should test rootSpan for GET requests with http error ${
httpErrorCodes[i]
}`, async () => {
it(`should test rootSpan for GET requests with http error ${httpErrorCodes[i]}`, async () => {
const testPath = '/outgoing/rootSpan/1';
doNock(
urlHost,
Expand Down Expand Up @@ -358,9 +356,7 @@ describe('HttpPlugin', () => {
});

for (let i = 0; i < httpErrorCodes.length; i++) {
it(`should test a child spans for GET requests with http error ${
httpErrorCodes[i]
}`, () => {
it(`should test a child spans for GET requests with http error ${httpErrorCodes[i]}`, () => {
const testPath = '/outgoing/rootSpan/childs/1';
doNock(
urlHost,
Expand Down
8 changes: 2 additions & 6 deletions packages/opencensus-instrumentation-https/test/test-https.ts
Expand Up @@ -251,9 +251,7 @@ describe('HttpsPlugin', () => {
const httpErrorCodes = [400, 401, 403, 404, 429, 501, 503, 504, 500];

for (let i = 0; i < httpErrorCodes.length; i++) {
it(`should test rootSpan for GET requests with http error ${
httpErrorCodes[i]
}`, async () => {
it(`should test rootSpan for GET requests with http error ${httpErrorCodes[i]}`, async () => {
const testPath = '/outgoing/rootSpan/1';
doNock(
urlHost,
Expand Down Expand Up @@ -311,9 +309,7 @@ describe('HttpsPlugin', () => {
});

for (let i = 0; i < httpErrorCodes.length; i++) {
it(`should test a child spans for GET requests with http error ${
httpErrorCodes[i]
}`, () => {
it(`should test a child spans for GET requests with http error ${httpErrorCodes[i]}`, () => {
const testPath = '/outgoing/rootSpan/childs/1';
doNock(
urlHost,
Expand Down

0 comments on commit d4c307e

Please sign in to comment.