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

Feature Request: Support OpenTelemetry Resources and Relationships in Monitor Model #339

Open
NassimBtk opened this issue Jul 24, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request java

Comments

@NassimBtk
Copy link
Member

NassimBtk commented Jul 24, 2024

Use case

Enhance the Connector model to support mapping monitors as OpenTelemetry Resources and allow attaching other monitors to these resources. This will involve:

  1. Adding two new fields: isResource and attachToResource in the mapping section of the YAML connector.
  2. Updating the Monitor class accordingly.
  3. Updating the discovery and the simple strategies to interpret isResource and attachToResource.
  4. Updating the agent to create new OpenTelemetry Resources defined by the connector and attach metrics to these new OpenTelemetry Resources.

Requirements

YAML Model Updates (Connector):

  • In the Mapping object add isResource field to indicate a monitor is an OpenTelemetry Resource.
  • In the Mapping object add attachToResource field to specify relationship and attach monitor to the defined OpenTelemetry Resource.

Example YAML Configuration

monitors:
  disk_controller:
    discovery:
      sources:
       # ...
      mapping:
        source: ${source::source(1)}
        isResource: true
        attributes:
          # ...

  battery_child:
    discovery:
      sources:
        # ...
      mapping:
        source: ${source::source(1)}
        attachToResource:
          type: disk_controller
          attributes:
            id: $10
        attributes:
           # ...

Monitor Model Changes

  • Add fields to the Monitor class:
    • isResource: boolean
    • Rename resource to attachedToResource to clearly express the relationship mechanism.

Steps to Implement

  1. Update YAML Schema:

    • Modify the Connector model to handle isResource and attachToResource fields.
  2. Update Monitor Model:

    • Add the new fields to the Monitor class.
  3. Update the Engine's Discovery and Simple Strategies:

    • Implement the logic in the AbstractAllAtOnceStrategy to interpret attachToResource from the connector mapping and create the attachedToResource field (Type: Resource) in the Monitor class accordingly. This involves renaming the resource field to attachedToResource, particularly in the MonitorFactory and within the Monitor class.
    • Implement the logic in the AbstractAllAtOnceStrategy to interpret isResource from the connector mapping and appropriately flag the isResource field in the Monitor class. This requires updating the MonitorFactory to ensure smooth monitor creation and updates.
  4. Modify the MetricsHub Agent:

    • The following agent updates should be manage by org.sentrysoftware.metricshub.agent.service.task.MonitoringTask.
    • Before initializing the OpenTelemetry Metric Observers for each monitor's metrics:
      • Case 1: If the current monitor defines attachedToResource:
        • From the TelemetryManager, retrieve the monitor matching the attributes and the type values defined in attachedToResource field. Let's call it resourceMonitor.
        • If resourceMonitor is not found go to Case 2.
        • Otherwise:
          • Create a new OpenTelemetry Resource using the resourceMonitor attributes.
          • Generate a new AutoConfiguredOpenTelemetrySdk using the new OpenTelemetry Resource.
          • Initialize the observers using the new OpenTelemetry Resource.
      • Case 2: If no attachedToResource in the monitor:
        • Initialize the Metric Observer as it is currently done, I.e. using the main OpenTelemetry Resource, currently created from host endpoint monitor attributes.
@NassimBtk NassimBtk added enhancement New feature or request java labels Jul 24, 2024
@NassimBtk NassimBtk self-assigned this Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request java
Projects
None yet
Development

No branches or pull requests

1 participant