-
Notifications
You must be signed in to change notification settings - Fork 351
[OpAMP.Client] Add support for plain http transport #2926
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
Conversation
Signed-off-by: RassK <[email protected]>
import "anyvalue.proto"; | ||
|
||
option go_package = "github.com/open-telemetry/opamp-go/protobufs"; | ||
option csharp_namespace = "OpAmp.Protocol"; |
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.
Still under review open-telemetry/opamp-spec#243
`OpenTelemetry.OpAmp.Client` | ||
project. | ||
* Initial release of `OpenTelemetry.OpAmp.Client` project. | ||
* Added support for OpAMP Plain Http transport. |
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.
Also needs a link to this PR.
* Added support for OpAMP Plain Http transport. | |
* Added support for OpAMP Plain HTTP transport. |
|
||
namespace OpenTelemetry.OpAmp.Client; | ||
|
||
internal class FrameBuilder : IFrameBuilder |
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.
Unless there's inheritance happening, internal classes can be sealed
as this can help the JIT create better code.
src/OpenTelemetry.OpAmp.Client/Listeners/Messages/AgentIdentificationMessage.cs
Show resolved
Hide resolved
/// <remarks>This enumeration defines the available transport protocols for communication. Use <see | ||
/// cref="WebSocket"/> for WebSocket-based communication, or <see cref="Http"/> for | ||
/// HTTP-based communication.</remarks> | ||
#pragma warning disable SA1201 // Elements should appear in the correct order |
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.
Fix rather than suppress?
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 was mistakenly looking that SA1201 doesn't like it either way, basically prohibits multiple classes in the same file, but didn't want to extract it (yet, or at least not into root).
<!-- .NET Framework supporting packages --> | ||
<ItemGroup Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'"> | ||
<PackageReference Include="System.Net.Http" Version="4.3.4" /> | ||
<PackageReference Include="System.Collections.Immutable" Version="9.0.7" /> |
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.
Considering open-telemetry/opentelemetry-dotnet#6327, I suggest starting with the lowest version possible (e.g. 8.0.0
).
if (!response.IsSuccessStatusCode) | ||
{ | ||
throw new HttpRequestException($"Failed to send message: {response.ReasonPhrase}"); | ||
} |
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.
Just use EnsureSuccessStatusCode()
?
public void Dispose() | ||
{ | ||
this.httpClient?.Dispose(); | ||
this.handler?.Dispose(); | ||
} |
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.
The HttpClient
should be able to be constructed so that it can be told to dispose of the handler itself, then this instance doesn't need to do that or keep a reference to it.
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.
Then you need to suppress CA2000 manually. disposeHandler
is there but static analysis does not pass.
Signed-off-by: RassK <[email protected]>
FYI: PTO 🌴, Will be back in 4th of August. Feel free to push changes and merge if critical stuff got resolved. (you can find context in #2872 if there is something looking very weird, there is kind of a big picture) |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Q: are you tracking aot incompatible libs somewhere? - seems protobuf is not compatible, therefore opamp also. |
There's an issue in Google.Protobuf that broke some native AoT compatibility that I'm aware of: protocolbuffers/protobuf#21824 |
@martincostello do you see anything else that requires attention, since we wait for spec to commit changes. |
/// <remarks>This enumeration defines the available transport protocols for communication. Use <see | ||
/// cref="WebSocket"/> for WebSocket-based communication, or <see cref="Http"/> for | ||
/// HTTP-based communication.</remarks> | ||
internal enum ConnectionType |
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.
This should be in its own file.
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.
where would you put it? ... I did not like root.
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 would put it in ConnectionType.cs
in the root, as otherwise I think the analyzers would complain about the style (having more than one type defined in the same file).
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.
So far no errors like in #2926 (comment)
In the PoC branch I added them to Settings
(since the subs would bloat root).
Those will become public and after that are not movable (not without creating a mess in namespaces).-
So need to get that internal / public boundary right.
src/OpenTelemetry.OpAmp.Client/OpenTelemetry.OpAmp.Client.csproj
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Costello <[email protected]>
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.
LGTM. I will merge as is. It is good groundwork for further changes. I would like to avoid any more huge PRs.
Changes related to the proto namespace can be easily fixed later.
|
||
<ItemGroup> | ||
<PackageReference Include="Google.Protobuf" Version="3.31.1" /> | ||
<PackageReference Include="Grpc.Tools" Version="2.72.0"> |
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.
Just a note: It will not work on ARM, if anybody decide to compile on this machine.
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(NetMinimumSupportedVersion);$(NetStandardMinimumSupportedVersion);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks> | ||
<TargetFrameworks>net9.0;$(NetMinimumSupportedVersion);$(NetStandardMinimumSupportedVersion);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks> |
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.
Note for myself, uid should be generated based on Guid.V7. It is available on .NET9+.
Changes
Adds support for plain http transport (send & receive).
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes