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

[exporter/bmchelix] Second PR of New component: BMC Helix Exporter #37350

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

NassimBtk
Copy link
Contributor

@NassimBtk NassimBtk commented Jan 20, 2025

  • Implemented core functionality in exporter.go to handle metric transformation and payload dispatch to BMC Helix.
  • Added metrics_client.go with HTTP client configuration.
  • Added metrics_producer.go to produce BMC Helix-compatible payloads.
  • Added unit tests.

Description

This pull request introduces the BMC Helix Exporter, which is responsible for exporting metrics to BMC Helix Operations Management. The most important changes include the implementation of the exporter, configuration adjustments, and the addition of unit tests.

Implementation of BMC Helix Exporter:
Configuration Adjustments:
Unit Tests:
  • exporter/bmchelixexporter/config_test.go: Modified tests to accommodate changes in configuration structure and added helper function createDefaultClientConfig.
  • exporter/bmchelixexporter/exporter_test.go: Added unit tests for newBmcHelixExporter function to ensure proper initialization.
  • exporter/bmchelixexporter/metrics_producer.go: Added unit tests.
  • exporter/bmchelixexporter/metrics_client.go: Added unit tests.
Changelog Entry:

Link to tracking issue

Fixes #36773

* Implemented core functionality in `exporter.go` to handle metric
transformation and payload dispatch to BMC Helix.
* Added `metrics_client.go` with HTTP client configuration.
* Added `metrics_producer.go` to produce BMC Helix-compatible payloads.
* Added unit tests.
return err
}

be.logger.Info("Sending BMC Helix payload")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it common practice to log all this? I would have expected such messages ("Building", "Sending", etc.) to be in debug level, rather than Info. (but I'm not familiar with the logging in other components!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can remove these two logs. I don't see what value they add, and after reviewing a few exporters, I didn't notice a similar practice to what I implemented here...

Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to be a noisey log and potentially provide little value, can you remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will remove it.

}

// Check if the entityTypeId is set
if labels["entityTypeId"] == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Too bad we can't figure out there is no entityTypeId attribute before processing all data points 🤷‍♂️

@NassimBtk
Copy link
Contributor Author

Conflict to be resolved...

Timeout time.Duration `mapstructure:"timeout"`
RetryConfig configretry.BackOffConfig `mapstructure:"retry_on_failure"`
confighttp.ClientConfig `mapstructure:",squash"`
APIKey string `mapstructure:"api_key"`
Copy link
Contributor

Choose a reason for hiding this comment

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

You want to use configopaque.String avoid leaking the key within logs or other marshalling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good idea, thank you!

be.logger.Info("Starting BMC Helix Exporter")

// Get the hostname reported by the kernel
osHostname, err := os.Hostname()
Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on this starts up, it could fetch the container hostname which is just a hash, is that going to be an issue?

Copy link
Contributor Author

@NassimBtk NassimBtk Jan 24, 2025

Choose a reason for hiding this comment

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

Very good question! This shouldn't cause issues for the user, as they should be able to configure the hostname of their container or pod. If that's not feasible, indeed, the hash will change with each new deployment. In such cases, I would recommend using OTTL to override the host.name on either the resource or the metric itself, though this approach could become cumbersome in scenarios where the collector processes a large volume of metrics. Alternatively, we could introduce an entity_hostname configuration option to override the OS hostname. Currently, the code defaults to the OS hostname only if it cannot find a host.name attribute on the datapoint or the associated resource. What do you think, @bertysentry?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good catch. I recommend we don't use os.Hostname() as the default entity hostname in BMC Helix. Instead, if the user wants to use the local host details, we will recommend to simply use the resourcedetectionprocessor in their otelcol config.

And if metrics don't have a host.name (at the end of the processors chain), then such metrics won't be exported to BMC Helix, and it's okay. Maybe we should log the number of metrics that are dropped so the end user knows what is going on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, os.Hostname() will not be used in that case.

feature/issue-36773-new-component-bmc-helix-exporter-implementation
* Using configopaque.String for APIKey
* os.Hostname is not used as last resort hostname
* Removed noisy log info.
feature/issue-36773-new-component-bmc-helix-exporter-implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New component: BMC Helix Exporter
4 participants