Skip to content

Commit

Permalink
[network path] Rename path_id to pathtrace_id (#28674)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreYang authored Aug 26, 2024
1 parent b6dc66d commit dd00b11
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func Test_NpCollector_runningAndProcessing(t *testing.T) {
{
"timestamp": 0,
"namespace": "my-ns1",
"path_id": "",
"pathtrace_id": "",
"protocol": "UDP",
"source": {
"hostname": "abc",
Expand Down Expand Up @@ -164,7 +164,7 @@ func Test_NpCollector_runningAndProcessing(t *testing.T) {
{
"timestamp": 0,
"namespace": "my-ns1",
"path_id": "",
"pathtrace_id": "",
"protocol": "UDP",
"source": {
"hostname": "abc",
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkpath/payload/pathevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type NetworkPathDestination struct {
type NetworkPath struct {
Timestamp int64 `json:"timestamp"`
Namespace string `json:"namespace"` // namespace used to resolve NDM resources
PathID string `json:"path_id"`
PathtraceID string `json:"pathtrace_id"`
Protocol Protocol `json:"protocol"`
Source NetworkPathSource `json:"source"`
Destination NetworkPathDestination `json:"destination"`
Expand Down
13 changes: 13 additions & 0 deletions pkg/networkpath/payload/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2024-present Datadog, Inc.

package payload

import "github.com/google/uuid"

// NewPathtraceID creates a new pathtrace id
func NewPathtraceID() string {
return uuid.New().String()
}
17 changes: 6 additions & 11 deletions pkg/networkpath/traceroute/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (
"github.com/DataDog/datadog-agent/pkg/util/hostname"
"github.com/DataDog/datadog-agent/pkg/util/kernel"
"github.com/DataDog/datadog-agent/pkg/util/log"

"github.com/google/uuid"
)

// TODO: are these good defaults?
Expand Down Expand Up @@ -222,11 +220,10 @@ func (r *Runner) runTCP(cfg Config, hname string, target net.IP, maxTTL uint8, t
}

func (r *Runner) processTCPResults(res *tcp.Results, hname string, destinationHost string, destinationPort uint16, destinationIP net.IP) (payload.NetworkPath, error) {
pathID := uuid.New().String()
traceroutePath := payload.NetworkPath{
PathID: pathID,
Protocol: payload.ProtocolTCP,
Timestamp: time.Now().UnixMilli(),
PathtraceID: payload.NewPathtraceID(),
Protocol: payload.ProtocolTCP,
Timestamp: time.Now().UnixMilli(),
Source: payload.NetworkPathSource{
Hostname: hname,
NetworkID: r.networkID,
Expand Down Expand Up @@ -285,12 +282,10 @@ func (r *Runner) processUDPResults(res *results.Results, hname string, destinati
probe *results.Probe
}

pathID := uuid.New().String()

traceroutePath := payload.NetworkPath{
PathID: pathID,
Protocol: payload.ProtocolUDP,
Timestamp: time.Now().UnixMilli(),
PathtraceID: payload.NewPathtraceID(),
Protocol: payload.ProtocolUDP,
Timestamp: time.Now().UnixMilli(),
Source: payload.NetworkPathSource{
Hostname: hname,
NetworkID: r.networkID,
Expand Down

0 comments on commit dd00b11

Please sign in to comment.