Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/agentcore-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: agentcore-build-test
on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.23.6"
cache: false

- name: Build agentcore collector
working-directory: ocb-utils/agentcore
run: ./build-agentcore.sh

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: otelcol-agentcore
path: ocb-utils/agentcore/output/otelcol-agentcore
retention-days: 3

e2e-test:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_E2E_TEST_ROLE_ARN }}
aws-region: us-east-1

- name: Download binary
uses: actions/download-artifact@v4
with:
name: otelcol-agentcore
path: ocb-utils/agentcore/output/

- name: Make binary executable
run: chmod +x ocb-utils/agentcore/output/otelcol-agentcore

- name: Run E2E test
working-directory: ocb-utils/agentcore
run: ./test-agentcore.sh
39 changes: 39 additions & 0 deletions ocb-utils/agentcore/Dockerfile.agentcore-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM public.ecr.aws/docker/library/golang:1.23.2 AS build

WORKDIR /tmp/build/
RUN go env -w GOPROXY=direct

ARG OCB_VERSION
ARG GOOS=darwin
ARG GOARCH=arm64

RUN curl --proto '=https' --tlsv1.2 -fL -o ocb \
https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv${OCB_VERSION}/ocb_${OCB_VERSION}_linux_amd64

RUN chmod +x ocb

# Copy entire repo code to container (from repo root)
COPY . /src/opentelemetry-collector-contrib/

# Copy agentcore config file
COPY ocb-utils/agentcore/builder-config-agentcore.yaml ./builder-config-agentcore.yaml

# Install gettext for envsubst
RUN apt-get update && apt-get install -y gettext-base && rm -rf /var/lib/apt/lists/*

# Build collector for target platform
RUN --mount=type=cache,target=/go/pkg/mod \
export OCB_VERSION=${OCB_VERSION} && \
envsubst < builder-config-agentcore.yaml > builder-config-resolved.yaml && \
echo "Building for ${GOOS}/${GOARCH}" && \
cat builder-config-resolved.yaml && \
GOOS=${GOOS} GOARCH=${GOARCH} ./ocb --config builder-config-resolved.yaml --verbose

# Output stage
FROM alpine:latest

COPY --from=build /tmp/build/otelcol-agentcore/otelcol-agentcore /output/

WORKDIR /output

CMD ["sh", "-c", "echo 'Build complete! Binary is in /output/otelcol-agentcore' && tail -f /dev/null"]
152 changes: 152 additions & 0 deletions ocb-utils/agentcore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# OpenTelemetry Collector AgentCore Builder

Build OpenTelemetry Collector with Application Signals components using current branch code.

## Prerequisites

- **Docker**: Must be installed and running (the build runs inside a Docker container)
- **Go**: Required for auto-detecting host platform (`go env GOOS`/`go env GOARCH`)

## Quick Start

Build for the current host platform (auto-detected):
```bash
./build-agentcore.sh
```

## Build for Different Platforms

### macOS ARM64 (Apple Silicon)
```bash
GOOS=darwin GOARCH=arm64 ./build-agentcore.sh
```

### macOS AMD64 (Intel)
```bash
GOOS=darwin GOARCH=amd64 ./build-agentcore.sh
```

### Linux ARM64
```bash
GOOS=linux GOARCH=arm64 ./build-agentcore.sh
```

### Linux AMD64
```bash
GOOS=linux GOARCH=amd64 ./build-agentcore.sh
```

### Windows AMD64
```bash
GOOS=windows GOARCH=amd64 ./build-agentcore.sh
```

## Configuration Options

### OCB Version
Specify OpenTelemetry Collector Builder version (default: 0.121.0):
```bash
OCB_VERSION=0.121.0 ./build-agentcore.sh
```

### Combined Example
Build Linux AMD64 with specific OCB version:
```bash
OCB_VERSION=0.121.0 GOOS=linux GOARCH=amd64 ./build-agentcore.sh
```

## Output

Binary will be created at:
```
./output/otelcol-agentcore
```

## Usage

### Environment Variables

The `config.yaml` uses the following environment variables:

| Variable | Description | Default |
|----------|-------------|---------|
| `AWS_REGION` | AWS Region | `us-west-2` |
| `AWS_APP_LOG_GROUP` | CloudWatch Log Group for application logs (otlphttp/logs) | `AgentCoreAppLogs` |
| `AWS_APP_LOG_STREAM` | CloudWatch Log Stream for application logs (otlphttp/logs) | `default` |
| `AWS_EMF_NAMESPACE` | CloudWatch Metrics Namespace for EMF exporter | `AgentCoreMetrics` |
| `AWS_EMF_LOG_GROUP` | CloudWatch Log Group for EMF metrics | `AgentCoreEMF` |
| `AWS_EMF_LOG_STREAM` | CloudWatch Log Stream for EMF metrics | `default` |

### Run the Collector

With default values (no environment variables needed):
```bash
./output/otelcol-agentcore --config config.yaml
```

With custom values:
```bash
AWS_REGION=us-east-1 \
AWS_APP_LOG_GROUP=MyAppLogs \
AWS_EMF_NAMESPACE=MyMetrics \
./output/otelcol-agentcore --config config.yaml
```

### View Available Components

```bash
./output/otelcol-agentcore components
```

## Pipelines

The default `config.yaml` includes the following pipelines:

| Pipeline | Receivers | Processors | Exporters |
|----------|-----------|------------|-----------|
| **traces** | otlp | batch | debug, otlphttp/traces (X-Ray) |
| **logs** | otlp | batch | debug, otlphttp/logs (CloudWatch Logs) |
| **metrics** | otlp | batch | debug, awsemf (CloudWatch Metrics) |

## Supported Platforms

- **GOOS**: `darwin`, `linux`, `windows`
- **GOARCH**: `amd64`, `arm64`, `386`, `arm`

## Components

The collector includes:
- **Processors**: Attributes, Filter, Metrics Transform, Batch
- **Exporters**: AWS EMF, OTLP HTTP, Debug
- **Receivers**: OTLP
- **Extensions**: AWS Proxy, SigV4 Auth

All AWS Application Signals components use local code from current branch.

## E2E Testing

Build and test in two steps:
```bash
./build-agentcore.sh
./test-agentcore.sh
```

### Prerequisites

- Docker running (for the build step)
- Go (for platform auto-detection)
- Python 3 (venv and pip dependencies are set up automatically by the test script)
- Valid AWS credentials (env vars or `~/.aws/credentials`)

### What the Test Verifies

1. Collector starts and becomes ready
2. Traces, metrics, and logs are sent via OTLP
3. Data arrives in CloudWatch (filtered by test start time to avoid false positives)
4. No export errors in collector logs

| Signal | CloudWatch Log Group | Log Stream |
|--------|---------------------|------------|
| Logs | `AgentCoreAppLogs` | `default` |
| Metrics (EMF) | `AgentCoreEMF` | `default` |
| Traces (Spans) | `aws/spans` | `default` |
68 changes: 68 additions & 0 deletions ocb-utils/agentcore/build-agentcore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

# Build ARM64 Application Signals Collector for macOS
# Usage: ./build-local.sh

set -e

echo "=========================================="
echo "Building ARM64 Application Signals Collector"
echo "=========================================="

# Set variables
IMAGE_NAME="otelcol-appsignals-builder"
CONTAINER_NAME="otelcol-appsignals-build-temp"
OUTPUT_DIR="./output"

# Set build configuration
OCB_VERSION="${OCB_VERSION:-0.121.0}"
GOOS="${GOOS:-$(go env GOOS)}"
GOARCH="${GOARCH:-$(go env GOARCH)}"

echo "OCB Version: $OCB_VERSION"
echo "Target Platform: $GOOS/$GOARCH"
echo "Building with current branch code"

# Clean and create output directory
echo "Cleaning output directory..."
rm -rf "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"

echo ""
echo "Step 1/4: Building Docker image..."
# Switch to repo root directory for build
cd ../..
docker build \
--build-arg OCB_VERSION=$OCB_VERSION \
--build-arg GOOS=$GOOS \
--build-arg GOARCH=$GOARCH \
-f ocb-utils/agentcore/Dockerfile.agentcore-build \
-t $IMAGE_NAME \
.
cd ocb-utils/agentcore

echo ""
echo "Step 2/4: Running temporary container..."
docker run --name $CONTAINER_NAME -d $IMAGE_NAME

echo ""
echo "Step 3/4: Copying binary from container to local..."
docker cp $CONTAINER_NAME:/output/otelcol-agentcore "$OUTPUT_DIR/otelcol-agentcore"

echo ""
echo "Step 4/4: Cleaning up temporary container..."
docker rm -f $CONTAINER_NAME

echo ""
echo "=========================================="
echo "✅ Build completed!"
echo "=========================================="
echo ""
echo "Binary location: $OUTPUT_DIR/otelcol-agentcore"
echo ""
echo "Verify file:"
ls -lh "$OUTPUT_DIR/otelcol-agentcore"
echo ""
echo "Usage:"
echo " $OUTPUT_DIR/otelcol-agentcore --config /path/to/your/config.yaml"
echo ""
30 changes: 30 additions & 0 deletions ocb-utils/agentcore/builder-config-agentcore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
dist:
name: otelcol-agentcore
description: OTel Collector for Application Signals (Local Build)
output_path: ./otelcol-agentcore

exporters:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter v${OCB_VERSION}
- gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v${OCB_VERSION}
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v${OCB_VERSION}

processors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v${OCB_VERSION}
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v${OCB_VERSION}
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/metricstransformprocessor v${OCB_VERSION}
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v${OCB_VERSION}

receivers:
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v${OCB_VERSION}

extensions:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/awsproxy v${OCB_VERSION}
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/sigv4authextension v${OCB_VERSION}

replaces:
# Replace components with local directory
- github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v${OCB_VERSION} => /src/opentelemetry-collector-contrib/internal/aws/awsutil
- github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs v${OCB_VERSION} => /src/opentelemetry-collector-contrib/internal/aws/cwlogs
- github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter v${OCB_VERSION} => /src/opentelemetry-collector-contrib/exporter/awsemfexporter
- github.com/amazon-contributing/opentelemetry-collector-contrib/processor/awsapplicationsignalsprocessor v${OCB_VERSION} => /src/opentelemetry-collector-contrib/processor/awsapplicationsignalsprocessor
- github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37
Loading
Loading