File opentelemetry-ebpf-profiler.spec of Package opentelemetry-ebpf-profiler

#
# spec file for package opentelemetry-ebpf-profiler
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           opentelemetry-ebpf-profiler
Version:        0.0.202527
Release:        0
Summary:        The production-scale datacenter profiler
License:        Apache-2.0
URL:            https://github.com/open-telemetry/opentelemetry-ebpf-profiler
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
BuildRequires:  golang(API) >= 1.24
BuildRequires:  clang
BuildRequires:  llvm

ExcludeArch:    %{ix86} %{arm}

%description
A whole-system, cross-language profiler for Linux via eBPF.

Core features and strengths
- Implements the experimental OTel profiling signal
- Very low CPU and memory overhead (1% CPU and 250MB memory are our upper
  limits in testing and the agent typically manages to stay way below that)
- Support for native C/C++ executables without the need for DWARF debug
  information (by leveraging .eh_frame data as described in US11604718B1)
- Support profiling of system libraries without frame pointers and without
  debug symbols on the host.
- Support for mixed stacktraces between runtimes - stacktraces go from Kernel
  space through unmodified system libraries all the way into high-level
  languages.
- Support for native code (C/C++, Rust, Zig, Go, etc. without debug symbols on
  host)
- Support for a broad set of HLLs (Hotspot JVM, Python, Ruby, PHP, Node.JS, V8,
  Perl), .NET is in preparation.
- 100% non-intrusive: there's no need to load agents or libraries into the
  processes that are being profiled.
- No need for any reconfiguration, instrumentation or restarts of HLL
  interpreters and VMs: the agent supports unwinding each of the supported
  languages in the default configuration.
- ARM64 support for all unwinders except NodeJS.
- Support for native inline frames, which provide insights into compiler
  optimizations and offer a higher precision of function call chains.

%prep
%autosetup -p 1 -a 1

%build
COMMIT_HASH="$(sed -n 's/commit: \(.*\)/\1/p' %_sourcedir/%{name}.obsinfo)"

DATE_FMT="+%%Y-%%m-%%dT%%H:%%M:%%SZ"
BUILD_DATE=$(date -u -d "@${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u "${DATE_FMT}")

#
# make generate
#
go generate ./...
cd support || exit 3
./generate.sh
cd .. || exit 3

#
# make ebpf
#
cd support/ebpf || exit 3
make BPF_CLANG=clang BPF_LINK=llvm-link LLC=llc
cd ../../ || exit 3

#
# without debug information
#
go build \
   -mod=vendor \
   -buildmode=pie \
   -buildvcs=false \
   -tags="osusergo,netgo" \
   -ldflags=" \
   -X go.opentelemetry.io/ebpf-profiler/vc.version= \
   -X go.opentelemetry.io/ebpf-profiler/vc.revision=${COMMIT_HASH} \
   -X go.opentelemetry.io/ebpf-profiler/vc.buildTimestamp=${BUILD_DATE}" \
   -o bin/%{name}

#
# make ebpf
#
cd support/ebpf
make debug BPF_CLANG=clang BPF_LINK=llvm-link LLC=llc
cd ../../

#
# with debug information
#
go build \
   -mod=vendor \
   -buildmode=pie \
   -tags="osusergo,netgo,debugtracer" \
   -ldflags=" \
   -X go.opentelemetry.io/ebpf-profiler/vc.version= \
   -X go.opentelemetry.io/ebpf-profiler/vc.revision=${COMMIT_HASH} \
   -X go.opentelemetry.io/ebpf-profiler/vc.buildTimestamp=${BUILD_DATE}" \
   -o bin/%{name}-debug

%install
install -D -m 0755 bin/%{name} %{buildroot}%{_bindir}/%{name}
install -D -m 0755 bin/%{name} %{buildroot}%{_bindir}/%{name}-debug

#
# copy ./support/ebpf/tracer.ebpf.debug.*
#
mkdir -p %{buildroot}%{_datadir}/%{name}/
install -m 0644 ./support/ebpf/tracer.ebpf.debug.* %{buildroot}%{_datadir}/%{name}/

%check
%{buildroot}%{_bindir}/%{name} -help
%{buildroot}%{_bindir}/%{name} -version
%{buildroot}%{_bindir}/%{name}-debug -help
%{buildroot}%{_bindir}/%{name}-debug -version

%files
%doc README.md
%license LICENSE
%{_bindir}/%{name}
%{_bindir}/%{name}-debug
%{_datadir}/%{name}/

%changelog
openSUSE Build Service is sponsored by