<commit_before>package report

import "fmt"

// Report is the core data type. It's produced by probes, and consumed and
// stored by apps. It's composed of multiple topologies, each representing
// a different (related, but not equivalent) view of the network.
type Report struct {
	// Endpoint nodes are individual (address, port) tuples on each host.
	// They come from inspecting active connections and can (theoretically)
	// be traced back to a process. Edges are present.
	Endpoint Topology

	// Address nodes are addresses (e.g. ifconfig) on each host. Certain
	// information may be present in this topology that can't be mapped to
	// endpoints (e.g. ICMP). Edges are present.
	Address Topology

	// Process nodes are processes on each host. Edges are not present.
	Process Topology

	// Container nodes represent all Docker containers on hosts running probes.
	// Metadata includes things like containter id, name, image id etc.
	// Edges are not present.
	Container Topology

	// ContainerImages nodes represent all Docker containers images on
	// hosts running probes. Metadata includes things like image id, name etc.
	// Edges are not present.
	ContainerImage Topology

	// Host nodes are physical hosts that run probes. Metadata includes things
	// like operating system, load, etc. The information is scraped by the
	// probes with each published report. Edges are not present.
	Host Topology

	// Overlay nodes are active peers in any software-defined network that's
	// overlaid on the infrastructure. The information is scraped by polling
	// their status endpoints. Edges could be present, but aren't currently.
	Overlay Topology

	// Sampling data for this report.
	Sampling
}

// MakeReport makes a clean report, ready to Merge() other reports into.
func MakeReport() Report {
	return Report{
		Endpoint:       NewTopology(),
		Address:        NewTopology(),
		Process:        NewTopology(),
		Container:      NewTopology(),
		ContainerImage: NewTopology(),
		Host:           NewTopology(),
		Overlay:        NewTopology(),
	}
}

// Topologies returns a slice of Topologies in this report
func (r Report) Topologies() []Topology {
	return []Topology{
		r.Endpoint,
		r.Address,
		r.Process,
		r.Container,
		r.ContainerImage,
		r.Host,
		r.Overlay,
	}
}

// Validate checks the report for various inconsistencies.
func (r Report) Validate() error {
	var packets uint64
	for _, topology := range r.Topologies() {
		if err := topology.Validate(); err != nil {
			return err
		}
		for _, emd := range topology.EdgeMetadatas {
			if emd.PacketCount != nil {
				packets += *emd.PacketCount<commit_msg>Don't flat-embed sampling in the report<commit_after>package report

import "fmt"

// Report is the core data type. It's produced by probes, and consumed and
// stored by apps. It's composed of multiple topologies, each representing
// a different (related, but not equivalent) view of the network.
type Report struct {
	// Endpoint nodes are individual (address, port) tuples on each host.
	// They come from inspecting active connections and can (theoretically)
	// be traced back to a process. Edges are present.
	Endpoint Topology

	// Address nodes are addresses (e.g. ifconfig) on each host. Certain
	// information may be present in this topology that can't be mapped to
	// endpoints (e.g. ICMP). Edges are present.
	Address Topology

	// Process nodes are processes on each host. Edges are not present.
	Process Topology

	// Container nodes represent all Docker containers on hosts running probes.
	// Metadata includes things like containter id, name, image id etc.
	// Edges are not present.
	Container Topology

	// ContainerImages nodes represent all Docker containers images on
	// hosts running probes. Metadata includes things like image id, name etc.
	// Edges are not present.
	ContainerImage Topology

	// Host nodes are physical hosts that run probes. Metadata includes things
	// like operating system, load, etc. The information is scraped by the
	// probes with each published report. Edges are not present.
	Host Topology

	// Overlay nodes are active peers in any software-defined network that's
	// overlaid on the infrastructure. The information is scraped by polling
	// their status endpoints. Edges could be present, but aren't currently.
	Overlay Topology

	// Sampling data for this report.
	Sampling Sampling
}

// MakeReport makes a clean report, ready to Merge() other reports into.
func MakeReport() Report {
	return Report{
		Endpoint:       NewTopology(),
		Address:        NewTopology(),
		Process:        NewTopology(),
		Container:      NewTopology(),
		ContainerImage: NewTopology(),
		Host:           NewTopology(),
		Overlay:        NewTopology(),
		Sampling:       Sampling{},
	}
}

// Topologies returns a slice of Topologies in this report
func (r Report) Topologies() []Topology {
	return []Topology{
		r.Endpoint,
		r.Address,
		r.Process,
		r.Container,
		r.ContainerImage,
		r.Host,
		r.Overlay,
	}
}

// Validate checks the report for various inconsistencies.
func (r Report) Validate() error {
	var packets uint64
	for _, topology := range r.Topologies() {
		if err := topology.Validate(); err != nil {
			return err
		}
		for _, emd := range topology.EdgeMetadatas {
			if emd.PacketCount != nil {
				packets += *emd.PacketCount
{'fraction_non_alphanumeric': 0.0818404676598152, 'fraction_numerical': 0.0007542900245144258, 'mean_word_length': 3.3690280065897857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3899800', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1437, 'n_words': 653}