Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions agent/backend/devicediscovery/device_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type deviceDiscoveryBackend struct {
diodeClientID string
diodeClientSecret string
diodeAppNamePrefix string
diodeOtelEndpoint string

startTime time.Time
proc backend.Commander
Expand Down Expand Up @@ -84,6 +85,12 @@ func (d *deviceDiscoveryBackend) Configure(logger *slog.Logger, repo policies.Po
d.diodeClientSecret = common.Diode.ClientSecret
d.diodeAppNamePrefix = common.Diode.AgentName

if common.Otel.Grpc != "" {
d.diodeOtelEndpoint = common.Otel.Grpc
d.logger.Info("device-discovery using OTLP metrics endpoint",
slog.String("endpoint", d.diodeOtelEndpoint))
}

return nil
}

Expand Down Expand Up @@ -112,6 +119,10 @@ func (d *deviceDiscoveryBackend) Start(ctx context.Context, cancelFunc context.C
"--diode-app-name-prefix", d.diodeAppNamePrefix,
}

if d.diodeOtelEndpoint != "" {
pvOptions = append(pvOptions, "--otel-endpoint", d.diodeOtelEndpoint)
}

d.logger.Info("device-discovery startup", slog.Any("arguments", pvOptions))

pvOptions[9] = d.diodeClientSecret
Expand Down
11 changes: 11 additions & 0 deletions agent/backend/networkdiscovery/network_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type networkDiscoveryBackend struct {
diodeClientID string
diodeClientSecret string
diodeAppNamePrefix string
diodeOtelEndpoint string

startTime time.Time
proc backend.Commander
Expand Down Expand Up @@ -84,6 +85,12 @@ func (d *networkDiscoveryBackend) Configure(logger *slog.Logger, repo policies.P
d.diodeClientSecret = common.Diode.ClientSecret
d.diodeAppNamePrefix = common.Diode.AgentName

if common.Otel.Grpc != "" {
d.diodeOtelEndpoint = common.Otel.Grpc
d.logger.Info("network-discovery using OTLP metrics endpoint",
slog.String("endpoint", d.diodeOtelEndpoint))
}

return nil
}

Expand Down Expand Up @@ -112,6 +119,10 @@ func (d *networkDiscoveryBackend) Start(ctx context.Context, cancelFunc context.
"--diode-app-name-prefix", d.diodeAppNamePrefix,
}

if d.diodeOtelEndpoint != "" {
pvOptions = append(pvOptions, "--otel-endpoint", d.diodeOtelEndpoint)
}

d.logger.Info("network-discovery startup", slog.Any("arguments", pvOptions))

pvOptions[9] = d.diodeClientSecret
Expand Down
15 changes: 12 additions & 3 deletions agent/backend/pktvisor/pktvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log/slog"
"net/http"
"net/url"
"os"
"os/exec"
"strconv"
Expand Down Expand Up @@ -302,9 +303,17 @@ func (p *pktvisorBackend) Configure(logger *slog.Logger, repo policies.PolicyRep

p.configFile = tmpFile.Name()

if common.Otel.Host != "" && common.Otel.Port != 0 {
p.otelReceiverHost = common.Otel.Host
p.otelReceiverPort = common.Otel.Port
if common.Otel.HTTP != "" {
uri, err := url.Parse(common.Otel.HTTP)
if err != nil {
return fmt.Errorf("failed to parse otel receiver http url: %w", err)
}
p.otelReceiverHost = uri.Hostname()
port, err := strconv.Atoi(uri.Port())
if err != nil {
return fmt.Errorf("failed to parse otel receiver port: %w", err)
}
p.otelReceiverPort = port
p.logger.Info("configured otel receiver host", slog.String("host", p.otelReceiverHost),
slog.Int("port", p.otelReceiverPort))
}
Expand Down
11 changes: 11 additions & 0 deletions agent/backend/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type workerBackend struct {
diodeClientID string
diodeClientSecret string
diodeAppNamePrefix string
diodeOtelEndpoint string

startTime time.Time
proc backend.Commander
Expand Down Expand Up @@ -84,6 +85,12 @@ func (d *workerBackend) Configure(logger *slog.Logger, repo policies.PolicyRepo,
d.diodeClientSecret = common.Diode.ClientSecret
d.diodeAppNamePrefix = common.Diode.AgentName

if common.Otel.Grpc != "" {
d.diodeOtelEndpoint = common.Otel.Grpc
d.logger.Info("orb-worker using OTLP metrics endpoint",
slog.String("endpoint", d.diodeOtelEndpoint))
}

return nil
}

Expand Down Expand Up @@ -112,6 +119,10 @@ func (d *workerBackend) Start(ctx context.Context, cancelFunc context.CancelFunc
"--diode-app-name-prefix", d.diodeAppNamePrefix,
}

if d.diodeOtelEndpoint != "" {
pvOptions = append(pvOptions, "--otel-endpoint", d.diodeOtelEndpoint)
}

d.logger.Info("worker startup", slog.Any("arguments", pvOptions))

pvOptions[9] = d.diodeClientSecret
Expand Down
4 changes: 2 additions & 2 deletions agent/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ type ManagerSecrets struct {
// BackendCommons represents common configuration for backends
type BackendCommons struct {
Otel struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Grpc string `yaml:"grpc"`
HTTP string `yaml:"http"`
AgentLabels map[string]string `yaml:"agent_labels"`
} `yaml:"otel"`
Diode struct {
Expand Down
Loading