Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codeboten/redistributed
Distributed tracing example using Redis
https://github.com/codeboten/redistributed
Last synced: about 1 month ago
JSON representation
Distributed tracing example using Redis
- Host: GitHub
- URL: https://github.com/codeboten/redistributed
- Owner: codeboten
- Created: 2019-03-30T03:22:33.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-30T03:29:56.000Z (almost 6 years ago)
- Last Synced: 2024-11-07T19:49:36.334Z (3 months ago)
- Language: Go
- Size: 277 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# redistributed
Library to support propagation of distributed tracing information for applications communicating over Redis channels.## Requirements
* docker
* docker-compose## Run example
```bash
git clone https://github.com/codeboten/redistributed.git
cd redistributed
docker-compose upcurl localhost:5000
open http://localhost:16686
```## Usage
```go
import "github.com/codeboten/redistributed/propagation"func publishMessage(w http.ResponseWriter, r *http.Request) {
span := trace.FromContext(r.Context())
conn := redisPool.GetWithContext(r.Context()).(redis.ConnWithContext)
publishCtx, publishSpan := trace.StartSpan(r.Context(), "publish")_, err := conn.DoContext(publishCtx, "PUBLISH", "mychannel1", redispropagation.Binary(publishSpan.SpanContext(), "message"))
}func receiveMessage(ctx context.Context) {
pubsub := client.Subscribe("mychannel1")
ch := pubsub.Channel()
for msg := range ch {
spanContext, message, ok := redispropagation.FromBinary(payload)
if ok {
_, span := trace.StartSpanWithRemoteParent(ctx, "generateReport", spanContext)
}
fmt.Printf("Message received:%s", message)
}
}
```