Skip to content

Commit

Permalink
AIMonitoring being disabled still sends requests out
Browse files Browse the repository at this point in the history
  • Loading branch information
mirackara committed Mar 8, 2024
1 parent e75efc0 commit 9b00c4a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions v3/integrations/nropenai/nropenai.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ func NRCreateChatCompletionMessage(txn *newrelic.Transaction, app *newrelic.Appl
func NRCreateChatCompletion(cw *ClientWrapper, req openai.ChatCompletionRequest, app *newrelic.Application) (ChatCompletionResponseWrapper, error) {
config, _ := app.Config()
resp := ChatCompletionResponseWrapper{}
// If AI Monitoring is disabled, do not start a transaction
// If AI Monitoring is disabled, do not start a transaction but still perform the request
if !config.AIMonitoring.Enabled {
return resp, errAIMonitoringDisabled
chatresp, err := cw.Client.CreateChatCompletion(context.Background(), req)
resp.ChatCompletionResponse = chatresp
return resp, err
}
// Start NR Transaction
txn := app.StartTransaction("OpenAIChatCompletion")
Expand Down Expand Up @@ -282,7 +284,8 @@ func NRCreateEmbedding(cw *ClientWrapper, req openai.EmbeddingRequest, app *newr

// If AI Monitoring is disabled, do not start a transaction but still perform the request
if !config.AIMonitoring.Enabled {
return resp, errAIMonitoringDisabled
resp, err := cw.Client.CreateEmbeddings(context.Background(), req)
return resp, err
}

// Start NR Transaction
Expand Down

0 comments on commit 9b00c4a

Please sign in to comment.