-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
This sample workflow demos context propagation through a workflow. Details about context propagation are | ||
This sample Workflow demos context propagation through a Workflow. Details about context propagation are | ||
available [here](https://docs.temporal.io/docs/go-tracing). | ||
|
||
The sample workflow initializes the client with a context propagator which propagates | ||
specific information in the `context.Context` object across the workflow. The `context.Context` object is populated | ||
with the information prior to calling `StartWorkflow`. The workflow demonstrates that the information is available | ||
in the workflow and any activities executed. | ||
The sample Workflow initializes the client with a context propagator which propagates | ||
specific information in the `context.Context` object across the Workflow. The `context.Context` object is populated | ||
with the information prior to calling `StartWorkflow`. The Workflow demonstrates that the information is available | ||
in the Workflow and any activities executed. | ||
|
||
Also, this sample initializes a Jaeger global tracer and pass it to the client. The sample will work without | ||
actual Jaeger instance -- just report every tracer call to the log. To see traces in Jaeger run it with follow command: | ||
``` | ||
$ docker run --publish 6831:6831 --publish 16686:16686 jaegertracing/all-in-one:latest | ||
``` | ||
|
||
Steps to run this sample: | ||
1) You need a Temporal service running. See details README.md | ||
2) Run the following command multiple times on different console window. This is to simulate running workers on multiple different machines. | ||
1) You need a Temporal service running. See details README.md. | ||
2) Run | ||
``` | ||
go run ctxpropagation/worker/main.go | ||
``` | ||
3) Run the following command to execute the context: | ||
to start worker for `ctxpropagation` Workflow. | ||
|
||
3) Run: | ||
``` | ||
go run ctxpropagation/starter/main.go | ||
``` | ||
to start Workflow. | ||
|
||
You should see prints showing the context information available in the workflow and activities. | ||
|
||
|
||
You should see prints showing the context information available in the workflow | ||
and activities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ctxpropagation | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/opentracing/opentracing-go" | ||
"github.com/uber/jaeger-client-go" | ||
"github.com/uber/jaeger-client-go/config" | ||
) | ||
|
||
func SetJaegerGlobalTracer() io.Closer { | ||
cfg := config.Configuration{ | ||
ServiceName: "ctx-propogation-sample", | ||
Sampler: &config.SamplerConfig{ | ||
Type: jaeger.SamplerTypeConst, | ||
Param: 1, | ||
}, | ||
Reporter: &config.ReporterConfig{ | ||
LogSpans: true, | ||
}, | ||
} | ||
tracer, closer, err := cfg.NewTracer( | ||
config.Logger(jaeger.StdLogger), | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
opentracing.SetGlobalTracer(tracer) | ||
|
||
return closer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters