Skip to content

Commit

Permalink
CentOS 6 RPM Package Changes
Browse files Browse the repository at this point in the history
CentOS 6 RPM Package Changes
  • Loading branch information
lokesh-balla authored Nov 7, 2023
1 parent 7be516a commit 7943a73
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v3
- uses: addnab/docker-run-action@v3
with:
image: golang:1.21.1-bullseye
image: golang:1.21.3-bullseye
options: -v ${{ github.workspace }}:${{ github.workspace }} --env IS_GITHUB_ACTION=true --env VERSION_TAG=${{ github.event.release.tag_name }}
run: |
cd ${{ github.workspace }}
Expand Down Expand Up @@ -78,4 +78,4 @@ jobs:
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}
Binary file added build/vm/configure
Binary file not shown.
45 changes: 33 additions & 12 deletions build/vm/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"
)

const ServiceName = "tracing-proxy.service"
const ServiceName = "tracing-proxy"

func main() {
configFile, err := os.ReadFile("/opt/opsramp/tracing-proxy/conf/config_complete.yaml")
Expand Down Expand Up @@ -56,21 +56,42 @@ func main() {
log.Fatal(err)
}

// Enable and start with fallback
if err := exec.Command("systemctl", "enable", "--now", ServiceName).Run(); err != nil {
_ = exec.Command("systemctl", "start", ServiceName).Run()
_ = exec.Command("systemctl", "enable", ServiceName).Run()
systemctl := exec.Command("systemctl", "--version").Run()
if systemctl == nil { //checking os type here

_ = exec.Command("cp", "/opt/opsramp/service_files/tracing-proxy.service", "/etc/systemd/system/tracing-proxy.service").Run()
_ = exec.Command("chmod", "0644", "/etc/systemd/system/tracing-proxy").Run()
_ = exec.Command("rm", "-rf", "/opt/opsramp/service_files").Run()

// Enable and start with fallback
if err := exec.Command("systemctl", "enable", "--now", ServiceName).Run(); err != nil {
_ = exec.Command("systemctl", "start", ServiceName).Run()
_ = exec.Command("systemctl", "enable", ServiceName).Run()
}
} else {
_ = exec.Command("mv", "/opt/opsramp/service_files/tracing-proxy", "/etc/init.d/tracing-proxy").Run()
_ = exec.Command("chmod", "0755", "/etc/init.d/tracing-proxy").Run()
_ = exec.Command("rm", "-rf", "/opt/opsramp/service_files").Run()
}

time.Sleep(5 * time.Second)

// Check if the services are enabled and started properly and attempt again
if output, err := exec.Command("systemctl", "is-enabled", ServiceName).Output(); err != nil || string(output) != "enabled" {
_ = exec.Command("systemctl", "enable", ServiceName).Run()
}
if output, err := exec.Command("systemctl", "is-active", ServiceName).Output(); err != nil || string(output) != "active" {
_ = exec.Command("systemctl", "start", ServiceName).Run()
systemctl = exec.Command("systemctl", "--version").Run()
if systemctl == nil {
//Check if the services are enabled and started properly and attempt again
if output, err := exec.Command("systemctl", "is-enabled", ServiceName).Output(); err != nil || string(output) != "enabled" {
_ = exec.Command("service", ServiceName, "enable").Run()
}
if output, err := exec.Command("systemctl", "is-active", ServiceName).Output(); err != nil || string(output) != "active" {
_ = exec.Command("service", ServiceName, "start").Run()
} else {
log.Println("Tracing-Proxy Started Successfully")
}
} else {
log.Println("Tracing-Proxy Started Successfully")
if err := exec.Command("service", ServiceName, "start").Run(); err != nil {
log.Fatal(err)
}
_ = exec.Command("chkconfig", ServiceName, "on")
log.Println("Tracing-Proxy Started successfully")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/sh
# For RedHat and cousins:
# chkconfig: - 99 01
# description: OpsRamp Trace-Aware Sampling Proxy
# processname: /opt/opsramp/tracing-proxy/bin/tracing-proxy
### BEGIN INIT INFO
# Provides: /opt/opsramp/tracing-proxy/bin/tracing-proxy
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: tracing-proxy
# Description: OpsRamp Trace-Aware Sampling Proxy
### END INIT INFO
cmd="/opt/opsramp/tracing-proxy/bin/tracing-proxy "-c" "/opt/opsramp/tracing-proxy/conf/config_complete.yaml" "-r" "/opt/opsramp/tracing-proxy/conf/rules_complete.yaml""
name=$(basename $(readlink -f $0))
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
[ -e /etc/sysconfig/$name ] && . /etc/sysconfig/$name
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && cat /proc/$(get_pid)/stat > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"

$cmd >> "$stdout_log" 2>> "$stderr_log" &
echo $! > "$pid_file"
if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log"
exit 1
fi
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill $(get_pid)
for i in $(seq 1 10)
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0

4 changes: 3 additions & 1 deletion build/vm/tracing-deb/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ rm -rf $BUILD_DIR/output
mkdir -p $BUILD_DIR/tracing/opt/opsramp/tracing-proxy/bin
mkdir -p $BUILD_DIR/tracing/opt/opsramp/tracing-proxy/conf
mkdir -p $BUILD_DIR/tracing/etc/systemd/system
mkdir -p $BUILD_DIR/tracing/etc/init.d
mkdir -p $BUILD_DIR/tracing/opt/opsramp/service_files

cp -r $BUILD_DIR/../package_directories/* $BUILD_DIR/tracing/

Expand Down Expand Up @@ -59,4 +61,4 @@ mv $BUILD_DIR/tracing.deb $BUILD_DIR/output/"${packageName}"
# Cleanup
rm -rf $BUILD_DIR/tracing/opt
rm -rf $BUILD_DIR/tracing/etc
rm -rf $BUILD_DIR/configure $BUILD_DIR/tracing-proxy
rm -rf $BUILD_DIR/configure $BUILD_DIR/tracing-proxy
2 changes: 1 addition & 1 deletion build/vm/tracing-deb/tracing/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: tracing-proxy
Version: 1.1.0
Version: 1.0.0
Architecture: amd64
Essential: no
Priority: optional
Expand Down
1 change: 0 additions & 1 deletion build/vm/tracing-deb/tracing/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mkdir -p /var/log/opsramp
touch /var/log/opsramp/tracing-proxy.log
chmod 644 /etc/systemd/system/tracing-proxy.service
chmod 600 /opt/opsramp/tracing-proxy/conf
chmod 600 /opt/opsramp/tracing-proxy/conf/config_complete.yaml
chmod 600 /opt/opsramp/tracing-proxy/conf/rules_complete.yaml
Expand Down
2 changes: 1 addition & 1 deletion build/vm/tracing-rpm/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ echo "***** rpm package can be found in /root/rpmbuild/RPMS/x86_64/<package-name

# CleanUp
rm -rf ${package_name}
rm -rf $BUILD_DIR/configure $BUILD_DIR/tracing-proxy
rm -rf $BUILD_DIR/configure $BUILD_DIR/tracing-proxy
37 changes: 25 additions & 12 deletions build/vm/tracing-rpm/tracing-proxy.spec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# SPEC file for creating tracing-proxy RPM

%define name tracing-proxy
%define release
%define release
%define version 1.1.0

Summary: Tracing Proxy
Summary: Tracing Proxy
License: OpsRamp
Name: %{name}
Version: %{version}
Version: %{version}
Source0: %{name}-%{version}.tar.gz
Release: %{release}
Provides: tracing-proxy
Expand All @@ -23,38 +23,51 @@ Tracing Proxy
%__rm -rf %{buildroot}
install -p -d -m 0755 %{buildroot}/opt/opsramp/tracing-proxy/bin
install -p -d -m 0755 %{buildroot}/opt/opsramp/tracing-proxy/conf
install -p -d -m 0755 %{buildroot}/opt/opsramp/service_files
install -p -d -m 0755 %{buildroot}/etc/systemd/system
install -p -d -m 0755 %{buildroot}/etc/init.d
install -m 0744 opt/opsramp/tracing-proxy/bin/tracing-proxy %{buildroot}/opt/opsramp/tracing-proxy/bin/
install -m 0744 opt/opsramp/tracing-proxy/bin/configure %{buildroot}/opt/opsramp/tracing-proxy/bin
install -m 0600 opt/opsramp/tracing-proxy/conf/config_complete.yaml %{buildroot}/opt/opsramp/tracing-proxy/conf/
install -m 0600 opt/opsramp/tracing-proxy/conf/rules_complete.yaml %{buildroot}/opt/opsramp/tracing-proxy/conf/
install -m 0644 etc/systemd/system/tracing-proxy.service %{buildroot}/etc/systemd/system
install -m 0600 opt/opsramp/service_files/tracing-proxy %{buildroot}/opt/opsramp/service_files/tracing-proxy
install -m 0600 opt/opsramp/service_files/tracing-proxy.service %{buildroot}/opt/opsramp/service_files/tracing-proxy.service

%clean
%__rm -rf %{buildroot}

%files
/opt/opsramp/tracing-proxy/bin/
/opt/opsramp/tracing-proxy/conf/
/etc/systemd/system/tracing-proxy.service

/opt/opsramp/service_files

%post -p /bin/bash
mkdir -p /var/log/opsramp
touch /var/log/opsramp/tracing-proxy.log
systemctl start tracing-proxy


%preun -p /bin/bash
echo "Uninstalling Tracing Proxy"
systemctl stop tracing-proxy
systemctl disable tracing-proxy
mkdir -p /opt/opsramp/service_files
touch /opt/opsramp/service_files/tracing-proxy.service
touch /opt/opsramp/service_files/tracing-proxy
if [ -f /etc/systemd/system/tracing-proxy.service ]; then
systemctl stop tracing-proxy
systemctl disable tracing-proxy
fi
if [ -f /etc/init.d/tracing-proxy ]; then
service tracing-proxy stop
fi


%postun -p /bin/bash
%__rm -rf /opt/opsramp/tracing-proxy
if [ -f /etc/systemd/system/tracing-proxy.service ]; then
systemctl daemon-reload
systemctl reset-failed tracing-proxy.service > /dev/null 2>&1
%__rm -rf /etc/systemd/system/tracing-proxy.service > /dev/null 2>&1
fi
systemctl daemon-reload
systemctl reset-failed tracing-proxy.service > /dev/null 2>&1
echo "Uninstalled Tracing Proxy Successfully"
if [ -f /etc/init.d/tracing-proxy ]; then
%__rm -rf /etc/init.d/tracing-proxy > /dev/null 2>&1
fi
echo "Uninstalled Tracing Proxy Successfully"
26 changes: 14 additions & 12 deletions collect/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,65 +114,65 @@ func (i *InMemCollector) Start() error {
"trace_operations_latency_ms",
"gauge",
"Trace latency wrt each trace operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_operations_failed",
"counter",
"Number of Error events in spans wrt each trace operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_operations_succeeded",
"counter",
"Number of Succeeded events in spans wrt each trace operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_operations_total",
"counter",
"Total Number of events in spans wrt each trace operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_root_span",
"counter",
"Number of root spans in an operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_spans_count",
"counter",
"Number of spans in an operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_root_operation_latency_ms",
"gauge",
"Trace latency wrt each root trace operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_root_operations_failed",
"counter",
"Number of Error events in root spans wrt each trace operation",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterWithDescriptionLabels(
"trace_operations_error",
"gauge",
"Trace errors wrt each trace operation / trace_span_count",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
)
i.Metrics.RegisterHistogram(
"trace_operations_latency",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
"span latency in microseconds(µs) by service, operation and app",
[]float64{100, 200, 300, 400, 500, 600, 700, 800, 900, 1000},
)
i.Metrics.RegisterHistogram(
"trace_root_operation_latency",
[]string{"service_name", "operation", "app"},
[]string{"service_name", "operation", "app", "instance"},
"root span latency in microseconds(µs) by service, operation and app",
[]float64{100, 200, 300, 400, 500, 600, 700, 800, 900, 1000},
)
Expand Down Expand Up @@ -644,12 +644,14 @@ func (i *InMemCollector) send(trace *types.Trace, reason string) {
}

labelToKeyMap := map[string][]string{
"service_name": {"service_name", "service.name"},
"service_name": {"service_name"}, // service.name is removed from []string because not needed as we are changing in processEvent function of route.go file
"operation": {"spanName"},
"app": {"app"},
"instance": {"instance"},
}

labels := metrics.ExtractLabelsFromSpan(span, labelToKeyMap)
i.Logger.Debug().Logf("========= labels: ", labels, " ===> ", span.Data["instance"])

durationMsString, ok := span.Data["durationMs"]
if ok && durationMsString != nil {
Expand Down
Loading

0 comments on commit 7943a73

Please sign in to comment.