Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Define API to create new trace #137

Open
pokryfka opened this issue Aug 24, 2020 · 2 comments
Open

Define API to create new trace #137

pokryfka opened this issue Aug 24, 2020 · 2 comments

Comments

@pokryfka
Copy link
Contributor

Instrument protocol defines interface to extract and inject its context from/to baggage.

I think there needs to be API to create (and inject to baggage) new TracingInstrument context;
Perhaps it could be defined using existing InjectorProtocol.

Use cases (examples):

  • creating new traces for operations which were started by the service (like ""cron" jobs);
  • instrument service lifecycle; (in fact swift-service-lifecycle could be instrumented, this would provide insight on the order and time needed to start and/or shutdown a service);
@ktoso
Copy link
Collaborator

ktoso commented Aug 24, 2020

Instrument protocol defines interface to extract and inject its context from/to baggage.

I think there needs to be API to create (and inject to baggage) new TracingInstrument context;

Instrument will never speak about any kind of traces etc.

creating new traces for operations which were started by the service (like ""cron" jobs);

That is starting a span from an empty context.

The same is true for other languages and runtimes; if a context has no trace ids a startSpan may have to make them up on the spot to start a new span after all.

Related: offering a .background "empty context factory" which is just an empty context but is named well to lead people to this by the name. slashmo/gsoc-swift-baggage-context#26


instrument service lifecycle; (in fact swift-service-lifecycle could be instrumented, this would provide insight on the order and time needed to start and/or shutdown a service);

Can we be more specific here though; other than creating an empty context and invoking starting a span I don't see how this needs to be special

@pokryfka
Copy link
Contributor Author

pokryfka commented Aug 24, 2020

creating new traces for operations which were started by the service (like ""cron" jobs);

That is starting a span from an empty context.

I can implement it that way in XRayInstrument if it should to be working that way.

This is not, however, how it works in other X-Ray clients which typically log error or even (default!) throw errors if context is missing, example: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-go-configuration.html

Such approach would also make it difficult to know if new context should be started or was is just missed because library/framework API does not enforce its propagation, for example by making baggage parameter optional, see https://forums.swift.org/t/the-context-passing-problem/39162

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants