-
Notifications
You must be signed in to change notification settings - Fork 715
Add Aspire.Hosting.Maui (.NET MAUI) Android integration + OpenTelemetry connectivity through dev tunnels #12381
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
Open
jfversluis
wants to merge
14
commits into
main
Choose a base branch
from
jfversluis/maui-android
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,987
−809
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2aaef80
Android integration
jfversluis c8436c2
Update tests and readme
jfversluis b5934a8
Address comment in #12342
jfversluis 70211f3
Address other comment in #12342
jfversluis f8cc646
Remove duplicate name check
jfversluis 26d4072
Add WithOtlpDevTunnel functionality
jfversluis 7612db8
Apply suggestions from code review
jfversluis 8f17d90
Update src/Aspire.Hosting.Maui/Utilities/MauiEnvironmentHelper.cs
jfversluis 293930b
Improve DCP value detection
jfversluis 0a51458
Refactor MauiAndroidEnvironmentProcessedAnnotation marker
jfversluis 42ba6bc
Revert "Update src/Aspire.Hosting.Maui/Utilities/MauiEnvironmentHelpe…
jfversluis af3a4ae
Share OtlpEndpointResolver
jfversluis 925675d
Refactor OTLP endpoint default value handling
jfversluis fb95dcd
Improve OTLP tunnel name
jfversluis 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 hidden or 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 hidden or 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 hidden or 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
40 changes: 40 additions & 0 deletions
40
src/Aspire.Hosting.Maui/Annotations/OtlpDevTunnelConfigurationAnnotation.cs
This file contains hidden or 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,40 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Aspire.Hosting.ApplicationModel; | ||
| using Aspire.Hosting.DevTunnels; | ||
| using Aspire.Hosting.Maui.Otlp; | ||
|
|
||
| namespace Aspire.Hosting.Maui.Annotations; | ||
|
|
||
| /// <summary> | ||
| /// Annotation that stores the OTLP dev tunnel configuration for a MAUI project. | ||
| /// This allows sharing a single dev tunnel infrastructure across multiple platform resources. | ||
| /// </summary> | ||
| internal sealed class OtlpDevTunnelConfigurationAnnotation : IResourceAnnotation | ||
| { | ||
| /// <summary> | ||
| /// The OTLP loopback stub resource that acts as the service discovery target. | ||
| /// </summary> | ||
| public OtlpLoopbackResource OtlpStub { get; } | ||
|
|
||
| /// <summary> | ||
| /// The resource builder for the OTLP stub (used for WithReference calls). | ||
| /// </summary> | ||
| public IResourceBuilder<OtlpLoopbackResource> OtlpStubBuilder { get; } | ||
|
|
||
| /// <summary> | ||
| /// The dev tunnel resource that tunnels the OTLP endpoint. | ||
| /// </summary> | ||
| public IResourceBuilder<DevTunnelResource> DevTunnel { get; } | ||
|
|
||
| public OtlpDevTunnelConfigurationAnnotation( | ||
| OtlpLoopbackResource otlpStub, | ||
| IResourceBuilder<OtlpLoopbackResource> otlpStubBuilder, | ||
| IResourceBuilder<DevTunnelResource> devTunnel) | ||
| { | ||
| OtlpStub = otlpStub; | ||
| OtlpStubBuilder = otlpStubBuilder; | ||
| DevTunnel = devTunnel; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,20 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace Aspire.Hosting.Maui; | ||
|
|
||
| /// <summary> | ||
| /// A resource that represents an Android physical device for running a .NET MAUI application. | ||
| /// </summary> | ||
| /// <param name="name">The name of the Android device resource.</param> | ||
| /// <param name="parent">The parent MAUI project resource.</param> | ||
| public sealed class MauiAndroidDeviceResource(string name, MauiProjectResource parent) | ||
| : ProjectResource(name), IMauiPlatformResource | ||
| { | ||
| /// <summary> | ||
| /// Gets the parent MAUI project resource. | ||
| /// </summary> | ||
| public MauiProjectResource Parent { get; } = parent; | ||
| } |
This file contains hidden or 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,20 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace Aspire.Hosting.Maui; | ||
|
|
||
| /// <summary> | ||
| /// A resource that represents an Android emulator for running a .NET MAUI application. | ||
| /// </summary> | ||
| /// <param name="name">The name of the Android emulator resource.</param> | ||
| /// <param name="parent">The parent MAUI project resource.</param> | ||
| public sealed class MauiAndroidEmulatorResource(string name, MauiProjectResource parent) | ||
| : ProjectResource(name), IMauiPlatformResource | ||
| { | ||
| /// <summary> | ||
| /// Gets the parent MAUI project resource. | ||
| /// </summary> | ||
| public MauiProjectResource Parent { get; } = parent; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Why not have this on by default? OTEL that just works by default is one of Aspire's most popular features.
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.
I guess I built it like this with the option in mind to provide a custom endpoint later or even use something entirely different like ngrok?
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.
Experimented with this a little but didn't get it quite right yet. My idea would then be: automatic dev tunnel when nothing is configured and when we detect a custom OTLP endpoint env var, then no dev tunnel and we just use that value.
People can then set it through
SetEnvironment()or just as an env var on the host machine directly or if they choose to build some ngrok integration, they need to make sure to set it from there. Does that make sense?If we want to explore down that path I think it might be good to do that in a follow-up PR.