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

Refactor Extensions code to check protocol efficiently #203

Closed
NassimBtk opened this issue May 27, 2024 · 0 comments · Fixed by #225
Closed

Refactor Extensions code to check protocol efficiently #203

NassimBtk opened this issue May 27, 2024 · 0 comments · Fixed by #225
Assignees
Labels
enhancement New feature or request

Comments

@NassimBtk
Copy link
Member

NassimBtk commented May 27, 2024

The OpenTelemetry-specific code is not passed to the protocol extension. Currently, the OpenTelemetry code observes the metric's value in the agent before sending it to the OTLP receiver.

The code you suggested is already implemented in the agent through the ProtocolHealthCheckStrategy, which is triggered at each collect cycle, except for the metricshub.host.protocol.up collect.

// Call the extensions to check the protocol health
final List<IProtocolExtension> protocolExtensions = extensionManager.findProtocolCheckExtensions(telemetryManager);
protocolExtensions.forEach(protocolExtension -> protocolExtension.checkProtocol(telemetryManager));

Indeed, the ProtocolHealthCheckStrategy can be updated to collect the protocol point, this will avoid code duplication in each extension. Several information are required from the TelemetryManager: hostname, configuration, so this can be passed as method arguments.

// Call the extensions to check the protocol health
final List<IProtocolExtension> protocolExtensions = extensionManager.findProtocolCheckExtensions(telemetryManager);
protocolExtensions.forEach(protocolExtension -> { 

    new MetricFactory()
        .collectNumberMetric(
            telemetryManager.getEndpointHostMonitor(),
            "metricshub.host.up{protocol=\"" + protocolExtension.getIdentifier() + "\"}",
            protocolExtension.checkProtocol(telemetryManager) ? UP : DOWN,
            telemetryManager.getStrategyTime()
        );
});

This can be done in a separate issue as it is a refactoring task. Moreover, each extension needs to be updated ;). By the way good catch, thanks @bertysentry.

Originally posted by @NassimBtk in #201 (comment)

@NassimBtk NassimBtk added the enhancement New feature or request label May 29, 2024
SafaeAJ added a commit that referenced this issue Jun 3, 2024
SafaeAJ added a commit that referenced this issue Jun 3, 2024
Fixed IpmiExtension

fixed ProtocolHealthCheckStrategy
SafaeAJ added a commit that referenced this issue Jun 3, 2024
SafaeAJ added a commit that referenced this issue Jun 4, 2024
SafaeAJ added a commit that referenced this issue Jun 4, 2024
Fixed comments in HttpExtension and WmiExtension
SafaeAJ added a commit that referenced this issue Jun 4, 2024
SafaeAJ added a commit that referenced this issue Jun 4, 2024
SafaeAJ added a commit that referenced this issue Jun 4, 2024
Modify OsCommandExtensionTest and WbemExtensionTest
SafaeAJ added a commit that referenced this issue Jun 4, 2024
SafaeAJ added a commit that referenced this issue Jun 4, 2024
SafaeAJ added a commit that referenced this issue Jun 4, 2024
SafaeAJ added a commit that referenced this issue Jun 4, 2024
Fixed style in ProtocolHealthCheckStrategy
NassimBtk added a commit that referenced this issue Jun 5, 2024
NassimBtk added a commit that referenced this issue Jun 5, 2024
…r-extensions-code-to-check-protocol-efficiently

Issue #203 : Refactor extensions code to check protocol efficiently
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants