-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[otel container]: Create otel container for HFT #23666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b44783d
9c2e1dd
867dae4
72df3d4
cdab210
0fe2a7c
ae7d085
5544587
59735c3
804de77
128e6b1
6f012d0
c92c743
75ba8b2
58b6bce
893b8f5
e9eebc7
b620101
0b2f172
9e0c88f
367ae36
0df0c9b
456e3da
b037620
15e6ba0
bf84774
e02d29c
acea365
28333dd
99d07b4
13f724b
6957337
b84d44d
cbd9754
f66260a
fe44474
e5af4b4
f98caac
b00adc1
7215a1b
33d3d74
37d35d9
b705491
ad2e202
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} | ||
| ARG BASE=docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} | ||
|
|
||
| FROM $BASE AS base | ||
|
|
||
| ARG docker_container_name | ||
| ARG image_version | ||
|
|
||
| ## Make apt-get non-interactive | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Pass the image_version to container | ||
| ENV IMAGE_VERSION=$image_version | ||
|
|
||
| RUN apt-get update | ||
|
|
||
| {% if docker_sonic_otel_debs.strip() -%} | ||
| # Copy locally-built Debian package dependencies | ||
| {{ copy_files("debs/", docker_sonic_otel_debs.split(' '), "/debs/") }} | ||
|
|
||
| # Install locally-built Debian packages and implicitly install their dependencies | ||
| {{ install_debian_packages(docker_sonic_otel_debs.split(' ')) }} | ||
| {%- endif %} | ||
|
|
||
| # Install dependencies | ||
| RUN apt-get install -y \ | ||
| ca-certificates \ | ||
| curl \ | ||
| wget | ||
|
|
||
| # Install OpenTelemetry Collector from official .deb package | ||
| ARG OTEL_VERSION=0.114.0 | ||
|
|
||
| # Download and install official .deb package with architecture-specific logic | ||
| {% if CONFIGURED_ARCH == "armhf" %} | ||
| RUN wget -v -O /tmp/otelcol-contrib.deb \ | ||
| "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/otelcol-contrib_${OTEL_VERSION}_linux_armv7.deb" && \ | ||
| dpkg --info /tmp/otelcol-contrib.deb && \ | ||
| (dpkg -i /tmp/otelcol-contrib.deb || apt-get install -f -y) && \ | ||
| ln -sf /usr/bin/otelcol-contrib /usr/local/bin/otelcol-contrib && \ | ||
| rm /tmp/otelcol-contrib.deb | ||
| {% elif CONFIGURED_ARCH == "arm64" %} | ||
| RUN wget -v -O /tmp/otelcol-contrib.deb \ | ||
| "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/otelcol-contrib_${OTEL_VERSION}_linux_arm64.deb" && \ | ||
| dpkg --info /tmp/otelcol-contrib.deb && \ | ||
| (dpkg -i /tmp/otelcol-contrib.deb || apt-get install -f -y) && \ | ||
| ln -sf /usr/bin/otelcol-contrib /usr/local/bin/otelcol-contrib && \ | ||
| rm /tmp/otelcol-contrib.deb | ||
| {% else %} | ||
| RUN wget -v -O /tmp/otelcol-contrib.deb \ | ||
| "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/otelcol-contrib_${OTEL_VERSION}_linux_amd64.deb" && \ | ||
| dpkg --info /tmp/otelcol-contrib.deb && \ | ||
| (dpkg -i /tmp/otelcol-contrib.deb || apt-get install -f -y) && \ | ||
| ln -sf /usr/bin/otelcol-contrib /usr/local/bin/otelcol-contrib && \ | ||
| rm /tmp/otelcol-contrib.deb | ||
|
Comment on lines
+35
to
+55
|
||
| {% endif %} | ||
|
|
||
| COPY ["start.sh", "otel.sh", "/usr/bin/"] | ||
| RUN chmod +x /usr/bin/start.sh /usr/bin/otel.sh | ||
| COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] | ||
| COPY ["critical_processes", "/etc/supervisor"] | ||
|
|
||
| FROM $BASE | ||
|
|
||
| RUN --mount=type=bind,from=base,target=/changes-to-image rsync -axAX --no-D --exclude=/sys --exclude=/proc --exclude=/dev --exclude=resolv.conf /changes-to-image/ / | ||
|
|
||
| ## Make apt-get non-interactive | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Pass the image_version to container | ||
| ENV IMAGE_VERSION=$image_version | ||
|
||
|
|
||
| ENTRYPOINT ["/usr/local/bin/supervisord"] | ||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this file used for? |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||
| ############################################################################### | ||||||||||
| ## Monit configuration for otel container | ||||||||||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| ############################################################################### | ||||||||||
|
||||||||||
| ############################################################################### | |
| ############################################################################### | |
| # Memory threshold for OTEL collector is set to 419430400 bytes (400 MB). | |
| # TODO: This value is a placeholder based on initial estimates. It should be adjusted based on actual memory profiling of the OTEL collector under expected load conditions. |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The monit check program name uses "container_memory_telemetry" but should use "container_memory_otel" to match the container name. This is inconsistent with the naming pattern used in other containers (e.g., "container_memory_gnmi" in monit_gnmi).
| check program container_memory_telemetry with path "/usr/bin/memory_checker otel 419430400" | |
| check program container_memory_otel with path "/usr/bin/memory_checker otel 419430400" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| program:otel | ||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| EXIT_OTEL_CONFIG_FILE_NOT_FOUND=1 | ||
| OTEL_CONFIG_FILE=/etc/sonic/otel_config.yml | ||
|
|
||
| echo "Starting otel.sh script" | ||
| echo "Checking for config file: $OTEL_CONFIG_FILE" | ||
|
|
||
| if [ ! -f "$OTEL_CONFIG_FILE" ]; then | ||
| echo "ERROR: OTEL config file not found at $OTEL_CONFIG_FILE" | ||
| exit $EXIT_OTEL_CONFIG_FILE_NOT_FOUND | ||
| fi | ||
|
|
||
| echo "Config file found at: $OTEL_CONFIG_FILE" | ||
|
|
||
| # Validate the YAML configuration | ||
| echo "Validating YAML configuration..." | ||
| python3 -c "import yaml; yaml.safe_load(open(\"$OTEL_CONFIG_FILE\"))" 2>&1 | ||
| if [ $? -ne 0 ]; then | ||
| echo "ERROR: YAML configuration is invalid" | ||
| exit 1 | ||
| fi | ||
|
|
||
| OTEL_ARGS="--config=$OTEL_CONFIG_FILE" | ||
|
|
||
| echo "Checking otelcol-contrib binary" | ||
| ls -la /usr/local/bin/otelcol-contrib | ||
|
|
||
| if [ ! -x "/usr/local/bin/otelcol-contrib" ]; then | ||
| echo "ERROR: otelcol-contrib binary not found or not executable" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "otel collector args: $OTEL_ARGS" | ||
| echo "Starting OTEL Collector with config file: $OTEL_CONFIG_FILE" | ||
|
Comment on lines
+6
to
+35
|
||
|
|
||
| exec /usr/local/bin/otelcol-contrib ${OTEL_ARGS} | ||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||
| #!/usr/bin/env bash | ||||||||||||
|
|
||||||||||||
| if [ "${RUNTIME_OWNER}" == "" ]; then | ||||||||||||
| RUNTIME_OWNER="kube" | ||||||||||||
|
Comment on lines
+3
to
+4
|
||||||||||||
| if [ "${RUNTIME_OWNER}" == "" ]; then | |
| RUNTIME_OWNER="kube" | |
| # Default to a generic runtime owner when not explicitly set via the environment. | |
| if [ -z "${RUNTIME_OWNER}" ]; then | |
| RUNTIME_OWNER="default" |
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||
| [supervisord] | ||||||
| logfile_maxbytes=1MB | ||||||
| logfile_backups=2 | ||||||
| nodaemon=true | ||||||
|
|
||||||
| [eventlistener:dependent-startup] | ||||||
| command=python3 -m supervisord_dependent_startup | ||||||
| autostart=true | ||||||
| autorestart=unexpected | ||||||
| startretries=0 | ||||||
| exitcodes=0,3 | ||||||
| events=PROCESS_STATE | ||||||
| buffer_size=1024 | ||||||
|
|
||||||
| [eventlistener:supervisor-proc-exit-listener] | ||||||
| command=/usr/local/bin/supervisor-proc-exit-listener --container-name otel | ||||||
|
||||||
| command=/usr/local/bin/supervisor-proc-exit-listener --container-name otel | |
| command=/usr/bin/supervisor-proc-exit-listener-rs --container-name otel |
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||
| [Unit] | ||||||||||||
| Description=Otel container | ||||||||||||
|
||||||||||||
| Description=Otel container | |
| Description=OTEL container |
Copilot
AI
Dec 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service description uses "Otel" with mixed case, but the standard abbreviation is "OTEL" (all caps) for OpenTelemetry. This should be changed to "OTEL container" for consistency with other services like "GNMI container" and "Telemetry container", and to match industry standard naming for OpenTelemetry.
| Description=Otel container | |
| Description=OTEL container |
Copilot
AI
Dec 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The systemd service ordering creates a potential dependency conflict. The service specifies "Before=swss.service" (line 4) and "After=sonic.target" (line 6), but swss.service typically starts after sonic.target as well. Additionally, the otel service only requires database.service but doesn't have an After dependency on it, which could lead to race conditions during startup. Consider adding "After=database.service" after line 3 to ensure proper startup ordering, and verify that the Before=swss.service ordering is actually required for HFT functionality.
| Requires=database.service | |
| Requires=database.service | |
| After=database.service |
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Dec 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The systemd service file is missing an [Install] section. Most other SONiC service files include an [Install] section with "WantedBy=sonic.target" to enable the service to be started by systemd. Without this section, the service may not be properly integrated into the system startup sequence. Add an [Install] section with "WantedBy=sonic.target" at the end of the file for consistency with other services like gnmi.service, telemetry.service, etc.
| RestartSec=30 | |
| RestartSec=30 | |
| [Install] | |
| WantedBy=sonic.target |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||||
| receivers: | ||||||||||||||
| otlp: | ||||||||||||||
| protocols: | ||||||||||||||
| grpc: | ||||||||||||||
| endpoint: "127.0.0.1:4317" | ||||||||||||||
| http: | ||||||||||||||
| endpoint: "127.0.0.1:4318" | ||||||||||||||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| processors: | ||||||||||||||
| batch: | ||||||||||||||
| timeout: 1s | ||||||||||||||
| send_batch_size: 1000 | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| # NOTE: This is a default/example configuration using the debug exporter. | |
| # For production deployments, customize the exporters section below to use an actual telemetry backend (e.g., OTLP, Prometheus, Jaeger, etc.). |
Copilot
AI
Dec 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "debug" exporter with "verbosity: detailed" is configured in the OTEL pipeline, which will log all telemetry data at a detailed level. This is likely intended for development/testing but could generate excessive log volume in production and potentially expose sensitive operational data.
For production deployments, consider using a more appropriate exporter (e.g., otlp, prometheus) or at minimum reduce the verbosity level to "normal" or "basic". If this is intended as a default configuration that users should customize, add a comment noting this is a development/testing configuration.
| exporters: | |
| exporters: | |
| # The "debug" exporter with "verbosity: detailed" is intended for development/testing only. | |
| # Do NOT use this configuration in production as it may generate excessive logs and expose sensitive data. |
Copilot
AI
Dec 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default OTEL configuration uses the 'debug' exporter with detailed verbosity, which outputs telemetry data to stdout/logs. This is suitable for development and testing but may not be appropriate for production use. Consider adding documentation or comments explaining that this configuration needs to be customized for production deployments with appropriate exporters (e.g., OTLP, Prometheus, etc.) configured to send data to actual telemetry backends.
| debug: | |
| debug: | |
| # NOTE: The 'debug' exporter writes telemetry data to stdout/logs and is intended | |
| # for development and testing only. For production deployments, customize this | |
| # configuration to use one or more exporters that send data to your telemetry | |
| # backend (for example 'otlp', 'prometheus', etc.). |
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace at end of line.
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace at the end of the line. This should be removed to maintain code cleanliness.
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected after the debug: exporter definition. While this doesn't affect YAML parsing, it's a style issue that should be removed for consistency and cleanliness.
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is trailing whitespace after "debug:" on this line. This should be removed for code cleanliness.
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| service_mgmt.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| DPATH := $($(DOCKER_OTEL)_PATH) | ||
| DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-otel.mk rules/docker-otel.dep | ||
| DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) | ||
| DEP_FILES += $(shell git ls-files $(DPATH)) | ||
|
|
||
| $(DOCKER_OTEL)_CACHE_MODE := GIT_CONTENT_SHA | ||
| $(DOCKER_OTEL)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) | ||
| $(DOCKER_OTEL)_DEP_FILES := $(DEP_FILES) | ||
|
|
||
| $(eval $(call add_dbg_docker,$(DOCKER_OTEL),$(DOCKER_OTEL_DBG))) | ||
|
|
||
Janetxxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||
| # docker image for otel collector | ||||
|
|
||||
| DOCKER_OTEL_STEM = docker-sonic-otel | ||||
| DOCKER_OTEL = $(DOCKER_OTEL_STEM).gz | ||||
| DOCKER_OTEL_DBG = $(DOCKER_OTEL_STEM)-$(DBG_IMAGE_MARK).gz | ||||
|
|
||||
| $(DOCKER_OTEL)_PATH = $(DOCKERS_PATH)/$(DOCKER_OTEL_STEM) | ||||
|
|
||||
| $(DOCKER_OTEL)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DEPENDS) | ||||
| $(DOCKER_OTEL)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BOOKWORM) | ||||
| $(DOCKER_OTEL)_VERSION = 1.0.0 | ||||
| $(DOCKER_OTEL)_PACKAGE_NAME = otel | ||||
| $(DOCKER_OTEL)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES) | ||||
|
|
||||
| SONIC_DOCKER_IMAGES += $(DOCKER_OTEL) | ||||
| SONIC_BOOKWORM_DOCKERS += $(DOCKER_OTEL) | ||||
| ifeq ($(INCLUDE_SYSTEM_OTEL), y) | ||||
| SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_OTEL) | ||||
| endif | ||||
|
|
||||
| SONIC_DOCKER_DBG_IMAGES += $(DOCKER_OTEL_DBG) | ||||
| SONIC_BOOKWORM_DBG_DOCKERS += $(DOCKER_OTEL_DBG) | ||||
| ifeq ($(INCLUDE_SYSTEM_OTEL), y) | ||||
| SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_OTEL_DBG) | ||||
| endif | ||||
|
|
||||
| $(DOCKER_OTEL)_CONTAINER_NAME = otel | ||||
| $(DOCKER_OTEL)_RUN_OPT += -t | ||||
| $(DOCKER_OTEL)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro | ||||
| $(DOCKER_OTEL)_RUN_OPT += -v /etc/localtime:/etc/localtime:ro | ||||
| $(DOCKER_OTEL)_RUN_OPT += -v /:/mnt/host:ro | ||||
| $(DOCKER_OTEL)_RUN_OPT += -v /tmp:/mnt/host/tmp:rw | ||||
| $(DOCKER_OTEL)_RUN_OPT += -v /var/tmp:/mnt/host/var/tmp:rw | ||||
| $(DOCKER_OTEL)_RUN_OPT += --pid=host | ||||
| $(DOCKER_OTEL)_RUN_OPT += --privileged | ||||
| $(DOCKER_OTEL)_RUN_OPT += --userns=host | ||||
|
|
||||
| $(DOCKER_OTEL)_BASE_IMAGE_FILES += monit_otel:/etc/monit/conf.d | ||||
|
|
||||
|
||||
Uh oh!
There was an error while loading. Please reload this page.