Skip to content

Commit f9ecc9b

Browse files
authored
Merge branch 'master' into metrics_rca_runtime
2 parents a15aa08 + fa137d5 commit f9ecc9b

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

plugins/node/opentelemetry-koa-instrumentation/src/koa.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ export class KoaInstrumentation extends BasePlugin<typeof koa> {
129129
const span = this._tracer.startSpan(metadata.name, {
130130
attributes: metadata.attributes,
131131
});
132-
const result = await middlewareLayer(context, next);
133-
span.end();
134-
return result;
132+
133+
return this._tracer.withSpan(span, async () => {
134+
const result = await middlewareLayer(context, next);
135+
span.end();
136+
return result;
137+
});
135138
};
136139
}
137140
}

plugins/node/opentelemetry-koa-instrumentation/test/koa.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ describe('Koa Instrumentation - Core Tests', () => {
9393
await next();
9494
};
9595

96+
const spanCreateMiddleware: koa.Middleware = async (ctx, next) => {
97+
const span = tracer.startSpan('foo');
98+
span.end();
99+
await next();
100+
};
101+
96102
const asyncMiddleware: koa.Middleware = async (ctx, next) => {
97103
const start = Date.now();
98104
await next();
@@ -106,11 +112,12 @@ describe('Koa Instrumentation - Core Tests', () => {
106112
app.use((ctx, next) => tracer.withSpan(rootSpan, next));
107113
app.use(customMiddleware);
108114
app.use(simpleResponse);
115+
app.use(spanCreateMiddleware);
109116

110117
await tracer.withSpan(rootSpan, async () => {
111118
await httpRequest.get(`http://localhost:${port}`);
112119
rootSpan.end();
113-
assert.deepStrictEqual(memoryExporter.getFinishedSpans().length, 5);
120+
assert.deepStrictEqual(memoryExporter.getFinishedSpans().length, 8);
114121

115122
assert.notStrictEqual(
116123
memoryExporter
@@ -119,6 +126,18 @@ describe('Koa Instrumentation - Core Tests', () => {
119126
undefined
120127
);
121128

129+
const fooParentSpan = memoryExporter
130+
.getFinishedSpans()
131+
.find(span => span.name.includes('spanCreateMiddleware'));
132+
assert.notStrictEqual(fooParentSpan, undefined);
133+
134+
const fooSpan = memoryExporter.getFinishedSpans().find(span => 'foo');
135+
assert.notStrictEqual(fooSpan, undefined);
136+
assert.strictEqual(
137+
fooSpan!.parentSpanId,
138+
fooParentSpan!.spanContext.spanId
139+
);
140+
122141
const simpleResponseSpan = memoryExporter
123142
.getFinishedSpans()
124143
.find(span => span.name.includes('simpleResponse'));

plugins/web/opentelemetry-plugin-react-load/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
"karma-webpack": "4.0.2",
6464
"mocha": "7.2.0",
6565
"nyc": "15.1.0",
66-
"react": "16.13.1",
67-
"react-dom": "16.13.1",
66+
"react": "17.0.1",
67+
"react-dom": "17.0.1",
6868
"rimraf": "3.0.2",
6969
"sinon": "9.0.2",
7070
"ts-loader": "8.0.4",
@@ -78,7 +78,7 @@
7878
"webpack-merge": "5.2.0"
7979
},
8080
"peerDependencies": {
81-
"react": "^16.13.1"
81+
"react": "^16.13.1 || ^17.0.0"
8282
},
8383
"dependencies": {
8484
"@opentelemetry/api": "^0.11.0",

0 commit comments

Comments
 (0)