Skip to content

Commit 823cae5

Browse files
committed
feat: update mongo-tracer and change startInstruments into setupInstruments
1 parent f5788e2 commit 823cae5

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

packages/core/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export const teardownCore = () => {
2525
};
2626

2727
export type {
28-
StartInstrumentsRequestBody,
29-
StartInstrumentsResponse,
28+
SetupInstrumentsRequestBody,
29+
SetupInstrumentsResponse,
3030
} from "./generated/openapi";
3131
export { getV8Flags, tryIntrospect } from "./introspection";
3232
export { optimizeFunction, optimizeFunctionSync } from "./optimization";

packages/core/src/mongoMeasurement.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {
22
MongoTracer,
3-
StartInstrumentsRequestBody,
4-
StartInstrumentsResponse,
3+
SetupInstrumentsRequestBody,
4+
SetupInstrumentsResponse,
55
} from "./generated/openapi";
66

7-
export type { StartInstrumentsRequestBody };
7+
export type { SetupInstrumentsRequestBody };
88

99
export class MongoMeasurement {
1010
private tracerClient: MongoTracer | undefined;
@@ -19,13 +19,13 @@ export class MongoMeasurement {
1919
}
2020
}
2121

22-
public async startInstruments(
23-
body: StartInstrumentsRequestBody
24-
): Promise<StartInstrumentsResponse> {
22+
public async setupInstruments(
23+
body: SetupInstrumentsRequestBody
24+
): Promise<SetupInstrumentsResponse> {
2525
if (this.tracerClient === undefined) {
2626
throw new Error("MongoDB Instrumentation is not enabled");
2727
}
28-
return await this.tracerClient.instruments.start(body);
28+
return await this.tracerClient.instruments.setup(body);
2929
}
3030

3131
public async start(uri: string) {

packages/core/tracer.spec.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"info": {
44
"title": "CodSpeed MongoDB Tracer",
55
"description": "Instrumentation API for CodSpeed Tracer",
6-
"version": "0.1.1-beta.4"
6+
"version": "0.2.0"
77
},
88
"paths": {
99
"/benchmark/start": {
@@ -74,15 +74,17 @@
7474
}
7575
}
7676
},
77-
"/instruments/start": {
77+
"/instruments/setup": {
7878
"post": {
7979
"tags": ["instruments"],
80-
"operationId": "start",
80+
"summary": "Start the instruments (proxy and aggregator) for the given `body.mongo_url`.",
81+
"description": "If other endpoints of the instrumentation server are called before this one, they will likely fail as the proxy and aggregator are not running yet.",
82+
"operationId": "setup",
8183
"requestBody": {
8284
"content": {
8385
"application/json": {
8486
"schema": {
85-
"$ref": "#/components/schemas/StartInstrumentsRequestBody"
87+
"$ref": "#/components/schemas/SetupInstrumentsRequestBody"
8688
}
8789
}
8890
},
@@ -94,7 +96,7 @@
9496
"content": {
9597
"application/json": {
9698
"schema": {
97-
"$ref": "#/components/schemas/StartInstrumentsResponse"
99+
"$ref": "#/components/schemas/SetupInstrumentsResponse"
98100
}
99101
}
100102
}
@@ -284,7 +286,7 @@
284286
"response_documents"
285287
]
286288
},
287-
"StartInstrumentsRequestBody": {
289+
"SetupInstrumentsRequestBody": {
288290
"type": "object",
289291
"properties": {
290292
"mongoUrl": {
@@ -294,7 +296,7 @@
294296
},
295297
"required": ["mongoUrl"]
296298
},
297-
"StartInstrumentsResponse": {
299+
"SetupInstrumentsResponse": {
298300
"type": "object",
299301
"properties": {
300302
"remoteAddr": {

packages/tinybench-plugin/src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
mongoMeasurement,
55
optimizeFunction,
66
setupCore,
7-
StartInstrumentsRequestBody,
8-
StartInstrumentsResponse,
7+
SetupInstrumentsRequestBody,
8+
SetupInstrumentsResponse,
99
teardownCore,
1010
tryIntrospect,
1111
} from "@codspeed/core";
@@ -105,16 +105,16 @@ function getCallingFile(): string {
105105
}
106106

107107
/**
108-
* Dynamically starts the CodSpeed instruments.
108+
* Dynamically setup the CodSpeed instruments.
109109
*/
110-
export async function startInstruments(
111-
body: StartInstrumentsRequestBody
112-
): Promise<StartInstrumentsResponse> {
110+
export async function setupInstruments(
111+
body: SetupInstrumentsRequestBody
112+
): Promise<SetupInstrumentsResponse> {
113113
if (!Measurement.isInstrumented()) {
114114
console.warn("[CodSpeed] No instrumentation found, using default mongoUrl");
115115

116116
return { remoteAddr: body.mongoUrl };
117117
}
118118

119-
return await mongoMeasurement.startInstruments(body);
119+
return await mongoMeasurement.setupInstruments(body);
120120
}

0 commit comments

Comments
 (0)