Skip to content

Commit

Permalink
Silence Errors On Agent Version Check Connectivity Issues (#97)
Browse files Browse the repository at this point in the history
Closes #96

This will still log the error if in debug mode.
  • Loading branch information
kolanos authored Dec 3, 2021
1 parent 5f42a5f commit 1c498e7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion checks/runtime_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func checkAndReturnRuntime() (runtimeConfig, error) {
func latestAgentTag(r *runtimeConfig) error {
resp, err := client.Get(r.agentVersionUrl)
if err != nil {
return err
// Likely a connectivity issue, log the error but skip check
util.Debugf("Can't query latest agent version. Request to %v returned error %v", r.agentVersionUrl, err)
return nil
}

defer resp.Body.Close()
Expand Down
2 changes: 1 addition & 1 deletion checks/runtime_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestRuntimeCheckNil(t *testing.T) {

func TestLatestAgentTag(t *testing.T) {
client = &mockClientError{}
assert.Error(t, latestAgentTag(&runtimeConfig{}))
assert.Nil(t, latestAgentTag(&runtimeConfig{}))

client = &mockClientRedirect{}
assert.Nil(t, latestAgentTag(&runtimeConfig{}))
Expand Down
8 changes: 4 additions & 4 deletions examples/sam/java/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ sam build --use-container

bucket="newrelic-example-${region}-${accountId}"

aws s3 mb --region ${region} s3://${bucket}
#aws s3 mb --region ${region} s3://${bucket}

sam package --region ${region} --s3-bucket=${bucket} --output-template-file packaged.yaml
aws cloudformation deploy --region ${region} \
sam package --region ${region} --s3-bucket ${bucket} --output-template-file packaged.yaml
sam deploy --region ${region} \
--template-file packaged.yaml \
--stack-name NewrelicExampleJava \
--stack-name NewrelicExampleJava2 \
--capabilities CAPABILITY_IAM \
--parameter-overrides "NRAccountId=${accountId}"
4 changes: 2 additions & 2 deletions examples/sam/java/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Resources:
Layers:
# This layer includes the New Relic Java agent and Lambda Extension, a sidecar process that sends telemetry,
# as well as the New Relic Agent for java, and a handler wrapper that makes integration easy.
- !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:451483290750:layer:NewRelicJava11:3
- !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:451483290750:layer:NewRelicJava11:11
Policies:
# This policy allows the lambda to know the value of the New Relic licence key. We need this so
# that we can send telemetry back to New Relic
Expand All @@ -49,7 +49,7 @@ Resources:
NEW_RELIC_LAMBDA_HANDLER: com.newrelic.lambda.example.Stream::handleRequest
NEW_RELIC_ACCOUNT_ID: !Sub ${NRAccountId}
Layers:
- !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:451483290750:layer:NewRelicJava11:2
- !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:451483290750:layer:NewRelicJava11:11
Policies:
- AWSSecretsManagerGetSecretValuePolicy:
SecretArn: !ImportValue NewRelicLicenseKeySecret-NewRelic-LicenseKeySecretARN
Expand Down
2 changes: 1 addition & 1 deletion util/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package util

const (
Name = "newrelic-lambda-extension"
Version = "2.0.5"
Version = "2.0.6"
Id = Name + ":" + Version
)

0 comments on commit 1c498e7

Please sign in to comment.