Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.
This repository was archived by the owner on May 23, 2023. It is now read-only.

Set a span parent without using the context #176

@Azim-Palmer

Description

@Azim-Palmer

I'm struggling to see how to manually set a span's parent in the JS library

var tracer = tracingManager.getTracer();
const appStartupSpan = tracer.startSpan("AppStartup");
appStartupSpan.addEvent("IronHide starting");

// Some time later in 
var childSpan = tracingManager.startSpan('AppStartup-ConnectToMetricsDatabase');

Reason for doing this is I have a node app, as soon as it loads I'd like to create a span called "AppStartup" so I know that process has started, however after several additional steps are done as part of startup that I can't wrap into a single execution function etc.

Ideally I can get the parents spanId and use that to manually connect spans I explicitly know are children of this span. I believe this works even when the parent span has already finished. This way I can tie together the 5 or so services that independently start but would be super useful to tie together under the AppStartup.

Looking at the source for tracer.startSpan I believe it would be reasonable to add a spanParentId onto the option object which overrides everything else.

Happy to create a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions