Skip to content

Add --enable-otlp configure flag and 'otlp' debian build profile#1183

Draft
yutongzhang-microsoft wants to merge 1 commit into
sonic-net:masterfrom
yutongzhang-microsoft:feature/otlp-build-plumbing
Draft

Add --enable-otlp configure flag and 'otlp' debian build profile#1183
yutongzhang-microsoft wants to merge 1 commit into
sonic-net:masterfrom
yutongzhang-microsoft:feature/otlp-build-plumbing

Conversation

@yutongzhang-microsoft
Copy link
Copy Markdown

@yutongzhang-microsoft yutongzhang-microsoft commented Apr 28, 2026

Why

This PR is the build-system half of Phase 2 in the Component Statistics HLD (sonic-net/SONiC#2312).

Phase 1 (#1180 here plus sonic-net/sonic-swss#4516) publishes service-level counters to COUNTERS_DB. Phase 2 will additionally export the same counters via OTLP/gRPC to a local OpenTelemetry Collector.

The OTLP sink depends on opentelemetry-cpp, which is not yet packaged in every SONiC build environment. To unblock the follow-up PRs that introduce the actual sink (OtlpSink wrapper + ComponentStats fan-out), this PR wires up the configure machinery first, behind an opt-in flag.

What

  • configure.ac

    • New --enable-otlp option (default: disabled).
    • PKG_CHECK_MODULES probe for opentelemetry_api / opentelemetry_sdk / opentelemetry_exporter_otlp_grpc.
    • Fallback header check (opentelemetry/version.h) + hard-coded -l<lib> list for SDKs that do not ship .pc files.
    • Defines HAVE_OTLP, AM_CONDITIONAL OTLP, and substitutes OPENTELEMETRY_CFLAGS / OPENTELEMETRY_LIBS for use by Makefile.am in follow-up PRs.
  • debian/rules

    • New otlp build profile; activates --enable-otlp when present, --disable-otlp otherwise (mirrors the existing noyangmod pattern).

What this PR does NOT do

  • No new source files, no public-API changes, no behaviour change on the default build path.
  • Does not require opentelemetry-cpp to be installed unless someone passes --enable-otlp (or builds with DEB_BUILD_PROFILES=otlp).
  • Does not introduce any runtime dependency.

How to verify

./autogen.sh
./configure                 # default build; opentelemetry-cpp not required
./configure --enable-otlp   # fails fast with a clear message if the SDK is missing

Follow-ups

Wire the build system to optionally pull in opentelemetry-cpp so a follow-up
PR can add an OTLP sink to ComponentStats. The default build is unchanged:

  * configure.ac gains a new --enable-otlp option (default: disabled).
    When enabled, the build probes for opentelemetry-cpp via pkg-config and
    falls back to a header check + a hard-coded -l<lib> list for SDKs that
    are not packaged with .pc files. HAVE_OTLP is defined and OTLP is
    exposed as an automake conditional, plus OPENTELEMETRY_CFLAGS /
    OPENTELEMETRY_LIBS substitutions for use by Makefile.am in later PRs.

  * debian/rules gains a new 'otlp' build profile. When the profile is
    active, --enable-otlp is passed to configure; otherwise --disable-otlp
    is passed, which is the current behaviour.

This is the build-system half of Phase 2 in the Component Statistics HLD
(sonic-net/SONiC#2312). It does not add any source files, does not change
the public API, and does not affect any default build path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants