Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW_RELIC_ENABLED env var not respected #215

Open
rittneje opened this issue Jun 4, 2024 · 2 comments
Open

NEW_RELIC_ENABLED env var not respected #215

rittneje opened this issue Jun 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@rittneje
Copy link

rittneje commented Jun 4, 2024

Description

If we set NEW_RELIC_ENABLED=0, the Go agent won't report anything. However, the extension does not respect this env var. Consequently, it waits for telemetry that will never come, and ends up timing out 200 ms before actual timeout. (From AWS's perspective, the function was running the whole time and we get billed for it.)

// Set the timeout timer for a smidge before the actual timeout; we can recover from false timeouts.
timeoutWatchBegins := 200 * time.Millisecond
timeLimitContext, timeLimitCancel := context.WithDeadline(ctx, timeoutInstant.Add(-timeoutWatchBegins))
// Before we begin to await telemetry, harvest and ship. Ripe telemetry will mostly be handled here. Even that is a
// minority of invocations. Putting this here lets us run the HTTP request to send to NR in parallel with the Lambda
// handler, reducing or eliminating our latency impact.
pollLogServer(logServer, batch)
shipHarvest(ctx, batch.Harvest(time.Now()), telemetryClient)
select {
case <-timeLimitContext.Done():
timeLimitCancel()
// We are about to timeout
probablyTimeout = true
continue
case telemetryBytes := <-telemetryChan:
timeLimitCancel()
// We received telemetry
util.Debugf("Agent telemetry bytes: %s", base64.URLEncoding.EncodeToString(telemetryBytes))
inv := batch.AddTelemetry(lastRequestId, telemetryBytes)
if inv == nil {
util.Logf("Failed to add telemetry for request %v", lastRequestId)
}
// Opportunity for an aggressive harvest, in which case, we definitely want to wait for the HTTP POST
// to complete. Mostly, nothing really happens here.
pollLogServer(logServer, batch)
shipHarvest(ctx, batch.Harvest(time.Now()), telemetryClient)
}

Steps to Reproduce

See above.

Expected Behavior

Extension should be a no-op if NEW_RELIC_ENABLED=0.

Relevant Logs / Console output

Your Environment

Additional context

@rittneje rittneje added the bug Something isn't working label Jun 4, 2024
@workato-integration
Copy link

@chaudharysaket
Copy link
Collaborator

Hi @rittneje
We haveNEW_RELIC_LAMBDA_EXTENSION_ENABLED lambda environment variable to enable/disable extension, as defined here

Currently, we see that different language agent is using a different env var to enable instrumentation, as mentioned here.
env var for controlling whether the agent is enabled differs across agents:
Go: NEW_RELIC_ENABLED
Ruby: NEW_RELIC_AGENT_ENABLED
Node.js: NEW_RELIC_ENABLED

Since lambda extension supports all language runtimes, it should respect all agent specific env vars. We will look into the issue such that lambda extension should respect the agent enable environment variable.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants