Skip to content

Commit

Permalink
[NPM-4131] Use module for network path payload
Browse files Browse the repository at this point in the history
add back Via and modularize the network JSON payload
  • Loading branch information
pimlu committed Jan 27, 2025
1 parent e8d3026 commit 97b51dc
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 8 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ replace (
github.com/DataDog/datadog-agent/pkg/logs/status/utils => ./pkg/logs/status/utils
github.com/DataDog/datadog-agent/pkg/logs/util/testutils => ./pkg/logs/util/testutils
github.com/DataDog/datadog-agent/pkg/metrics => ./pkg/metrics/
github.com/DataDog/datadog-agent/pkg/network/payload => ./pkg/network/payload
github.com/DataDog/datadog-agent/pkg/networkdevice/profile => ./pkg/networkdevice/profile
github.com/DataDog/datadog-agent/pkg/networkpath/payload => ./pkg/networkpath/payload
github.com/DataDog/datadog-agent/pkg/obfuscate => ./pkg/obfuscate
github.com/DataDog/datadog-agent/pkg/orchestrator/model => ./pkg/orchestrator/model
github.com/DataDog/datadog-agent/pkg/process/util/api => ./pkg/process/util/api
Expand Down Expand Up @@ -568,6 +570,8 @@ require (
github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/impl v0.61.0
github.com/DataDog/datadog-agent/pkg/config/structure v0.61.0
github.com/DataDog/datadog-agent/pkg/fips v0.0.0 // indirect
github.com/DataDog/datadog-agent/pkg/network/payload v0.0.0-00010101000000-000000000000
github.com/DataDog/datadog-agent/pkg/networkpath/payload v0.0.0-00010101000000-000000000000
github.com/DataDog/datadog-agent/pkg/util/defaultpaths v0.61.0
github.com/DataDog/datadog-agent/pkg/util/utilizationtracker v0.0.0
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.11
Expand Down
2 changes: 2 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ use (
pkg/logs/status/utils
pkg/logs/util/testutils
pkg/metrics
pkg/network/payload
pkg/networkdevice/profile
pkg/networkpath/payload
pkg/obfuscate
pkg/orchestrator/model
pkg/process/util/api
Expand Down
2 changes: 2 additions & 0 deletions modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ modules:
used_by_otel: true
pkg/metrics:
used_by_otel: true
pkg/network/payload: default
pkg/networkdevice/profile: default
pkg/networkpath/payload: default
pkg/obfuscate:
used_by_otel: true
pkg/orchestrator/model:
Expand Down
9 changes: 3 additions & 6 deletions pkg/network/event_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"go4.org/intern"

"github.com/DataDog/datadog-agent/pkg/network/dns"
networkpayload "github.com/DataDog/datadog-agent/pkg/network/payload"
"github.com/DataDog/datadog-agent/pkg/network/protocols"
"github.com/DataDog/datadog-agent/pkg/network/protocols/http"
"github.com/DataDog/datadog-agent/pkg/network/protocols/kafka"
Expand Down Expand Up @@ -298,14 +299,10 @@ type ConnectionStats struct {
}

// Via has info about the routing decision for a flow
type Via struct {
Subnet Subnet `json:"subnet,omitempty"`
}
type Via = networkpayload.Via

// Subnet stores info about a subnet
type Subnet struct {
Alias string `json:"alias,omitempty"`
}
type Subnet = networkpayload.Subnet

// IPTranslation can be associated with a connection to show the connection is NAT'd
type IPTranslation struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/network/payload/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/DataDog/datadog-agent/pkg/network/payload

go 1.23.0
17 changes: 17 additions & 0 deletions pkg/network/payload/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 2025-present Datadog, Inc.

// Package payload separates network types used as JSON payloads into a module
package payload

// Via has info about the routing decision for a flow
type Via struct {
Subnet Subnet `json:"subnet,omitempty"`
}

// Subnet stores info about a subnet
type Subnet struct {
Alias string `json:"alias,omitempty"`
}
10 changes: 10 additions & 0 deletions pkg/networkpath/payload/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/DataDog/datadog-agent/pkg/networkpath/payload

go 1.23.0

replace github.com/DataDog/datadog-agent/pkg/network/payload => ../../network/payload

require (
github.com/DataDog/datadog-agent/pkg/network/payload v0.0.0-00010101000000-000000000000
github.com/google/uuid v1.6.0
)
2 changes: 2 additions & 0 deletions pkg/networkpath/payload/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/networkpath/payload/pathevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Package payload contains Network Path payload
package payload

import "github.com/DataDog/datadog-agent/pkg/network"
import "github.com/DataDog/datadog-agent/pkg/network/payload"

// Protocol defines supported network protocols
// Please define new protocols based on the Keyword from:
Expand Down Expand Up @@ -48,7 +48,7 @@ type NetworkPathHop struct {
// about the source of a path
type NetworkPathSource struct {
Hostname string `json:"hostname"`
Via *network.Via `json:"via,omitempty"`
Via *payload.Via `json:"via,omitempty"`
NetworkID string `json:"network_id,omitempty"` // Today this will be a VPC ID since we only resolve AWS resources
Service string `json:"service,omitempty"`
ContainerID string `json:"container_id,omitempty"`
Expand Down

0 comments on commit 97b51dc

Please sign in to comment.