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

Overhaul metrics [feature branch] #3209

Merged
merged 110 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
4d6efa0
Initial commit before rebasing onto master
LaPeste Nov 2, 2022
6000c71
Readds needed using after rebase
LaPeste Nov 2, 2022
78334f9
Merge branch 'main' of github.com:realm/realm-dotnet into ac/analytic…
LaPeste Nov 3, 2022
9d6ce91
Finalises backbone of the implementation for early feedback. Diagnost…
LaPeste Nov 3, 2022
0c457d4
Removes leftover import
LaPeste Nov 3, 2022
7763e8d
Adds many more fields, polishes the already done ones and moves from …
LaPeste Nov 9, 2022
b724d82
Adds a small optimisation that hasn't been measured yet and tested th…
LaPeste Nov 15, 2022
03c13d6
Adjusts a condition value in the sc csproj
LaPeste Nov 15, 2022
daf82cb
Adds minor comments
LaPeste Nov 16, 2022
f9afdf1
Fixes a small mistake in the usage of the new dictionary for actions …
LaPeste Nov 16, 2022
339be41
Merge branch 'main' of github.com:realm/realm-dotnet into ac/analytic…
LaPeste Nov 24, 2022
33349e2
Quickly wraps up the code to share it with Nikola
LaPeste Dec 1, 2022
38185f0
Add basic analytics tests
nirinchev Dec 1, 2022
fe27607
Don't delete non-existent directories
nirinchev Dec 1, 2022
7791b90
Disable async warning
nirinchev Dec 1, 2022
0f13ddb
Fixed for merge of Nikola's work (test analytics)
LaPeste Dec 5, 2022
cc9acf8
Merge branch 'ni/analytics-testing' of github.com:realm/realm-dotnet …
LaPeste Dec 5, 2022
0b343ad
The majority of the tests have been added and pass. However, the SG i…
LaPeste Dec 12, 2022
c23aa7c
Cleans some leftovers from Doagnostics and fixes all the tests
LaPeste Dec 12, 2022
2eb9878
Readds a line removed by mistake
LaPeste Dec 12, 2022
e609885
Merge branch 'main' into ac/analytics-in-sg
LaPeste Dec 13, 2022
e780344
Avoids empty WrapInTryCatch when not in DEBUG
LaPeste Dec 13, 2022
d9db9ac
Fixes weaver tests that started failing plus small cleanup
LaPeste Dec 13, 2022
9066755
Minor cleanup
LaPeste Dec 13, 2022
162b6c3
Adds support for SG test suite for metrics
LaPeste Dec 13, 2022
6108921
Removes a CS8 construct as only CS7.3 is supported
LaPeste Dec 14, 2022
0a43b37
Beginning of a deep cleanup
LaPeste Dec 14, 2022
ae2d9d6
Some more cleanup
LaPeste Dec 14, 2022
69d6d1e
Still cleanup
LaPeste Dec 14, 2022
3777e57
Removes a todo
LaPeste Dec 15, 2022
643f7df
Fixes an issue with release builds
LaPeste Dec 15, 2022
aae17be
Removes a lot of CodeQL issues
LaPeste Dec 15, 2022
7631dae
Removes more CodeQL issues
LaPeste Dec 15, 2022
638af27
Reverts some changes in SyntaxContextReceiver
LaPeste Dec 15, 2022
9e5041b
Cleans up a few more things
LaPeste Dec 16, 2022
6b40ed0
Adds more minor clean-ups
LaPeste Dec 16, 2022
fcb05bb
Adds metrics for backlinks and addUpdate
LaPeste Dec 19, 2022
eccce07
Small details from PR review
LaPeste Dec 19, 2022
4dc7cf8
Weaver based and SG based tests are now passing and removes all the a…
LaPeste Dec 22, 2022
3857a6b
Undoes the changes in fakeforweaver
LaPeste Dec 22, 2022
8b8fba5
Still cleans up fakeforweaver
LaPeste Dec 22, 2022
82fac81
Removes 2 todos
LaPeste Dec 22, 2022
bb0aee8
Accomplishes some todos
LaPeste Jan 5, 2023
1fcafaf
Adds some better error messages in analytics tests
LaPeste Jan 6, 2023
c7d13fc
Still adding more try catches in analytics tests
LaPeste Jan 6, 2023
79a9cdb
Tests if the issue is net472
LaPeste Jan 6, 2023
71c62e2
Revert "Tests if the issue is net472"
LaPeste Jan 6, 2023
db3e80e
Tries again to remove net472
LaPeste Jan 6, 2023
5d5e9e5
Readds net472 to AnalyticsAssembly as that was not the problem
LaPeste Jan 6, 2023
81fa467
Adds more debugging on the payload file for analytics test
LaPeste Jan 6, 2023
a651507
Should fix the failing test by avoiding fody to weave while compiling
LaPeste Jan 6, 2023
ca87b17
Cleans up a few small cosmetic details
LaPeste Jan 9, 2023
791dae7
Merge branch 'main' into ac/analytics-in-sg
LaPeste Jan 9, 2023
7c95c31
Adds entry in the changelog
LaPeste Jan 9, 2023
6f58096
Revert "Adds entry in the changelog"
LaPeste Jan 9, 2023
e4509dc
Adds entry in the changelog.
LaPeste Jan 9, 2023
9f8e868
Adds some initial work, mostly guess work, on calculating what versio…
LaPeste Jan 12, 2023
dd77733
Updates generated classes
LaPeste Jan 12, 2023
9253440
Adds missing metrics but left blank
LaPeste Jan 12, 2023
061cc93
Merge branch 'main' into ac/analytics-in-sg
LaPeste Jan 13, 2023
45e8f81
Fixes merge issues in CHANGELOG
LaPeste Jan 13, 2023
5429735
Renames some info coming from Unity and adds a few todo comments
LaPeste Jan 13, 2023
8819c46
Fixes Host OS version string
LaPeste Jan 13, 2023
669d0bd
Adds what should have been brought in the last commit: proper OS vers…
LaPeste Jan 13, 2023
3668e50
Final touches before sending for PR review
LaPeste Jan 16, 2023
f9dbb6a
Adds a minor improvement in readbaility for properties returning a re…
LaPeste Jan 18, 2023
9355fa2
PR feedback: removes performance data from SG and reshapes switch cas…
LaPeste Jan 19, 2023
6bb8121
PR feedback: Fixes indentation in AnalyticsAssembly/Program.cs
LaPeste Jan 19, 2023
864146a
PR feedback: slightly changes the mechanics around the analytics dict…
LaPeste Jan 22, 2023
23f58c5
Set LangVersion to 9 for UnityWeaver
LaPeste Jan 23, 2023
7e960d2
Last touches before PR review
LaPeste Jan 23, 2023
c76dfd7
Aligns some misunderstanding in some of the names in the analytics
LaPeste Jan 26, 2023
a0ccb5d
Adds all win platforms to ConvertPlatformIdOsToMetricVersion
LaPeste Jan 27, 2023
81dc132
Fixes some var names for metrics
LaPeste Jan 27, 2023
aa3a9d7
PR feedback: Micro change on Program.cs to the main method
LaPeste Jan 27, 2023
4e84d36
Add suggestions to the analytics PR (#3208)
nirinchev Feb 1, 2023
ffbd19a
Merge branch 'ac/analytics-in-sg' into ac/overhaul-metrics
LaPeste Feb 1, 2023
3ca646c
Language version bumped up on Realm.UnityWeaver.csproj
LaPeste Feb 1, 2023
a6df11e
Set core version in analytics (#3189)
papafe Feb 1, 2023
79e6f5f
Find installation method for analytics (#3204)
papafe Feb 2, 2023
cdeb259
Adds stable Id for metrics (#3203)
LaPeste Feb 6, 2023
1a9cc37
Merge branch 'main' into ac/overhaul-metrics
LaPeste Feb 9, 2023
3f62fbe
Don't wait for analytics submission (#3211)
nirinchev Feb 9, 2023
22115fb
Merge branch 'main' into ac/overhaul-metrics
LaPeste Feb 14, 2023
039dffb
Fix unity hanging while in its sort-of-headless mode (#3228)
LaPeste Feb 15, 2023
0f9364f
Fix UWP not building on CI (#3239)
LaPeste Feb 23, 2023
143a62f
Adds minor fixes of bugs discovered while manually testing (#3244)
LaPeste Mar 2, 2023
1ebfe2e
Adds hostOS tests to the weaver (#3246)
LaPeste Mar 2, 2023
0edadcd
Merge branch 'main' into ac/overhaul-metrics
nirinchev Mar 2, 2023
bdd041d
Bring back the legacy distinct id
nirinchev Mar 15, 2023
18db4c8
Use `IsOnPlatform` and fix the Realm.sln
nirinchev Mar 20, 2023
cad7e12
Collect target OS versions; add a few more tests
nirinchev Mar 21, 2023
35ab0c6
report msbuild for compiler
nirinchev Mar 21, 2023
c699d38
Merge branch 'main' into ac/overhaul-metrics
nirinchev Mar 24, 2023
b43d984
Remove usage of valuetuple in weaver
nirinchev Mar 24, 2023
d6a818a
Merge branch 'main' into ac/overhaul-metrics
nirinchev Mar 24, 2023
dc0694d
Fix analytics tests project
nirinchev Mar 24, 2023
20daf00
Merge branch 'main' into ac/overhaul-metrics
nirinchev Mar 27, 2023
9c0d9e2
Merge branch 'main' into ac/overhaul-metrics
nirinchev Jun 12, 2023
97ef1d7
Try to fix Realm.sln
nirinchev Jun 12, 2023
1326646
Fix Realm.sln again
nirinchev Jun 12, 2023
85f37a3
Merge fixes
nirinchev Jun 12, 2023
9ca9214
Unify bundle id across sync and compile-time metrics
nirinchev Jun 12, 2023
119a48a
Setup workloads, fix some analytics tests
nirinchev Jun 12, 2023
fd89d8b
fallback for android
nirinchev Jun 13, 2023
71dd03c
Fix weaver test workflow
nirinchev Jun 13, 2023
0ec1cae
Don't install ios, maccatalyst workloads on linux
nirinchev Jun 13, 2023
29a713d
Enable nullability
nirinchev Jun 13, 2023
34c8091
Fix the schema definition
nirinchev Jun 15, 2023
967f8ad
Fix analytics tests
nirinchev Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/templates/test-weaver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ env:
DOTNET_NOLOGO: true
jobs:
run-tests-weaver:
runs-on: windows-latest
strategy:
matrix:
os:
- runner: windows-latest
runtime: win-x64
- runner: ubuntu-latest
runtime: linux-x64
- runner: macos-latest
runtime: osx-x64
runs-on: ${{ matrix.os.runner }}
name: Weaver
timeout-minutes: 15
steps:
- #@ template.replace(checkoutCode())
- #@ template.replace(dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "netcoreapp3.1", "win-x64"))
- #@ template.replace(dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}"))
- name: Run Tests
run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.Weaver.xml --labels=After
- #@ publishTestsResults("TestResults.Weaver.xml", "Weaver")
15 changes: 15 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Read Core version
id: get-core-version
run: |
cd wrappers/realm-core
pkgVersion=$(grep "\bVERSION=" dependencies.list | cut -d= -f2)
echo "core-version=$pkgVersion" >> $GITHUB_OUTPUT
shell: bash
- name: Update Analytics.cs
uses: jacobtomlinson/gha-find-replace@0dfd0777cc234ef6947ec1f20873c632114c4167 #! 0.1.4
with:
find: '_coreVersion = "\w*"'
replace: '_coreVersion = "${{ steps.get-core-version.outputs.core-version }}"'
include: Realm/Realm.Weaver/Analytics/Analytics.cs
- name: Update Changelog
id: update-changelog
uses: realm/ci-actions/update-changelog@187889c026eb16673dba3152906a46ed87406e30
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/test-weaver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ env:
DOTNET_NOLOGO: true
jobs:
run-tests-weaver:
runs-on: windows-latest
strategy:
matrix:
os:
- runner: windows-latest
runtime: win-x64
- runner: ubuntu-latest
runtime: linux-x64
- runner: macos-latest
runtime: osx-x64
runs-on: ${{ matrix.os.runner }}
name: Weaver
timeout-minutes: 15
steps:
Expand All @@ -20,10 +29,10 @@ jobs:
- name: Register msvc problem matcher
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
- name: Publish Tests/Weaver/Realm.Fody.Tests
run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f netcoreapp3.1 -r win-x64 --no-self-contained
run: dotnet publish Tests/Weaver/Realm.Fody.Tests -c Release -f net6.0 -r ${{ matrix.os.runtime }} --no-self-contained
- name: Output executable path
id: dotnet-publish
run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/netcoreapp3.1/win-x64' >> $GITHUB_OUTPUT
run: echo 'executable-path=./Tests/Weaver/Realm.Fody.Tests/bin/Release/net6.0/${{ matrix.os.runtime }}' >> $GITHUB_OUTPUT
shell: bash
- name: Run Tests
run: ${{ steps.dotnet-publish.outputs.executable-path }}/Realm.Fody.Tests --result=TestResults.Weaver.xml --labels=After
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
* Realm Studio: 13.0.0 or later.

### Internal
* Using Core 13.2.0.
* Overhauled and extended the metrics collection of the SDK to better drive future development effort. (PR [#3080](https://github.com/realm/realm-dotnet/pull/3080))
* Using Core 13.4.0.
* Updated `DynamicRealmObjectHelper.TryGetPrimaryKeyValue` not to use reflection. (Issue [#3166](https://github.com/realm/realm-dotnet/issues/3166))
* Fixed UWP tests workflow when running a debug build. (Issue [#3030](https://github.com/realm/realm-dotnet/issues/3030))
Expand Down
284 changes: 168 additions & 116 deletions Realm - Windows.sln

Large diffs are not rendered by default.

871 changes: 448 additions & 423 deletions Realm.sln

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Realm/Realm.Fody/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Nicer organization that way.", Scope = "type", Target = "~T:RealmWeaver.WeaveTypeResult")]
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Nicer organization that way", Scope = "type", Target = "~T:RealmWeaver.WeavePropertyResult")]
[assembly: SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "It doesn't really conflict with anything.", Scope = "member", Target = "~M:RealmWeaver.ILogger.Error(System.String,Mono.Cecil.Cil.SequencePoint)")]
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1000:Keywords should be spaced correctly", Justification = "In C# 9.0 we can use new() to instantiate objects and we don't need a space there", Scope = "module")]
78 changes: 27 additions & 51 deletions Realm/Realm.Fody/ModuleWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Runtime.Versioning;
using Mono.Cecil.Cil;
using RealmWeaver;
using static RealmWeaver.Analytics;

public partial class ModuleWeaver : Fody.BaseModuleWeaver, ILogger
{
Expand Down Expand Up @@ -55,66 +56,41 @@ public override IEnumerable<string> GetAssembliesForScanning()
yield return "System.Threading";
}

private Analytics.Config GetAnalyticsConfig(FrameworkName frameworkName)
private Config GetAnalyticsConfig(FrameworkName frameworkName)
{
var disableAnalytics = bool.TryParse(Config.Attribute("DisableAnalytics")?.Value, out var result) && result;

var config = new Analytics.Config
AnalyticsCollection analyticsCollection;
if (Enum.TryParse<AnalyticsCollection>(Config.Attribute("AnalyticsCollection")?.Value, out var collection))
{
Framework = "xamarin", // This is for backwards compatibility
RunAnalytics = !disableAnalytics,
};

config.FrameworkVersion = frameworkName.Version.ToString();
config.TargetOSName = GetTargetOSName(frameworkName);

// For backward compatibility
config.TargetOSVersion = frameworkName.Version.ToString();

return config;
}

private static string GetTargetOSName(FrameworkName frameworkName)
{
try
analyticsCollection = collection;
}
else if (bool.TryParse(Config.Attribute("DisableAnalytics")?.Value, out var disableAnalytics))
{
// Legacy reporting used ios, osx, and android
switch (frameworkName.Identifier)
{
case "Xamarin.iOS":
return "ios";
case "Xamarin.Mac":
return "osx";
case "MonoAndroid":
case "Mono.Android":
return "android";
}

if (frameworkName.Identifier.EndsWith("-android", StringComparison.OrdinalIgnoreCase))
{
return "android";
}

if (frameworkName.Identifier.EndsWith("-ios", StringComparison.OrdinalIgnoreCase))
{
return "ios";
}

if (frameworkName.Identifier.EndsWith("-maccatalyst", StringComparison.OrdinalIgnoreCase))
{
return "osx";
}
analyticsCollection = disableAnalytics ? AnalyticsCollection.Disabled : AnalyticsCollection.Full;
}
else if (Environment.GetEnvironmentVariable("REALM_DISABLE_ANALYTICS") != null || Environment.GetEnvironmentVariable("CI") != null)
{
analyticsCollection = AnalyticsCollection.Disabled;
}
catch
else
{
#if DEBUG
// Make sure we get build failures and address the problem in debug,
// but don't fail users' builds because of that.
throw;
analyticsCollection = AnalyticsCollection.DryRun;
#else
analyticsCollection = AnalyticsCollection.Full;
#endif
}

return "windows";
var config = new Config
{
AnalyticsCollection = analyticsCollection,
AnalyticsLogPath = Config.Attribute("AnalyticsLogPath")?.Value,
InstallationMethod = "Nuget",
};

config.NetFrameworkTarget = frameworkName.Identifier;
config.NetFrameworkTargetVersion = frameworkName.Version.ToString();
config.TargetOSName = AnalyticsUtils.GetTargetOsName(frameworkName);
return config;
}

void ILogger.Debug(string message)
Expand Down
2 changes: 1 addition & 1 deletion Realm/Realm.Fody/Realm.Fody.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<CodeAnalysisRuleSet>$(ProjectDir)..\..\global.ruleset</CodeAnalysisRuleSet>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn),1591, NU5100, NU5128</NoWarn>
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>
<IncludeSymbols>False</IncludeSymbols>
</PropertyGroup>
<ItemGroup Label="References">
Expand Down
2 changes: 1 addition & 1 deletion Realm/Realm.UnityWeaver/Realm.UnityWeaver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Title>Realm.UnityWeaver</Title>
<ReleaseNotes>https://docs.mongodb.com/realm-sdks/dotnet/latest/CHANGELOG.html</ReleaseNotes>
<CodeAnalysisRuleSet>$(ProjectDir)..\..\global.ruleset</CodeAnalysisRuleSet>
<LangVersion>9.0</LangVersion>
<AssemblyName>Realm.UnityWeaver</AssemblyName>
<NoWarn>1701;1702;NU1701</NoWarn>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading