-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[App Insights] Adding Data Plane SDK #4088
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
874f0f1
Adding initial AI Data Plane
3cedc06
Updated generated code & added some metric & event extensions
0b0c535
Added metric extension tests
0dc9eed
Tests & fixes for event extensions
b19a44a
Updated AI Data Plane SDK
e5eebe3
Minor cleanup to SDK
alexeldeib 18b3b17
Fix typing of eventId, rows
alexeldeib 1a3c621
Fix tests
alexeldeib 8b2ae31
Update directory structure; generate.cmd; solution + project files
alexeldeib 64f8c7c
Fix solution project file
alexeldeib 7d522e3
Merge branch 'psSdkJson6' of github.com:Azure/azure-sdk-for-net into …
alexeldeib 329fe62
regen from pssdkjson6
alexeldeib 5f69bed
add git commit
alexeldeib b266bea
adding generated artifacts
alexeldeib 4d588f9
updating csproj, adding build artifacts
alexeldeib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 21 additions & 0 deletions
21
.../ApplicationInsights/Data.ApplicationInsights.Tests/Data.ApplicationInsights.Tests.csproj
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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" /> | ||
<PropertyGroup> | ||
<PackageId>Data.ApplicationInsights.Tests</PackageId> | ||
<Description>Data.ApplicationInsights.Tests Class library</Description> | ||
<PackageId>Data.ApplicationInsights.Tests</PackageId> | ||
<VersionPrefix>1.0.0-preview</VersionPrefix> | ||
<TargetFrameworks>netcoreapp1.1</TargetFrameworks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Update="SessionRecords\**\*.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="[1.6.0-preview, 2.0.0)" /> | ||
<ProjectReference Include="..\Data.ApplicationInsights\Microsoft.Azure.ApplicationInsights.csproj" /> | ||
<!-- Enable below line in local to work around the bug that cannot find test cases --> | ||
<!--<PackageReference Update="Microsoft.NET.Test.Sdk" Version="15.3.0" />--> | ||
</ItemGroup> | ||
</Project> |
23 changes: 23 additions & 0 deletions
23
src/SDKs/ApplicationInsights/Data.ApplicationInsights.Tests/DataPlaneTestBase.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,23 @@ | ||
using Microsoft.Azure.ApplicationInsights; | ||
using Microsoft.Azure.Test.HttpRecorder; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using System; | ||
|
||
namespace Data.ApplicationInsights.Tests | ||
{ | ||
public abstract class DataPlaneTestBase | ||
{ | ||
protected const string DefaultAppId = "DEMO_APP"; | ||
protected const string DefaultApiKey = "DEMO_KEY"; | ||
|
||
protected ApplicationInsightsDataClient GetClient(MockContext ctx, string appId = DefaultAppId, string apiKey = DefaultApiKey) | ||
{ | ||
var credentials = new ApiKeyClientCredentials(apiKey); | ||
var client = new ApplicationInsightsDataClient(credentials, HttpMockServer.CreateInstance()); | ||
client.AppId = appId; | ||
client.BaseUri = new Uri("https://api.applicationinsights.io/v1"); | ||
|
||
return client; | ||
} | ||
} | ||
} |
221 changes: 221 additions & 0 deletions
221
...ationInsights/Data.ApplicationInsights.Tests/ScenarioTests/Events/EventsExtensionTests.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,221 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Data.ApplicationInsights.Tests.Events; | ||
using Microsoft.Azure.ApplicationInsights; | ||
using Microsoft.Azure.ApplicationInsights.Models; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using Newtonsoft.Json; | ||
using Xunit; | ||
|
||
namespace Data.ApplicationInsights.Tests.ScenarioTests.Events | ||
{ | ||
public class EventsExtensionTests : EventsTestBase | ||
{ | ||
[Theory] | ||
[MemberData(nameof(TraceData))] | ||
[MemberData(nameof(CustomEventsData))] | ||
[MemberData(nameof(PageViewsData))] | ||
[MemberData(nameof(BrowserTimingsData))] | ||
[MemberData(nameof(RequestsData))] | ||
[MemberData(nameof(DependenciesData))] | ||
[MemberData(nameof(ExceptionsData))] | ||
[MemberData(nameof(AvailabilityResultsData))] | ||
[MemberData(nameof(PerformanceCountersData))] | ||
[MemberData(nameof(CustomMetricsData))] | ||
public async Task GetEventsAsync<T>(EventType eventType, MultiQueryAsync<T> multiQueryAsync, SingleQueryAsync<T> singleQueryAsync, | ||
object unused1, object unused2) where T : EventsResultData | ||
{ | ||
using (var ctx = MockContext.Start(GetType().FullName, $"GetEvents.{eventType}")) | ||
{ | ||
var timespan = new TimeSpan(12, 0, 0); | ||
var top = 10; | ||
|
||
var client = GetClient(ctx); | ||
var events = await multiQueryAsync(client, timespan, top); | ||
|
||
Assert.NotNull(events); | ||
Assert.NotNull(events.Value); | ||
Assert.True(events.Value.Count > 0); | ||
Assert.True(events.Value.Count <= top); | ||
|
||
foreach (var e in events.Value) | ||
{ | ||
AssertEvent(e, eventType); | ||
} | ||
|
||
Assert.True(!string.IsNullOrEmpty(events.Value[0].Id)); | ||
|
||
var evnt = await singleQueryAsync(client, events.Value[0].Id, timespan); | ||
|
||
Assert.NotNull(evnt); | ||
Assert.NotNull(evnt.Value); | ||
Assert.True(evnt.Value.Count == 1); | ||
|
||
Assert.Equal(JsonConvert.SerializeObject(evnt.Value[0]), | ||
JsonConvert.SerializeObject(events.Value[0])); | ||
} | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TraceData))] | ||
[MemberData(nameof(CustomEventsData))] | ||
[MemberData(nameof(PageViewsData))] | ||
[MemberData(nameof(BrowserTimingsData))] | ||
[MemberData(nameof(RequestsData))] | ||
[MemberData(nameof(DependenciesData))] | ||
[MemberData(nameof(ExceptionsData))] | ||
[MemberData(nameof(AvailabilityResultsData))] | ||
[MemberData(nameof(PerformanceCountersData))] | ||
[MemberData(nameof(CustomMetricsData))] | ||
public void GetEvents<T>(EventType eventType, object unused1, object unused2, | ||
MultiQuery<T> multiQuery, SingleQuery<T> singleQuery) where T : EventsResultData | ||
{ | ||
using (var ctx = MockContext.Start(GetType().FullName, $"GetEvents.{eventType}")) | ||
{ | ||
var timespan = new TimeSpan(12, 0, 0); | ||
var top = 10; | ||
|
||
var client = GetClient(ctx); | ||
var events = multiQuery(client, timespan, top); | ||
|
||
Assert.NotNull(events); | ||
Assert.NotNull(events.Value); | ||
Assert.True(events.Value.Count > 0); | ||
Assert.True(events.Value.Count <= top); | ||
|
||
foreach (var e in events.Value) | ||
{ | ||
AssertEvent(e, eventType); | ||
} | ||
|
||
Assert.True(!string.IsNullOrEmpty(events.Value[0].Id)); | ||
|
||
var evnt = singleQuery(client, events.Value[0].Id, timespan); | ||
|
||
Assert.NotNull(evnt); | ||
Assert.NotNull(evnt.Value); | ||
Assert.True(evnt.Value.Count == 1); | ||
|
||
Assert.Equal(JsonConvert.SerializeObject(evnt.Value[0]), | ||
JsonConvert.SerializeObject(events.Value[0])); | ||
} | ||
} | ||
|
||
public delegate Task<EventsResults<T>> MultiQueryAsync<T>(ApplicationInsightsDataClient client, System.TimeSpan? timespan, int top) where T : EventsResultData; | ||
public delegate Task<EventsResults<T>> SingleQueryAsync<T>(ApplicationInsightsDataClient client, string id, System.TimeSpan? timespan) where T : EventsResultData; | ||
|
||
public delegate EventsResults<T> MultiQuery<T>(ApplicationInsightsDataClient client, System.TimeSpan? timespan, int top) where T : EventsResultData; | ||
public delegate EventsResults<T> SingleQuery<T>(ApplicationInsightsDataClient client, string id, System.TimeSpan? timespan) where T : EventsResultData; | ||
|
||
private static readonly object[] TraceParams = new object[] | ||
{ | ||
EventType.Traces, | ||
new MultiQueryAsync<EventsTraceResult>(async (client, timespan, top) => await client.GetTraceEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsTraceResult>(async (client, id, timespan) => await client.GetTraceEventAsync(id, timespan)), | ||
new MultiQuery<EventsTraceResult>((client, timespan, top) => client.GetTraceEvents(timespan, top: top)), | ||
new SingleQuery<EventsTraceResult>((client, id, timespan) => client.GetTraceEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] CustomEventsParams = new object[] | ||
{ | ||
EventType.CustomEvents, | ||
new MultiQueryAsync<EventsCustomEventResult>(async (client, timespan, top) => await client.GetCustomEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsCustomEventResult>(async (client, id, timespan) => await client.GetCustomEventAsync(id, timespan)), | ||
new MultiQuery<EventsCustomEventResult>((client, timespan, top) => client.GetCustomEvents(timespan, top: top)), | ||
new SingleQuery<EventsCustomEventResult>((client, id, timespan) => client.GetCustomEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] PageViewsParams = new object[] | ||
{ | ||
EventType.PageViews, | ||
new MultiQueryAsync<EventsPageViewResult>(async (client, timespan, top) => await client.GetPageViewEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsPageViewResult>(async (client, id, timespan) => await client.GetPageViewEventAsync(id, timespan)), | ||
new MultiQuery<EventsPageViewResult>((client, timespan, top) => client.GetPageViewEvents(timespan, top: top)), | ||
new SingleQuery<EventsPageViewResult>((client, id, timespan) => client.GetPageViewEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] BrowserTimingsParams = new object[] | ||
{ | ||
EventType.BrowserTimings, | ||
new MultiQueryAsync<EventsBrowserTimingResult>(async (client, timespan, top) => await client.GetBrowserTimingEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsBrowserTimingResult>(async (client, id, timespan) => await client.GetBrowserTimingEventAsync(id, timespan)), | ||
new MultiQuery<EventsBrowserTimingResult>((client, timespan, top) => client.GetBrowserTimingEvents(timespan, top: top)), | ||
new SingleQuery<EventsBrowserTimingResult>((client, id, timespan) => client.GetBrowserTimingEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] RequestsParams = new object[] | ||
{ | ||
EventType.Requests, | ||
new MultiQueryAsync<EventsRequestResult>(async (client, timespan, top) => await client.GetRequestEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsRequestResult>(async (client, id, timespan) => await client.GetRequestEventAsync(id, timespan)), | ||
new MultiQuery<EventsRequestResult>((client, timespan, top) => client.GetRequestEvents(timespan, top: top)), | ||
new SingleQuery<EventsRequestResult>((client, id, timespan) => client.GetRequestEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] DependenciesParams = new object[] | ||
{ | ||
EventType.Dependencies, | ||
new MultiQueryAsync<EventsDependencyResult>(async (client, timespan, top) => await client.GetDependencyEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsDependencyResult>(async (client, id, timespan) => await client.GetDependencyEventAsync(id, timespan)), | ||
new MultiQuery<EventsDependencyResult>((client, timespan, top) => client.GetDependencyEvents(timespan, top: top)), | ||
new SingleQuery<EventsDependencyResult>((client, id, timespan) => client.GetDependencyEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] ExceptionsParams = new object[] | ||
{ | ||
EventType.Exceptions, | ||
new MultiQueryAsync<EventsExceptionResult>(async (client, timespan, top) => await client.GetExceptionEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsExceptionResult>(async (client, id, timespan) => await client.GetExceptionEventAsync(id, timespan)), | ||
new MultiQuery<EventsExceptionResult>((client, timespan, top) => client.GetExceptionEvents(timespan, top: top)), | ||
new SingleQuery<EventsExceptionResult>((client, id, timespan) => client.GetExceptionEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] AvailabilityResultsParams = new object[] | ||
{ | ||
EventType.AvailabilityResults, | ||
new MultiQueryAsync<EventsAvailabilityResultResult>(async (client, timespan, top) => await client.GetAvailabilityResultEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsAvailabilityResultResult>(async (client, id, timespan) => await client.GetAvailabilityResultEventAsync(id, timespan)), | ||
new MultiQuery<EventsAvailabilityResultResult>((client, timespan, top) => client.GetAvailabilityResultEvents(timespan, top: top)), | ||
new SingleQuery<EventsAvailabilityResultResult>((client, id, timespan) => client.GetAvailabilityResultEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] PerformanceCountersParams = new object[] | ||
{ | ||
EventType.PerformanceCounters, | ||
new MultiQueryAsync<EventsPerformanceCounterResult>(async (client, timespan, top) => await client.GetPerformanceCounterEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsPerformanceCounterResult>(async (client, id, timespan) => await client.GetPerformanceCounterEventAsync(id, timespan)), | ||
new MultiQuery<EventsPerformanceCounterResult>((client, timespan, top) => client.GetPerformanceCounterEvents(timespan, top: top)), | ||
new SingleQuery<EventsPerformanceCounterResult>((client, id, timespan) => client.GetPerformanceCounterEvent(id, timespan)), | ||
}; | ||
|
||
private static readonly object[] CustomMetricsParams = new object[] | ||
{ | ||
EventType.CustomMetrics, | ||
new MultiQueryAsync<EventsCustomMetricResult>(async (client, timespan, top) => await client.GetCustomMetricEventsAsync(timespan, top: top)), | ||
new SingleQueryAsync<EventsCustomMetricResult>(async (client, id, timespan) => await client.GetCustomMetricEventAsync(id, timespan)), | ||
new MultiQuery<EventsCustomMetricResult>((client, timespan, top) => client.GetCustomMetricEvents(timespan, top: top)), | ||
new SingleQuery<EventsCustomMetricResult>((client, id, timespan) => client.GetCustomMetricEvent(id, timespan)), | ||
}; | ||
|
||
public static IEnumerable<object[]> TraceData { get { yield return TraceParams; } } | ||
|
||
public static IEnumerable<object[]> CustomEventsData { get { yield return CustomEventsParams; } } | ||
|
||
public static IEnumerable<object[]> PageViewsData { get { yield return PageViewsParams; } } | ||
|
||
public static IEnumerable<object[]> BrowserTimingsData { get { yield return BrowserTimingsParams; } } | ||
|
||
public static IEnumerable<object[]> RequestsData { get { yield return RequestsParams; } } | ||
|
||
public static IEnumerable<object[]> DependenciesData { get { yield return DependenciesParams; } } | ||
|
||
public static IEnumerable<object[]> ExceptionsData { get { yield return ExceptionsParams; } } | ||
|
||
public static IEnumerable<object[]> AvailabilityResultsData { get { yield return AvailabilityResultsParams; } } | ||
|
||
public static IEnumerable<object[]> PerformanceCountersData { get { yield return PerformanceCountersParams; } } | ||
|
||
public static IEnumerable<object[]> CustomMetricsData { get { yield return CustomMetricsParams; } } | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the intention behind building against portable configurations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None -- not sure when this snuck in. I removed it while changing up the directory structure.