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

[DEV-52] Plugins reloaded: Metrics and Diagnostics support #42

Merged
merged 13 commits into from
May 16, 2024

Conversation

RagingKore
Copy link
Contributor

@RagingKore RagingKore commented May 14, 2024

Added: new Plugin base class for a simpler implementation with diagnostics and metrics support
Added: new SubsystemsPlugin base class for a simpler implementation with diagnostics and metrics support
Added: PluginDiagnosticsDataCollector to collect all data diags from the plugins
Added: automatic license checking if a licence public key is provided.
Fixed: Licence test
Changed: IPlugableComponent removing CollectTelemetry method and adding other properties like Name and Version
Removed: Serilog dependency

Background and Motivation

Creating plugins should be simpler, and support pushing metrics and diagnostics data to the host.
Connectors are a prime example of a plugin that requires all these capabilities on top of an improved dev ex.

Solution

  • Plugin base classes were created with automatic default behaviours and values. The new Plugin base class has the capability to publish diagnostics to the system via DiagnosticsListener.
  • There is now automatic license checking if a licence public key is provided.
  • This also allowed for the removal of coupled and the weakly typed CollectTelemetry operation.
  • The plugin now has a default name based on the implementing class without the suffixes of Plugin, Component and Subsystem and Subsystems
  • PluginDiagnosticsDataCollector component to be used in ESDB in order to replace the TelemetryService logic.
public class TcpApiPlugin() : SubsystemsPlugin(licensePublicKey: LicensePublicKey) {
    const string LicensePublicKey = "ZKfMEgCQQDGtRXI-bla-bla-blagkAPOZHTbPQM5AgMBAAE=";

    protected override (bool Enabled, string EnableInstructions) IsEnabled(IConfiguration configuration) {
        var options = configuration.GetSection("EventStore").Get<EventStoreOptions>() ?? new();

        return options.TcpPlugin.EnableExternalTcp
            ? (true, "")
            : (false, "To enable set EnableExternalTcp plugin setting to true");
    }

    protected override void ConfigureServices(IServiceCollection services, IConfiguration configuration) =>
        services.AddHostedService<PublicTcpApiService>();
}
public sealed class ConnectorsPlugin : SubsystemsPlugin {
    protected override void ConfigureServices(IServiceCollection services, IConfiguration configuration) {
        services.AddSingleton<SystemConnectorsFactory>();
        
        services
            .AddGrpc()
            .AddJsonTranscoding();
        
        services.AddConnectorsControlPlane();
    }

    protected override void ConfigureApplication(IApplicationBuilder app, IConfiguration configuration) =>
        app.UseConnectorsManagement();
}

Bonus

  • Removed dependency on Serilog as we can simply use the system ILogger if needed.
  • Restructured the solution by moving the .sln file to root and moving tests to test folder.
  • Upgraded all packages.
  • Refactored the remaining code.

new subsystem plugin base class with default Meter
removed serilog
code cleanup
fixed some comments
better docs
more tests
modified sln moving tests into test folder and solution file and editorconfig to root.
@RagingKore RagingKore self-assigned this May 14, 2024
@RagingKore RagingKore requested a review from hayley-jean May 14, 2024 16:54
@RagingKore RagingKore merged commit eca0063 into master May 16, 2024
2 checks passed
@RagingKore RagingKore deleted the plugins-reloaded branch May 16, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants