Skip to content
Open
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
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NRLICENSE := $(TOOLS_BIN_DIR)/nrlicense

DISTRIBUTIONS ?= "nrdot-collector,nrdot-collector-experimental"

ci: check manifests-check build build-fips version-check licenses-check
ci: check manifests-check component-inventory-check build build-fips version-check licenses-check
check: ensure-goreleaser-up-to-date

build: go ocb
Expand All @@ -42,9 +42,6 @@ goreleaser-verify: goreleaser
ensure-goreleaser-up-to-date: generate-goreleaser
@git diff -s --exit-code distributions/*/.goreleaser*.yaml || (echo "Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1)

validate-components:
@./scripts/validate-components.sh

.PHONY: ocb
ocb:
ifeq (, $(shell command -v ocb 2>/dev/null))
Expand Down Expand Up @@ -185,4 +182,11 @@ manifests-check:
echo "NRDOT Experimental manifest out of sync with Core. Diff:"; \
echo "$${diff}"; \
exit 1; \
} || exit 0
} || exit 0

# Check that each distro's component-inventory.yaml (if present) matches its manifest.yaml
.PHONY: component-inventory-check
component-inventory-check:
@for distro in $$(echo ${DISTRIBUTIONS} | tr ',' ' ' | tr -d '"'); do \
./scripts/validate-component-inventory.sh "$$distro" || exit 1; \
done
83 changes: 0 additions & 83 deletions distributions/nrdot-collector/component-inventory.md

This file was deleted.

73 changes: 73 additions & 0 deletions distributions/nrdot-collector/component-inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Component Inventory
#
# Maps each component in the `nrdot-collector` distribution to the use cases
# that require it. As use cases evolve and begin to use components already
# present in the distro, this list might become stale and need updating, so
# it's not meant to be authoritative — it's best-effort context for maintainers.
#
# This file is validated against manifest.yaml by
# scripts/validate-component-inventory.sh (run as part of `make ci`). Component
# names must match the path suffix after /<category>/ in the manifest's gomod
# value (e.g. `extension/observer/dockerobserver` -> `observer/dockerobserver`).
#
# Use-case legend:
# Core - Core (not use-case specific)
# Host - Host Monitoring
# k8s - Kubernetes Monitoring
# ATP - Host Monitoring with process metrics
# Gateway - Gateway Mode
# OHI - On-Host Integrations

receivers:
dockerstatsreceiver: [OHI]
elasticsearchreceiver: [OHI]
filelogreceiver: [Host, k8s]
hostmetricsreceiver: [Host, k8s, OHI]
jmxreceiver: [OHI]
k8seventsreceiver: [OHI, k8s]
kafkametricsreceiver: [OHI]
kubeletstatsreceiver: [OHI, k8s]
nginxreceiver: [OHI]
otlpreceiver: [Core]
prometheusreceiver: [Gateway, k8s]
rabbitmqreceiver: [OHI]
receivercreator: [OHI]

processors:
adaptivetelemetryprocessor: [ATP]
attributesprocessor: [Core]
batchprocessor: [Core]
cumulativetodeltaprocessor: [Core]
filterprocessor: [Core]
groupbyattrsprocessor: [k8s, Gateway]
k8sattributesprocessor: [k8s, ATP, OHI]
memorylimiterprocessor: [Core]
metricsgenerationprocessor: [k8s, ATP, OHI]
metricstransformprocessor: [Core]
resourcedetectionprocessor: [Core]
resourceprocessor: [k8s, Gateway]
spanprocessor: [Gateway]
tailsamplingprocessor: [Gateway]
transformprocessor: [Core]

exporters:
debugexporter: [Core]
loadbalancingexporter: [Gateway]
otlpexporter: [Core]
otlphttpexporter: [Core]

connectors:
routingconnector: [Core]

extensions:
healthcheckextension: [Core]
observer/dockerobserver: [OHI]
observer/hostobserver: [OHI]
observer/k8sobserver: [OHI]

providers:
envprovider: [Core]
fileprovider: [Core]
httpprovider: [Core]
httpsprovider: [Core]
yamlprovider: [Core]
77 changes: 77 additions & 0 deletions scripts/validate-component-inventory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
# Copyright New Relic, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Validate that distributions/<distro>/component-inventory.yaml lists exactly
# the components present in distributions/<distro>/manifest.yaml.
#
# Usage: scripts/validate-component-inventory.sh <distribution>
#
# Exits 0 if the inventory file does not exist (the check is opt-in per distro).
# Exits 0 if every component category matches in both directions.
# Exits 1 with a per-category diff when there is drift.

set -euo pipefail

if [[ $# -ne 1 ]]; then
echo "usage: $0 <distribution>" >&2
exit 2
fi

DISTRO="$1"
SRC_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
DIR="${SRC_ROOT}/distributions/${DISTRO}"
MANIFEST="${DIR}/manifest.yaml"
INVENTORY="${DIR}/component-inventory.yaml"

if [[ ! -f "$INVENTORY" ]]; then
echo "ℹ️ ${DISTRO}: no component-inventory.yaml, skipping check"
exit 0
fi

if [[ ! -f "$MANIFEST" ]]; then
echo "❌ ${DISTRO}: manifest.yaml not found at ${MANIFEST}" >&2
exit 1
fi

# plural manifest section -> singular path segment used in gomod URLs
CATEGORIES=(
"receivers:receiver"
"processors:processor"
"exporters:exporter"
"connectors:connector"
"extensions:extension"
"providers:provider"
)

failed=0
for entry in "${CATEGORIES[@]}"; do
plural="${entry%%:*}"
singular="${entry##*:}"

manifest_components=$(yq -r "
.${plural}[]?.gomod
| sub(\" v[0-9].*$\"; \"\")
| sub(\".*/${singular}/\"; \"\")
" "$MANIFEST" | sort -u)

inventory_components=$(yq -r "
.${plural} // {} | keys | .[]
" "$INVENTORY" | sort -u)

if ! diff_output=$(diff <(echo "$manifest_components") <(echo "$inventory_components")); then
echo "❌ ${DISTRO} ${plural}: manifest and inventory disagree"
echo "$diff_output" | sed 's/^/ /'
failed=1
fi
done

if [[ $failed -eq 1 ]]; then
echo
echo " Manifest: ${MANIFEST}"
echo " Inventory: ${INVENTORY}"
echo " '<' lines are only in the manifest; '>' lines are only in the inventory."
exit 1
fi

echo "✅ ${DISTRO}: component inventory matches manifest"
Loading