Skip to content

Commit fc4e45c

Browse files
committed
Add telemetry catalogs and weaver gen for metadata.yaml used by mdatagen
1 parent 632970f commit fc4e45c

31 files changed

+1984
-1176
lines changed

Diff for: Makefile

+83
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,68 @@ include Makefile.tools
101101
include Makefile.containers
102102
include Makefile.packaging
103103

104+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
105+
# https://github.com/open-telemetry/weaver #
106+
# These images are for invoking weaver #
107+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
108+
109+
# From where to resolve the containers (e.g. "otel/weaver").
110+
CONTAINER_REPOSITORY=docker.io
111+
112+
# Per container overrides for the repository resolution.
113+
WEAVER_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)
114+
SEMCONVGEN_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)
115+
OPA_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)
116+
117+
CHECK_TARGETS=install-tools markdownlint
118+
119+
# Versioned, non-qualified references to containers used in this Makefile.
120+
# These are parsed from dependencies.Dockerfile so dependabot will autoupdate
121+
# the versions of docker files we use.
122+
VERSIONED_WEAVER_CONTAINER_NO_REPO=$(shell cat dependencies.Dockerfile | awk '$$4=="weaver" {print $$2}')
123+
VERSIONED_SEMCONVGEN_CONTAINER_NO_REPO=$(shell cat dependencies.Dockerfile | awk '$$4=="semconvgen" {print $$2}')
124+
VERSIONED_OPA_CONTAINER_NO_REPO=$(shell cat dependencies.Dockerfile | awk '$$4=="opa" {print $$2}')
125+
126+
# Fully qualified references to containers used in this Makefile. These
127+
# include the container repository, so that the build will work with tools
128+
# like "podman" with a default "/etc/containers/registries.conf", where
129+
# a default respository of "docker.io" is not assumed. This is intended to
130+
# eliminate errors from podman such as:
131+
#
132+
# Error: short-name "otel/weaver:v1.2.3" did not resolve to an alias
133+
# and no unqualified-search registries are defined in "/etc/containers/registries.conf"
134+
WEAVER_CONTAINER=$(WEAVER_CONTAINER_REPOSITORY)/$(VERSIONED_WEAVER_CONTAINER_NO_REPO)
135+
SEMCONVGEN_CONTAINER=$(SEMCONVGEN_CONTAINER_REPOSITORY)/$(VERSIONED_SEMCONVGEN_CONTAINER_NO_REPO)
136+
OPA_CONTAINER=$(OPA_CONTAINER_REPOSITORY)/$(VERSIONED_OPA_CONTAINER_NO_REPO)
137+
138+
# Determine if "docker" is actually podman
139+
DOCKER_VERSION_OUTPUT := $(shell docker --version 2>&1)
140+
DOCKER_IS_PODMAN := $(shell echo $(DOCKER_VERSION_OUTPUT) | grep -c podman)
141+
142+
ifeq ($(DOCKER_IS_PODMAN),0)
143+
DOCKER_COMMAND := docker
144+
else
145+
DOCKER_COMMAND := podman
146+
endif
147+
148+
# Debug printing
149+
ifdef DEBUG
150+
$(info Docker version output: $(DOCKER_VERSION_OUTPUT))
151+
$(info Is Docker actually Podman? $(DOCKER_IS_PODMAN))
152+
$(info Using command: $(DOCKER_COMMAND))
153+
endif
154+
155+
DOCKER_RUN=$(DOCKER_COMMAND) run
156+
DOCKER_USER=$(shell id -u):$(shell id -g)
157+
DOCKER_USER_IS_HOST_USER_ARG=-u $(DOCKER_USER)
158+
ifeq ($(DOCKER_COMMAND),podman)
159+
# On podman, additional arguments are needed to make "-u" work
160+
# correctly with the host user ID and host group ID.
161+
#
162+
# Error: OCI runtime error: crun: setgroups: Invalid argument
163+
DOCKER_USER_IS_HOST_USER_ARG=--userns=keep-id -u $(DOCKER_USER)
164+
endif
165+
104166
.PHONY: help clean no-local-changes build lint format unit-test integration-test run dev run-mock-management-grpc-server generate generate-mocks local-apk-package local-deb-package local-rpm-package
105167

106168
help: ## Show help message
@@ -238,6 +300,27 @@ stop-mock-management-otel-collector: ## Stop running mock management plane OTel
238300
@echo "Stopping mock management plane OTel collector"
239301
AGENT_IMAGE_WITH_NGINX_PLUS=nginx_plus_$(IMAGE_TAG):latest AGENT_IMAGE_WITH_NGINX_OSS=nginx_oss_$(IMAGE_TAG):latest AGENT_IMAGE_WITH_NGINX_PLUS_AND_NAP=nginx_plus_and_nap_$(IMAGE_TAG):latest $(CONTAINER_COMPOSE) -f ./test/mock/collector/docker-compose.yaml down
240302

303+
# Generate attribute registry metadata for mdatagen.
304+
# Example uses:
305+
# make nginxplus-metadata-gen
306+
# make nginxoss-metadata-gen
307+
.PHONY: %-metadata-gen
308+
%-metadata-gen:
309+
$(DOCKER_RUN) --rm \
310+
$(DOCKER_USER_IS_HOST_USER_ARG) \
311+
--mount 'type=bind,source=$(PWD)/templates,target=/home/weaver/templates,readonly' \
312+
--mount 'type=bind,source=$(PWD)/catalog/$*,target=/home/weaver/source/,readonly' \
313+
--mount 'type=bind,source=$(PWD)/internal/collector,target=/home/weaver/target' \
314+
$(WEAVER_CONTAINER) registry generate \
315+
--registry=/home/weaver/source \
316+
--templates=/home/weaver/templates \
317+
metadata \
318+
/home/weaver/target/$*receiver
319+
cat $(PWD)/internal/collector/$*receiver/*_metadata.yaml > $(PWD)/internal/collector/$*receiver/metadata.yaml
320+
rm $(PWD)/internal/collector/$*receiver/*_metadata.yaml
321+
@echo "🗃️ Generating go files"
322+
@$(GOGEN) $(PWD)/internal/collector/$*receiver/...
323+
241324
generate: ## Generate golang code
242325
@echo "🗄️ Generating proto files"
243326
@cd api/grpc && $(GORUN) $(BUF) generate

Diff for: catalog/nginxoss/metrics.yaml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/open-telemetry/weaver/v0.9.2/schemas/semconv.schema.json
2+
groups:
3+
# nginx.http.* metrics
4+
- id: metric.nginxoss.http.connections
5+
type: metric
6+
unit: "connections"
7+
metric_name: nginx.http.connections
8+
stability: experimental
9+
brief: "The total number of connections."
10+
instrument: counter
11+
note: |
12+
Source: HTTP API `/status`
13+
attributes:
14+
- ref: nginx.connections.outcome
15+
requirement_level: required
16+
17+
- id: metric.nginxoss.http.connection.count
18+
type: metric
19+
unit: "connections"
20+
metric_name: nginx.http.connection.count
21+
stability: experimental
22+
brief: "The current number of connections."
23+
instrument: gauge
24+
note: |
25+
Source: HTTP API `/status`
26+
attributes:
27+
- ref: nginx.connections.outcome
28+
requirement_level: required
29+
30+
- id: metric.nginxplus.http.requests
31+
type: metric
32+
unit: "requests"
33+
metric_name: nginx.http.requests
34+
stability: experimental
35+
brief: "The total number of client requests received from clients."
36+
instrument: counter
37+
note: |
38+
Source: HTTP API `/status`
39+
attributes: []
40+
41+
- id: metric.nginxoss.http.request.count
42+
type: metric
43+
unit: "requests"
44+
metric_name: nginx.http.request.count
45+
stability: experimental
46+
brief: "The current number of client requests received from clients."
47+
instrument: updowncounter
48+
note: |
49+
Source: HTTP API `/status`
50+
attributes: []
51+
52+
- id: metric.nginxoss.http.response.count
53+
type: metric
54+
unit: "responses"
55+
metric_name: nginx.http.response.count
56+
stability: experimental
57+
brief: "The current number of responses, grouped by status code range."
58+
instrument: updowncounter
59+
note: |
60+
Source: Logs `access.log`
61+
attributes:
62+
- ref: nginx.status_range
63+
requirement_level: required

Diff for: catalog/nginxoss/registry.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/open-telemetry/weaver/v0.9.2/schemas/semconv.schema.json
2+
groups:
3+
# General NGINX OSS attributes
4+
- id: registry.nginxoss
5+
type: attribute_group
6+
stability: experimental
7+
display_name: General NGINX OSS Attributes
8+
brief: "Describes NGINX attributes"
9+
attributes:
10+
- id: nginx.status_range
11+
type: string
12+
stability: development
13+
brief: "A status code range or bucket for a HTTP response's status code."
14+
examples: ["1xx","2xx","3xx","4xx","5xx"]
15+
- id: nginx.connections.outcome
16+
type: string
17+
stability: development
18+
brief: "The outcome of a connection"
19+
examples: ["ACCEPTED","ACTIVE","HANDLED","READING","WRITING","WAITING","DROPPED","IDLE"]

0 commit comments

Comments
 (0)