microsoft / durabletask-go

The Durable Task Framework is a lightweight, embeddable engine for writing durable, fault-tolerant business logic (orchestrations) as ordinary code.
Apache License 2.0
178 stars 25 forks source link

Add trace support into task #55

Open kaibocai opened 6 months ago

kaibocai commented 6 months ago

This PR add support to support for injection of otel spans into tasks. Try to resolve https://github.com/microsoft/durabletask-go/issues/31 protobuf update: https://github.com/microsoft/durabletask-protobuf/pull/21

User can get current span by

span := trace.SpanFromContext(ctx.Context())

or create child span from current span

_, childSpan := tracer.Start(ctx.Context(), "activity-subwork")

The output trace looks like

image
kaibocai commented 6 months ago

tagging @ItalyPaleAle for review.

kaibocai commented 5 months ago

Should we add ParentTraceContext in OrchestratorRequest as well as well, similar to activityRequest? It would enable users to create spans/use trace informations in orchestrations as well.

My thought is that in orchestration users are simply calling APIs we provided to do their orchestration, it seems to me that there is not much need to create child spans inside orchestration. All the operations will be simple and the span we generated here should be enough. https://github.com/microsoft/durabletask-go/blob/fc5756737d3c85ac4903adf35b58fce25f36641b/backend/executor.go#L311