Skip to content

Conversation

@sharpSteff
Copy link
Contributor

@sharpSteff sharpSteff commented May 16, 2024

Hi Aspire-Team,

Great work with the Aspire-Dashboard.
I'm currently looking for a replacement for current OTLP-Backend (https://github.com/SigNoz/signoz), and Aspire Dashboard seems to be a lightweight sulution.

However we are relying in the HTTP OTLP Receiver (#3688). Therefore i tried my best to add HTTP OTLP endpoint support and it works quite will in our usecase.

With this changes Aspire Dashboard can consume OTLP Grpc and http(s) simultaneously. Due to the http/protobuf I could reuse the existing grpc-otlps models and services

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-dashboard label May 16, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 16, 2024
@davidfowl davidfowl requested a review from JamesNK May 16, 2024 06:45
Comment on lines 49 to 54
private static async Task<byte[]> ReadFullyAsync(HttpContext context)
{
using var ms = new MemoryStream();
await context.Request.Body.CopyToAsync(ms).ConfigureAwait(false);
return ms.ToArray();
}
Copy link
Member

@davidfowl davidfowl May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be using pipelines to buffer without allocating a memory stream and a byte[]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I achieve this?
Google.Protobuf.MessageParser<T> wants either ReadOnlySequence<byte> , ReadOnlySpan<byte> or a Stream. but the HttpContext.Request.Body-Stream can not be passed directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidfowl I got rid of the byte[] and stream allocation

@davidfowl
Copy link
Member

The formatting changes make it really hard to review. I don't know if you can undo those but with a big change like this it really makes the diff bigger than it needs to be.

@sharpSteff
Copy link
Contributor Author

The formatting changes make it really hard to review. I don't know if you can undo those but with a big change like this it really makes the diff bigger than it needs to be.

I reverted the format changes. Sorry for that

@eerhardt
Copy link
Member

Are there tests that can be written for this new functionality?

Copy link
Member

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good addition, thanks. Left a few comments.

It'd be great to add a playground application that exercised these options, so there was an F5-able test bed, for manual testing.

There are integration tests for the current gRPC-based OTLP interactions. Having similar tests for the HTTP interactions would be valuable to ensure this scenario doesn't break.

@sharpSteff
Copy link
Contributor Author

sharpSteff commented May 22, 2024

@eerhardt @drewnoakes

Are there tests that can be written for this new functionality?

I added for all endpoints IntegrationTests in OtlpServiceTests.cs

Copy link
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small nits but also big issues. I need to read the OTLP HTTP spec to understand what exactly we need to support.

I'm on leave at the moment, but when I get back (beginning of June) are you ok with me making changes to your PR? I think communicating everything via comments will be too much overhead.

@dotnet-policy-service dotnet-policy-service bot added the needs-author-action An issue or pull request that requires more info or actions from the author. label May 23, 2024
@sharpSteff
Copy link
Contributor Author

sharpSteff commented May 23, 2024

@JamesNK It's a big honor to receive a review of Newtonsoft.Json's author. Thanks for all your work!

@dotnet-policy-service dotnet-policy-service bot removed the needs-author-action An issue or pull request that requires more info or actions from the author. label May 23, 2024
@JamesNK
Copy link
Member

JamesNK commented Jun 19, 2024

I made a bunch of changes.

  • Locked the endpoint down to Protobuf payloads
  • Make OTLP/gRPC endpoint optional. Either OTLP/gRPC or OTLP/HTTP is required.
  • More tests

TODO: There is still work to get the url flowing from the AppHost to the dashboard. I want to make it so that both endpoints are created if specified in app host launchSettings.json. The gRPC address is priorizited. But if the gRPC address is missing then OTLP/HTTP is used.

@JamesNK JamesNK requested a review from drewnoakes June 20, 2024 04:38
@JamesNK
Copy link
Member

JamesNK commented Jun 20, 2024

I think everything is done and this is mergeable. Looking for reviews and approvals.

A follow-up piece of work is changing the app host templates to include DOTNET_DASHBOARD_OTLP_HTTP_ENDPOINT_URL env var. Will do that in its own PR as I think it merits its own discussion without distraction.

public const string ProtobufContentType = "application/x-protobuf";
public const string JsonContentType = "application/json";

public static void ConfigureHttpOtlp(this IEndpointRouteBuilder endpoints)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
public static void ConfigureHttpOtlp(this IEndpointRouteBuilder endpoints)
public static void MapOtlpEndpoints(this IEndpointRouteBuilder endpoints)

Map* is the verb we use for adding routes. Configure is for options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I came up with the Map* verb back in .NET Core 3 😋

JamesNK and others added 2 commits June 20, 2024 20:56
public const string ProtobufContentType = "application/x-protobuf";
public const string JsonContentType = "application/json";

public static void MapHttpOtlpApi(this IEndpointRouteBuilder endpoints)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's typically recommended that MapX implementations like this one return the IEndpoitRouteBuilder instance passed in in order to support chaining invocations onto the call (e.g. adding metadata via WithMetadta). Is there a particular reason to prohibit chaining on this API?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only called in on place. It’s not a library, just part of an app. It’s less important in that context

}
}

private sealed class OtlpResult<T> : IResult where T : IMessage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it helpful for this result type to implement IEndpointMetadataProvider so that information about the response produced from these endpoints can surface to documentation tools like OpenAPI?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, the dashboard doesn't produce OpenAPI. This can improve later if that changes.

@JamesNK JamesNK enabled auto-merge (squash) June 20, 2024 23:53
@JamesNK JamesNK merged commit c971a93 into dotnet:main Jun 21, 2024
@JamesNK
Copy link
Member

JamesNK commented Jun 21, 2024

Merged! Thanks for your work on this @sharpSteff.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-dashboard community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants