Skip to content

Commit 28f374e

Browse files
authored
[HDX-3929] Migrate OTel Collector build to use OCB (OpenTelemetry Collector Builder) (#2109)
1 parent 28b81dd commit 28f374e

10 files changed

Lines changed: 449 additions & 10 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@hyperdx/otel-collector': minor
3+
---
4+
5+
feat: Bump OTel Collector from 0.147.0 to 0.149.0
6+
7+
Upgrade the OpenTelemetry Collector and all its components from v0.147.0 to
8+
v0.149.0 (core providers from v1.53.0 to v1.55.0).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@hyperdx/otel-collector': minor
3+
---
4+
5+
feat: Migrate OTel Collector build to use OCB (OpenTelemetry Collector Builder)
6+
7+
Replace the pre-built otel/opentelemetry-collector-contrib image with a custom
8+
binary built via OCB. This enables adding custom receiver/processor components
9+
in the future while including only the components HyperDX needs. The collector
10+
version is now centralized in `.env` via `OTEL_COLLECTOR_VERSION` and
11+
`OTEL_COLLECTOR_CORE_VERSION`, with `builder-config.yaml` using templatized
12+
placeholders substituted at Docker build time.

.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,11 @@ HDX_DEV_OTEL_HTTP_PORT=4318
3838
HDX_DEV_OTEL_METRICS_PORT=8888
3939
HDX_DEV_OTEL_JSON_HTTP_PORT=14318
4040

41+
# Otel Collector version (used as Docker build arg for image tags and component versions)
42+
# When bumping, look up the core version from the upstream manifest:
43+
# https://github.com/open-telemetry/opentelemetry-collector-releases/blob/main/distributions/otelcol-contrib/manifest.yaml
44+
OTEL_COLLECTOR_VERSION=0.149.0
45+
OTEL_COLLECTOR_CORE_VERSION=1.55.0
46+
4147
# Otel/Clickhouse config
4248
HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE=default

docker-compose.ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ services:
55
context: .
66
dockerfile: docker/otel-collector/Dockerfile
77
target: dev
8+
args:
9+
OTEL_COLLECTOR_VERSION: ${OTEL_COLLECTOR_VERSION}
10+
OTEL_COLLECTOR_CORE_VERSION: ${OTEL_COLLECTOR_CORE_VERSION}
811
environment:
912
CLICKHOUSE_ENDPOINT: 'tcp://ch-server:9000?dial_timeout=10s'
1013
HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE: ${HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE}

docker-compose.dev.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ services:
2626
context: .
2727
dockerfile: docker/otel-collector/Dockerfile
2828
target: dev
29+
args:
30+
OTEL_COLLECTOR_VERSION: ${OTEL_COLLECTOR_VERSION}
31+
OTEL_COLLECTOR_CORE_VERSION: ${OTEL_COLLECTOR_CORE_VERSION}
2932
environment:
3033
CLICKHOUSE_ENDPOINT: 'tcp://ch-server:9000?dial_timeout=10s'
3134
CLICKHOUSE_PROMETHEUS_METRICS_ENDPOINT: 'ch-server:9363'
@@ -63,6 +66,9 @@ services:
6366
context: .
6467
dockerfile: docker/otel-collector/Dockerfile
6568
target: dev
69+
args:
70+
OTEL_COLLECTOR_VERSION: ${OTEL_COLLECTOR_VERSION}
71+
OTEL_COLLECTOR_CORE_VERSION: ${OTEL_COLLECTOR_CORE_VERSION}
6672
environment:
6773
CLICKHOUSE_ENDPOINT: 'tcp://ch-server:9000?dial_timeout=10s'
6874
CLICKHOUSE_PROMETHEUS_METRICS_ENDPOINT: 'ch-server:9363'

docker/hyperdx/Dockerfile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,29 @@
99

1010
ARG NODE_VERSION=22.22
1111
ARG CLICKHOUSE_VERSION=26.1
12-
ARG OTEL_COLLECTOR_VERSION=0.147.0
13-
ARG OTEL_COLLECTOR_OPAMPSUPERVISOR_VERSION=0.147.0
12+
ARG OTEL_COLLECTOR_VERSION=0.149.0
13+
ARG OTEL_COLLECTOR_CORE_VERSION=1.55.0
1414

1515
# base #############################################################################################
1616
# == Otel Collector Image ==
17-
FROM otel/opentelemetry-collector-contrib:${OTEL_COLLECTOR_VERSION} AS otel_collector_base
18-
FROM otel/opentelemetry-collector-opampsupervisor:${OTEL_COLLECTOR_OPAMPSUPERVISOR_VERSION} AS otel_collector_opampsupervisor_base
17+
FROM otel/opentelemetry-collector-opampsupervisor:${OTEL_COLLECTOR_VERSION} AS otel_collector_opampsupervisor_base
1918
FROM kukymbr/goose-docker@sha256:0cd025636df126e7f66472861ca4db3683bc649be46cd1f6ef1a316209058e23 AS goose
2019

20+
# Build the custom HyperDX collector binary using OCB (OpenTelemetry Collector Builder).
21+
# This replaces the pre-built otel/opentelemetry-collector-contrib image so we can
22+
# include custom receiver/processor components alongside the standard contrib ones.
23+
# Note: The official OCB image may ship an older Go than the contrib modules require,
24+
# so we copy the ocb binary into a golang base with a newer toolchain.
25+
FROM otel/opentelemetry-collector-builder:${OTEL_COLLECTOR_VERSION} AS ocb-bin
26+
FROM golang:1.26-alpine AS ocb-builder
27+
ARG OTEL_COLLECTOR_VERSION
28+
ARG OTEL_COLLECTOR_CORE_VERSION
29+
COPY --from=ocb-bin /usr/local/bin/ocb /usr/local/bin/ocb
30+
WORKDIR /build
31+
COPY packages/otel-collector/builder-config.yaml .
32+
RUN sed -i "s/__OTEL_COLLECTOR_VERSION__/${OTEL_COLLECTOR_VERSION}/g; s/__OTEL_COLLECTOR_CORE_VERSION__/${OTEL_COLLECTOR_CORE_VERSION}/g" builder-config.yaml && \
33+
CGO_ENABLED=0 ocb --config=builder-config.yaml
34+
2135
# Build the Go migration tool with full TLS support for ClickHouse
2236
FROM golang:1.26-alpine AS migrate-builder
2337
WORKDIR /build
@@ -132,7 +146,7 @@ ARG USER_GID=10001
132146
ENV CODE_VERSION=$CODE_VERSION
133147
ENV OTEL_RESOURCE_ATTRIBUTES="service.version=$CODE_VERSION"
134148
# Copy from otel collector bases
135-
COPY --from=otel_collector_base --chmod=755 /otelcol-contrib /otelcontribcol
149+
COPY --from=ocb-builder --chmod=755 /build/output/otelcol-hyperdx /otelcontribcol
136150
COPY --from=otel_collector_opampsupervisor_base --chmod=755 /usr/local/bin/opampsupervisor /usr/local/bin/opampsupervisor
137151

138152
# Copy Node.js runtime from node base

docker/otel-collector/Dockerfile

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
## base #############################################################################################
2-
FROM otel/opentelemetry-collector-contrib:0.147.0 AS col
3-
FROM otel/opentelemetry-collector-opampsupervisor:0.147.0 AS supervisor
2+
ARG OTEL_COLLECTOR_VERSION=0.149.0
3+
ARG OTEL_COLLECTOR_CORE_VERSION=1.55.0
4+
5+
FROM otel/opentelemetry-collector-opampsupervisor:${OTEL_COLLECTOR_VERSION} AS supervisor
46
FROM hairyhenderson/gomplate:v4.3.3-alpine AS gomplate
57
FROM kukymbr/goose-docker@sha256:0cd025636df126e7f66472861ca4db3683bc649be46cd1f6ef1a316209058e23 AS goose
68

7-
# Build the Go migration tool with full TLS support for ClickHouse
9+
# Build the custom HyperDX collector binary using OCB (OpenTelemetry Collector Builder).
10+
# This replaces the pre-built otel/opentelemetry-collector-contrib image so we can
11+
# include custom receiver/processor components alongside the standard contrib ones.
812
# Note: Build context must be repo root (use: docker build -f docker/otel-collector/Dockerfile .)
9-
FROM golang:1.25-alpine AS migrate-builder
13+
# Note: The official OCB image may ship an older Go than the contrib modules require,
14+
# so we copy the ocb binary into a golang base with a newer toolchain.
15+
FROM otel/opentelemetry-collector-builder:${OTEL_COLLECTOR_VERSION} AS ocb-bin
16+
FROM golang:1.26-alpine AS ocb-builder
17+
ARG OTEL_COLLECTOR_VERSION
18+
ARG OTEL_COLLECTOR_CORE_VERSION
19+
COPY --from=ocb-bin /usr/local/bin/ocb /usr/local/bin/ocb
20+
WORKDIR /build
21+
COPY packages/otel-collector/builder-config.yaml .
22+
RUN sed -i "s/__OTEL_COLLECTOR_VERSION__/${OTEL_COLLECTOR_VERSION}/g; s/__OTEL_COLLECTOR_CORE_VERSION__/${OTEL_COLLECTOR_CORE_VERSION}/g" builder-config.yaml && \
23+
CGO_ENABLED=0 ocb --config=builder-config.yaml
24+
25+
# Build the Go migration tool with full TLS support for ClickHouse
26+
FROM golang:1.26-alpine AS migrate-builder
1027
WORKDIR /build
1128
COPY packages/otel-collector/go.mod packages/otel-collector/go.sum ./
1229
RUN go mod download
@@ -38,7 +55,7 @@ COPY --from=migrate-builder /migrate /usr/local/bin/migrate
3855
USER ${USER_UID}:${USER_GID}
3956

4057
COPY --from=supervisor --chmod=755 /usr/local/bin/opampsupervisor /opampsupervisor
41-
COPY --from=col --chmod=755 /otelcol-contrib /otelcontribcol
58+
COPY --from=ocb-builder --chmod=755 /build/output/otelcol-hyperdx /otelcontribcol
4259

4360
# Copy entrypoint and log tail wrapper scripts
4461
COPY --chmod=755 docker/otel-collector/entrypoint.sh /entrypoint.sh

0 commit comments

Comments
 (0)