-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix incorrectly tagging AIM data when AIM is disabled (#2408)
- Loading branch information
Showing
3 changed files
with
90 additions
and
1 deletion.
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
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
82 changes: 82 additions & 0 deletions
82
tests/Agent/IntegrationTests/IntegrationTests/LLM/LLMDisabledTests.cs
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,82 @@ | ||
// Copyright 2020 New Relic, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NewRelic.Agent.IntegrationTestHelpers; | ||
using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace NewRelic.Agent.IntegrationTests.LLM | ||
{ | ||
public abstract class LlmDisabledTestsBase<TFixture> : NewRelicIntegrationTest<TFixture> | ||
where TFixture : ConsoleDynamicMethodFixture | ||
{ | ||
private readonly TFixture _fixture; | ||
private const string _model = "meta13"; | ||
private string _prompt = "In one sentence, what is a large-language model?"; | ||
|
||
public LlmDisabledTestsBase(TFixture fixture, ITestOutputHelper output) : base(fixture) | ||
{ | ||
_fixture = fixture; | ||
_fixture.SetTimeout(TimeSpan.FromMinutes(2)); | ||
_fixture.TestLogger = output; | ||
_fixture.AddActions( | ||
setupConfiguration: () => | ||
{ | ||
new NewRelicConfigModifier(fixture.DestinationNewRelicConfigFilePath) | ||
.ForceTransactionTraces() | ||
.EnableAiMonitoring(false) | ||
.SetLogLevel("finest"); | ||
}, | ||
exerciseApplication: () => | ||
{ | ||
_fixture.AgentLog.WaitForLogLines(AgentLogBase.MetricDataLogLineRegex, TimeSpan.FromMinutes(2), 2); | ||
} | ||
); | ||
|
||
_fixture.AddCommand($"LLMExerciser InvokeModel {_model} {LLMHelpers.ConvertToBase64(_prompt)}"); | ||
|
||
_fixture.Initialize(); | ||
} | ||
|
||
[Fact] | ||
public void BedrockDisabledTest() | ||
{ | ||
// Make sure it actually got called | ||
var transactionEvent = _fixture.AgentLog.TryGetTransactionEvent($"OtherTransaction/Custom/MultiFunctionApplicationHelpers.NetStandardLibraries.LLM.LLMExerciser/InvokeModel"); | ||
Assert.NotNull(transactionEvent); | ||
|
||
var unexpectedMetrics = new List<Assertions.ExpectedMetric> | ||
{ | ||
new Assertions.ExpectedMetric { metricName = @"Supportability/DotNet/ML/Bedrock/.*", IsRegexName = true }, | ||
new Assertions.ExpectedMetric { metricName = @"Custom/Llm/.*", IsRegexName = true }, | ||
}; | ||
|
||
var metrics = _fixture.AgentLog.GetMetrics().ToList(); | ||
Assertions.MetricsDoNotExist(unexpectedMetrics, metrics); | ||
|
||
|
||
} | ||
} | ||
[NetCoreTest] | ||
public class LlmDisabledTest_CoreLatest : LlmDisabledTestsBase<ConsoleDynamicMethodFixtureCoreLatest> | ||
{ | ||
public LlmDisabledTest_CoreLatest(ConsoleDynamicMethodFixtureCoreLatest fixture, ITestOutputHelper output) | ||
: base(fixture, output) | ||
{ | ||
} | ||
} | ||
|
||
[NetFrameworkTest] | ||
public class LlmDisabledTest_FWLatest : LlmDisabledTestsBase<ConsoleDynamicMethodFixtureFWLatest> | ||
{ | ||
public LlmDisabledTest_FWLatest(ConsoleDynamicMethodFixtureFWLatest fixture, ITestOutputHelper output) | ||
: base(fixture, output) | ||
{ | ||
} | ||
} | ||
|
||
} |