Skip to content

Commit

Permalink
Add missing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ogaca-dd committed Jan 28, 2025
1 parent d3d2b4b commit 699b3b8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/otlp/attributes/gateway_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ package attributes

import "sync"

// GatewayUsage is a HostFromAttributesHandler that detects if the setup is a gateway.
// If two attributes have different hostnames, then we consider the setup is a gateway.
type GatewayUsage struct {
fistHostname string
gatewayUsage bool
m sync.Mutex
firstHostname string
gatewayUsage bool
m sync.Mutex
}

var _ HostFromAttributesHandler = (*GatewayUsage)(nil)
Expand All @@ -34,9 +36,9 @@ func NewGatewayUsage() *GatewayUsage {
func (g *GatewayUsage) OnHost(host string) {
g.m.Lock()
defer g.m.Unlock()
if g.fistHostname == "" {
g.fistHostname = host
} else if g.fistHostname != host {
if g.firstHostname == "" {
g.firstHostname = host
} else if g.firstHostname != host {
g.gatewayUsage = true
}
}
Expand Down

0 comments on commit 699b3b8

Please sign in to comment.