File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
packages/vitest-plugin/src Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1- import { getV8Flags , Measurement } from "@codspeed/core" ;
1+ import {
2+ getV8Flags ,
3+ Measurement ,
4+ mongoMeasurement ,
5+ SetupInstrumentsRequestBody ,
6+ SetupInstrumentsResponse ,
7+ } from "@codspeed/core" ;
28import { join } from "path" ;
39import { Plugin } from "vite" ;
410import { UserConfig } from "vitest/config" ;
@@ -45,3 +51,18 @@ export default function codspeedPlugin(): Plugin {
4551 } ,
4652 } ;
4753}
54+
55+ /**
56+ * Dynamically setup the CodSpeed instruments.
57+ */
58+ export async function setupInstruments (
59+ body : SetupInstrumentsRequestBody
60+ ) : Promise < SetupInstrumentsResponse > {
61+ if ( ! Measurement . isInstrumented ( ) ) {
62+ console . warn ( "[CodSpeed] No instrumentation found, using default mongoUrl" ) ;
63+
64+ return { remoteAddr : body . mongoUrl } ;
65+ }
66+
67+ return await mongoMeasurement . setupInstruments ( body ) ;
68+ }
You can’t perform that action at this time.
0 commit comments