Skip to content

Commit

Permalink
Set the component header key with the caller ID
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Dec 4, 2023
1 parent 5b0fe23 commit 3d4a605
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ func (c *client) execDuration(name string, duration time.Duration) {
c.executionDuration.WithLabelValues(name).Observe(duration.Seconds())
}

// Header key definition constants.
const (
PDAllowFollowerHandleKey = "PD-Allow-Follower-Handle"
ComponentSignatureKey = "component"
)

// HeaderOption configures the HTTP header.
type HeaderOption func(header http.Header)

Expand Down Expand Up @@ -272,6 +278,8 @@ func (c *client) request(
for _, opt := range headerOpts {
opt(req.Header)
}
req.Header.Set(ComponentSignatureKey, c.callerID)

start := time.Now()
resp, err := c.inner.cli.Do(req)
if err != nil {
Expand Down

0 comments on commit 3d4a605

Please sign in to comment.