@@ -2429,6 +2429,68 @@ describe("parent precedence", () => {
24292429 expect ( byName . forced . span_parents ) . toContain ( byName . outer . span_id ) ;
24302430 expect ( byName . forced . span_parents ) . not . toContain ( byName . inner . span_id ) ;
24312431 } ) ;
2432+
2433+ test ( "logger.startSpan with exported parent uses receiver project" , async ( ) => {
2434+ const primaryLogger = initLogger ( {
2435+ projectName : "primary" ,
2436+ projectId : "project-a" ,
2437+ } ) ;
2438+ const secondaryLogger = initLogger ( {
2439+ projectName : "secondary" ,
2440+ projectId : "project-b" ,
2441+ } ) ;
2442+
2443+ const root = primaryLogger . startSpan ( { name : "root" } ) ;
2444+ const parentStr = await root . export ( ) ;
2445+ root . end ( ) ;
2446+
2447+ const child = secondaryLogger . startSpan ( {
2448+ name : "child" ,
2449+ parent : parentStr ,
2450+ } ) ;
2451+ child . end ( ) ;
2452+
2453+ await memory . flush ( ) ;
2454+ const events = await memory . drain ( ) ;
2455+ const byName : any = Object . fromEntries (
2456+ events . map ( ( e : any ) => [ e . span_attributes ?. name , e ] ) ,
2457+ ) ;
2458+
2459+ expect ( byName . child . project_id ) . toBe ( "project-b" ) ;
2460+ expect ( byName . child . root_span_id ) . toBe ( byName . root . root_span_id ) ;
2461+ expect ( byName . child . span_parents ) . toContain ( byName . root . span_id ) ;
2462+ } ) ;
2463+
2464+ test ( "experiment.startSpan with exported parent uses receiver experiment" , async ( ) => {
2465+ const primaryExperiment = _exportsForTestingOnly . initTestExperiment (
2466+ "experiment-a" ,
2467+ "project-a" ,
2468+ ) ;
2469+ const secondaryExperiment = _exportsForTestingOnly . initTestExperiment (
2470+ "experiment-b" ,
2471+ "project-b" ,
2472+ ) ;
2473+
2474+ const root = primaryExperiment . startSpan ( { name : "root" } ) ;
2475+ const parentStr = await root . export ( ) ;
2476+ root . end ( ) ;
2477+
2478+ const child = secondaryExperiment . startSpan ( {
2479+ name : "child" ,
2480+ parent : parentStr ,
2481+ } ) ;
2482+ child . end ( ) ;
2483+
2484+ await memory . flush ( ) ;
2485+ const events = await memory . drain ( ) ;
2486+ const byName : any = Object . fromEntries (
2487+ events . map ( ( e : any ) => [ e . span_attributes ?. name , e ] ) ,
2488+ ) ;
2489+
2490+ expect ( byName . child . experiment_id ) . toBe ( "experiment-b" ) ;
2491+ expect ( byName . child . root_span_id ) . toBe ( byName . root . root_span_id ) ;
2492+ expect ( byName . child . span_parents ) . toContain ( byName . root . span_id ) ;
2493+ } ) ;
24322494} ) ;
24332495
24342496test ( "attachment with unreadable path logs warning" , ( ) => {
0 commit comments