Manual instrumentation
Prerequisites
- Ensure Golang version 1.19 or higher
- SixthSense account and access to the SixthSense platform.
- Downloaded SixthSense Go Agent binary for the target operating system and architecture.
- Root access or sudo privileges on the target machine.
Instrumentation (Outside Docker)
- Obtain the SixthSense GO Agent Binary.
Download the appropriate SixthSense GO Agent binary for your operating system and architecture (for example, sixthsense-go-agent-0.5.0-linux-arm64).
curl --header "PRIVATE-TOKEN: AUTH_TOKEN" --output sixthsense-go-agent.zip "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/62/packages/generic/Go-Agent/v0.5.0/sixthsense-go-agent.zip"
Make the Agent Executable:
- Open a terminal.
- Navigate to the directory where you placed the SixthSense GO Agent binary.
cd /path/sixthsense/agent/directory
chmod +x sixthsense-go-agent-<VERSION>-<OS>-<ARCH>
EXAMPLE: chmod +x sixthsense-go-agent-0.5.0-linux-amd64
Inject the Agent :
- Navigate to the root directory of your GO application:
cd /path/to/application-root/ # Replace with the actual path
- Run the agent injection command:
/path/to/sixthsense-go-agent-<VERSION>-<OS>-<ARCH> -inject /path/to/application-root/ -all
Build the Application
- Build the application with the SixthSense GO Agent as the tool executor:
go build -toolexec="/path/sixthsense/agent/directory/sixthsense-go-agent-<VERSION>-<OS>-<ARCH> " -a -o myapp . # Replace 'myapp' with your desired application name
note
The -a flag forces a rebuild of all packages. This is important to ensure that the instrumentation is applied correctly.
Set Environment Variables
export SW_AGENT_NAME=<SERVICE-NAME>
export SW_AGENT_REPORTER_GRPC_BACKEND_SERVICE=<gRPC-URL>
export SW_AGENT_REPORTER_GRPC_AUTHENTICATION=<ss-dashboard Token>
export SW_SERVICE_TEAM_ID=<team-id>
export SW_AGENT_COLLECTOR_GRPC_TLS_ENABLE=true
Instrumentation with Docker
FROM golang: 1.23.7-alpine AS builder
WORKDIR /app
# Copy application code
COPY . /app
# Copy your custom SixthSense GO Agent binary
COPY build/sixthsense-go-agent-<VERSION>-<OS>-<ARCH> /app/sixthsense-go-agent
# Make the agent executable
RUN chmod +x /app/sixthsense-go-agent
# Inject the agent into the project and build
RUN /app/sixthsense-go-agent -inject /app -all && \
go build -toolexec="/app/sixthsense-go-agent" -a -o main .
# Create a lean runtime image
FROM alpine:latest
WORKDIR /app
# Copy the built binary and agent
COPY --from=builder /app/main /app/main
COPY --from=builder /app/sixthsense-go-agent /app/sixthsense-go-agent
# Set executable permissions (if needed)
RUN chmod +x /app/main
CMD ["./main"]