go-kit / go-kit/kit

Tracing: NATS support

Open
#1,006 7 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
27.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Hi. I would like to add NATS support in the go-kit tracing.

### How to pass a span context?
Unlike gRPC or HTTP packages, NATS doesn't have any headers or metadata (as I know) to pass content besides request body. Due to this, I see the only solution is to pass the span context **within the message data**.

**There are two options, that come to mind:**
- pass the context and the data in separate fields (_tracing has to be plugged in on the other end_)
```
type natsMessageWithContext struct {
Sc model.SpanContext `json:"sc"`
Data interface{} `json:"data"`
}
```
- pass the context among other data fields (_doesn't look good, from my point of view_)

For the rest, I suggest to do by analogy with the gRPC tracing and HTTP tracing solutions.

Is there something, that may be a problem? Is this solution acceptable?

**Samples:**
Publisher - https://github.com/sergey-suslov/apartments-booking/blob/feature/nats-tracing-as-options/services/booking/pkg/nats-tracing/nats.go
Subscriber - https://github.com/sergey-suslov/apartments-booking/blob/feature/nats-tracing-as-options/services/apartments/pkg/nats-tracing/nats.go

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.