-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from newrelic/develop
Release v3.16.0
- Loading branch information
Showing
53 changed files
with
728 additions
and
360 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,9 +45,12 @@ jobs: | |
|
||
# v2 integrations | ||
- go-version: 1.13.x | ||
# only versions up to 0.24.0 of awssdkv2 are supported by this code | ||
pin: github.com/aws/[email protected] | ||
dirs: _integrations/nrawssdk | ||
- go-version: 1.13.x | ||
dirs: _integrations/nrecho | ||
pin: github.com/labstack/[email protected] | ||
- go-version: 1.13.x | ||
dirs: _integrations/nrgin/v1 | ||
- go-version: 1.13.x | ||
|
@@ -231,6 +234,7 @@ jobs: | |
env: | ||
DIRS: ${{ matrix.dirs }} | ||
EXTRATESTING: ${{ matrix.extratesting }} | ||
PIN: ${{ matrix.pin }} | ||
|
||
go-agent-arm64: | ||
# Run all unit tests on aarch64 emulator to ensure compatibility with AWS | ||
|
@@ -271,7 +275,7 @@ jobs: | |
go version | ||
cd v3/newrelic | ||
go mod download github.com/golang/protobuf | ||
go get | ||
go get -t | ||
echo ==== v3/newrelic tests ==== | ||
go test ./... | ||
cd ../internal | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,21 +19,34 @@ fi | |
|
||
pwd=$(pwd) | ||
|
||
# inputs | ||
# 1: repo pin; example: github.com/rewrelic/[email protected] | ||
pin_go_dependency() { | ||
if [[ ! -z "$1" ]]; then | ||
echo "Pinning: $1" | ||
repo=$(echo "$1" | cut -d '@' -f1) | ||
pinTo=$(echo "$1" | cut -d '@' -f2) | ||
set +e | ||
go get -u "$repo" # this go get will fail to build | ||
set -e | ||
cd "$GOPATH"/src/"$repo" | ||
git checkout "$pinTo" | ||
cd - | ||
fi | ||
} | ||
|
||
IFS="," | ||
for dir in $DIRS; do | ||
cd "$pwd/$dir" | ||
|
||
if [ -f "go.mod" ]; then | ||
go mod edit -replace github.com/newrelic/go-agent/v3=$pwd/v3 | ||
go mod edit -replace github.com/newrelic/go-agent/v3="$pwd"/v3 | ||
fi | ||
|
||
# go get is necessary for testing v2 integrations since they do not have | ||
# a go.mod file. | ||
if [[ $dir =~ "_integrations" ]]; then | ||
go get -t ./... | ||
fi | ||
pin_go_dependency "$PIN" | ||
|
||
# avoid testing v3 code when testing v2 newrelic package | ||
if [ $dir == "." ]; then | ||
if [ "$dir" == "." ]; then | ||
rm -rf v3/ | ||
else | ||
# Only v3 code version 1.9+ needs GRPC dependencies | ||
|
@@ -44,31 +57,29 @@ for dir in $DIRS; do | |
V1_10="1.10" | ||
V1_11="1.11" | ||
V1_12="1.12" | ||
V1_13="1.13" | ||
V1_14="1.14" | ||
if [[ "$VERSION" =~ .*"$V1_7".* || "$VERSION" =~ .*"$V1_8".* ]]; then | ||
echo "Not installing GRPC for old versions" | ||
elif [[ "$VERSION" =~ .*"$V1_9" || "$VERSION" =~ .*"$V1_10" || "$VERSION" =~ .*"$V1_11" || "$VERSION" =~ .*"$V1_12" ]]; then | ||
elif [[ "$VERSION" =~ .*"$V1_9" || "$VERSION" =~ .*"$V1_10" || "$VERSION" =~ .*"$V1_11" || "$VERSION" =~ .*"$V1_12" || "$VERSION" =~ .*"$V1_13" || "$VERSION" =~ .*"$V1_14" ]]; then | ||
# install v3 dependencies that support this go version | ||
set +e | ||
go get -u google.golang.org/grpc # this go get will fail to build | ||
set -e | ||
cd $GOPATH/src/google.golang.org/grpc | ||
git checkout v1.31.0 | ||
cd - | ||
|
||
set +e | ||
go get -u golang.org/x/net/http2 # this go get will fail to build | ||
set -e | ||
cd $GOPATH/src/golang.org/x/net/http2 | ||
git checkout 7fd8e65b642006927f6cec5cb4241df7f98a2210 | ||
cd - | ||
pin_go_dependency "google.golang.org/[email protected]" | ||
pin_go_dependency "golang.org/x/net/http2@7fd8e65b642006927f6cec5cb4241df7f98a2210" | ||
|
||
# install protobuf once dependencies are resolved | ||
go get -u github.com/golang/protobuf/protoc-gen-go | ||
else | ||
go get -u github.com/golang/protobuf/protoc-gen-go | ||
go get -u google.golang.org/grpc | ||
fi | ||
fi | ||
|
||
# go get is necessary for testing v2 integrations since they do not have | ||
# a go.mod file. | ||
if [[ $dir =~ "_integrations" ]]; then | ||
go get -t ./... | ||
fi | ||
|
||
go test -race -benchtime=1ms -bench=. ./... | ||
go vet ./... | ||
|
||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2020 New Relic Corporation. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package sysinfo | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
// PhysicalMemoryBytes returns the total amount of host memory. | ||
func PhysicalMemoryBytes() (uint64, error) { | ||
mib := []int32{6 /* CTL_HW */, 19 /* HW_PHYSMEM64 */} | ||
|
||
buf := make([]byte, 8) | ||
bufLen := uintptr(8) | ||
|
||
_, _, e1 := syscall.Syscall6(syscall.SYS___SYSCTL, | ||
uintptr(unsafe.Pointer(&mib[0])), uintptr(len(mib)), | ||
uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&bufLen)), | ||
uintptr(0), uintptr(0)) | ||
|
||
if e1 != 0 { | ||
return 0, e1 | ||
} | ||
|
||
switch bufLen { | ||
case 4: | ||
return uint64(*(*uint32)(unsafe.Pointer(&buf[0]))), nil | ||
case 8: | ||
return *(*uint64)(unsafe.Pointer(&buf[0])), nil | ||
default: | ||
return 0, syscall.EIO | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2020 New Relic Corporation. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package sysinfo | ||
|
||
import ( | ||
"errors" | ||
"os/exec" | ||
"regexp" | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
var re = regexp.MustCompile(`hw\.physmem=(\d+)`) | ||
|
||
func openbsdSysctlMemoryBytes() (uint64, error) { | ||
out, err := exec.Command("/sbin/sysctl", "hw.physmem").Output() | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
match := re.FindSubmatch(out) | ||
if match == nil { | ||
return 0, errors.New("memory size not found in sysctl output") | ||
} | ||
|
||
bts, err := strconv.ParseUint(string(match[1]), 10, 64) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
return bts, nil | ||
} | ||
|
||
func TestPhysicalMemoryBytes(t *testing.T) { | ||
mem, err := PhysicalMemoryBytes() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
mem2, err := openbsdSysctlMemoryBytes() | ||
if nil != err { | ||
t.Fatal(err) | ||
} | ||
|
||
if mem != mem2 { | ||
t.Errorf("Expected %d, got %d\n", mem2, mem) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.