feat: Add logging custom attributes #1541
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2023 New Relic Corporation. All rights reserved. | |
# SPDX-License-Identifier: Apache-2.0 | |
name: Go Agent CI | |
on: pull_request | |
env: | |
# Specifies which go version to run integration tests on | |
INTEGRATION_TESTS_GO_VERSION: latest | |
jobs: | |
go-agent-v3: | |
runs-on: ubuntu-latest | |
strategy: | |
# if one test fails, do not abort the rest | |
fail-fast: false | |
matrix: | |
include: | |
# Core Tests on 3 most recent major Go versions | |
- go-version: 1.24.0 | |
dirs: v3/newrelic,v3/internal,v3/examples | |
- go-version: 1.23.0 | |
dirs: v3/newrelic,v3/internal,v3/examples | |
- go-version: latest | |
dirs: v3/newrelic,v3/internal,v3/examples | |
# Integration Tests on highest Supported Go Version | |
- dirs: v3/integrations/nramqp | |
- dirs: v3/integrations/nrfasthttp | |
- dirs: v3/integrations/nrsarama | |
- dirs: v3/integrations/logcontext/nrlogrusplugin | |
- dirs: v3/integrations/logcontext-v2/nrlogrus | |
- dirs: v3/integrations/logcontext-v2/nrzerolog | |
- dirs: v3/integrations/logcontext-v2/nrzap | |
- dirs: v3/integrations/logcontext-v2/nrslog | |
- dirs: v3/integrations/logcontext-v2/nrwriter | |
- dirs: v3/integrations/logcontext-v2/zerologWriter | |
- dirs: v3/integrations/logcontext-v2/logWriter | |
- dirs: v3/integrations/nrawssdk-v1 | |
- dirs: v3/integrations/nrawssdk-v2 | |
- dirs: v3/integrations/nrecho-v3 | |
- dirs: v3/integrations/nrecho-v4 | |
- dirs: v3/integrations/nrelasticsearch-v7 | |
- dirs: v3/integrations/nrgin | |
- dirs: v3/integrations/nrfiber | |
- dirs: v3/integrations/nrgorilla | |
- dirs: v3/integrations/nrgraphgophers | |
- dirs: v3/integrations/nrlogrus | |
- dirs: v3/integrations/nrlogxi | |
- dirs: v3/integrations/nrpkgerrors | |
- dirs: v3/integrations/nrlambda | |
- dirs: v3/integrations/nrmysql | |
- dirs: v3/integrations/nrpq | |
- dirs: v3/integrations/nrpgx5 | |
- dirs: v3/integrations/nrpq/example/sqlx | |
- dirs: v3/integrations/nrredis-v7 | |
- dirs: v3/integrations/nrredis-v9 | |
- dirs: v3/integrations/nrsqlite3 | |
- dirs: v3/integrations/nrsnowflake | |
- dirs: v3/integrations/nrgrpc | |
- dirs: v3/integrations/nrmicro | |
- dirs: v3/integrations/nrnats | |
- dirs: v3/integrations/nrstan | |
- dirs: v3/integrations/nrstan/test | |
- dirs: v3/integrations/nrstan/examples | |
- dirs: v3/integrations/logcontext | |
- dirs: v3/integrations/nrzap | |
- dirs: v3/integrations/nrhttprouter | |
- dirs: v3/integrations/nrb3 | |
- dirs: v3/integrations/nrmongo | |
- dirs: v3/integrations/nrgraphqlgo,v3/integrations/nrgraphqlgo/example | |
- dirs: v3/integrations/nrmssql | |
- dirs: v3/integrations/nropenai | |
- dirs: v3/integrations/nrslog | |
- dirs: v3/integrations/nrgochi | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
with: | |
path: "go-agent" | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.24.0 | |
check-latest: true | |
- name: Install dependencies | |
run: | | |
IFS=',' read -ra DIR_LIST <<< "${{ matrix.dirs }}" | |
for dir in "${DIR_LIST[@]}"; do | |
cd go-agent/$dir | |
if [[ "$dir" == "v3/integrations/nrnats" ]]; then | |
GOPROXY=direct go mod tidy | |
else | |
go mod tidy | |
fi | |
cd - # Return to the root to avoid path issues | |
done | |
- name: Run tests | |
run: | | |
IFS=',' read -ra DIR_LIST <<< "${{ matrix.dirs }}" | |
for dir in "${DIR_LIST[@]}"; do | |
if [[ "$dir" == "v3/examples" ]]; then | |
echo "Skipping tests for $dir" | |
continue | |
fi | |
cd go-agent/$dir | |
# Generate coverage profile | |
go test -coverprofile=coverage.txt | |
cd - # Return to root to avoid path issues | |
done | |
- name: Upload results to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: go-agent/${{ matrix.dirs }}/coverage.txt | |
- name: Build Docker Image | |
run: docker build -f ${{ github.workspace }}/go-agent/Dockerfile ${{ github.workspace }} --build-arg GO_VERSION=${{ matrix.go-version || env.INTEGRATION_TESTS_GO_VERSION }} -t go-agent-tests-amd64 | |
- name: Set up Docker container and run tests | |
run: | | |
IFS=',' read -ra DIRS <<< "${{ matrix.dirs }}" | |
for dir in "${DIRS[@]}"; do | |
if [ -d "go-agent/$dir" ]; then | |
# Create Coverage Report Directory for CodeCov | |
coverage_dir="${{ github.workspace }}/coverage-reports" | |
mkdir -p "$coverage_dir" | |
# Special case for nrnats, which requires direct module proxying | |
if [[ "$dir" == *"nrnats"* ]]; then | |
docker run -e GOPROXY=direct -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e GITHUB_HEAD_REF=${GITHUB_HEAD_REF} -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir" "/coverage" | |
else | |
docker run -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e GITHUB_HEAD_REF=${GITHUB_HEAD_REF} -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir" "/coverage" | |
fi | |
else | |
echo "Directory /app/$dir does not exist." | |
fi | |
done | |
# Arm64 tests | |
go-agent-v3-arm64: | |
runs-on: ubuntu-24.04-arm | |
strategy: | |
# if one test fails, do not abort the rest | |
fail-fast: false | |
matrix: | |
include: | |
# Core Tests on 3 most recent major Go versions | |
- go-version: 1.24.0 | |
dirs: v3/newrelic,v3/internal,v3/examples | |
- go-version: 1.23.0 | |
dirs: v3/newrelic,v3/internal,v3/examples | |
- go-version: latest | |
dirs: v3/newrelic,v3/internal,v3/examples | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
with: | |
path: "go-agent" | |
- name: Build Docker Image | |
run: docker build -f ${{ github.workspace }}/go-agent/Dockerfile ${{ github.workspace }} --build-arg GO_VERSION=${{ matrix.go-version || env.INTEGRATION_TESTS_GO_VERSION }} -t go-agent-tests-amd64 | |
- name: Set up Docker container and run tests | |
run: | | |
IFS=',' read -ra DIRS <<< "${{ matrix.dirs }}" | |
for dir in "${DIRS[@]}"; do | |
if [ -d "go-agent/$dir" ]; then | |
# Create Coverage Report Directory for CodeCov | |
coverage_dir="${{ github.workspace }}/coverage-reports" | |
mkdir -p "$coverage_dir" | |
# Special case for nrnats, which requires direct module proxying | |
if [[ "$dir" == *"nrnats"* ]]; then | |
docker run -e GOPROXY=direct -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e GITHUB_HEAD_REF=${GITHUB_HEAD_REF} -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir" "/coverage" | |
else | |
docker run -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e GITHUB_HEAD_REF=${GITHUB_HEAD_REF} -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir" "/coverage" | |
fi | |
else | |
echo "Directory /app/$dir does not exist." | |
fi | |
done |