-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[exporter/bmchelix] Second PR of New component: BMC Helix Exporter #37350
Conversation
* 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") |
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.
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!)
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 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...
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 is going to be a noisey log and potentially provide little value, can you remove this?
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.
Yes, I will remove it.
} | ||
|
||
// Check if the entityTypeId is set | ||
if labels["entityTypeId"] == "" { |
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.
Too bad we can't figure out there is no entityTypeId
attribute before processing all data points 🤷♂️
Conflict to be resolved... |
exporter/bmchelixexporter/config.go
Outdated
Timeout time.Duration `mapstructure:"timeout"` | ||
RetryConfig configretry.BackOffConfig `mapstructure:"retry_on_failure"` | ||
confighttp.ClientConfig `mapstructure:",squash"` | ||
APIKey string `mapstructure:"api_key"` |
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.
You want to use configopaque.String
avoid leaking the key within logs or other marshalling.
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.
Yes, good idea, thank you!
be.logger.Info("Starting BMC Helix Exporter") | ||
|
||
// Get the hostname reported by the kernel | ||
osHostname, err := os.Hostname() |
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.
Depending on this starts up, it could fetch the container hostname which is just a hash, is that going to be an issue?
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.
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?
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.
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.
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.
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
…exporter-implementation
feature/issue-36773-new-component-bmc-helix-exporter-implementation
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.
Sorry to be a pain, but if we can shuffle some of the definitions of types into internal packages to reduce the API exposure would be awesome :D
) | ||
|
||
// BmcHelixExporter is responsible for exporting metrics to BMC Helix | ||
type BmcHelixExporter struct { |
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 suggest not making this package in the root package, and by go naming convention it should be BMCHelixExporter
(all acronyms get capitalised since they are new words).
Conversely, the name is also a double up on the package, perhaps having it just simply as producer
would be enough to avoid any naming collisions with packages, and adhering to go naming conventions.
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.
Thanks for the feedback! That makes sense. I'll rename BmcHelixExporter
to metricsExporter
since the package is already named bmchelixexporter
, and metricsExporter
should better reflect its purpose within the package.
// MetricsClient is responsible for sending the metrics payload to BMC Helix Operations Management | ||
type MetricsClient struct { |
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 being mindful of what is being exported as part of the package, I think it just makes sense to rename as metricsClient
and it should be fine here.
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.
Thanks! I will rename the struct name to metricsClient
.
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.
Can I suggest that gets moved into internal/bmchelix
(or anything that makes sense) to avoid exposing unneeded types in the root package?
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.
Yes, that makes sense. Thank you!
feature/issue-36773-new-component-bmc-helix-exporter-implementation
* Moved MetricsProducer and MetricsClient to internal/ package to control API exposure * metricsExporter is now unexported
feature/issue-36773-new-component-bmc-helix-exporter-implementation
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! Nice work Nassim!
* main: (392 commits) fix(deps): update module golang.org/x/text to v0.22.0 (open-telemetry#37686) [exporter/bmchelix] Second PR of New component: BMC Helix Exporter (open-telemetry#37350) chore(deps): update otel/opentelemetry-collector-contrib docker tag to v0.119.0 (open-telemetry#37688) [chore] fix codeowners allowlist (open-telemetry#37684) chore(deps): update otel/opentelemetry-collector docker tag to v0.119.0 (open-telemetry#37687) Update jpkroehling's affiliation (open-telemetry#37683) fix(deps): update module github.com/clickhouse/clickhouse-go/v2 to v2.30.3 (open-telemetry#37655) fix(deps): update all opentelemetry collector contrib packages to v0.119.0 (open-telemetry#37666) fix(deps): update module github.com/elastic/go-docappender/v2 to v2.4.0 (open-telemetry#37667) fix(deps): update all golang.org/x packages (open-telemetry#37680) [exporter/prometheusremotewrite] Fix WAL deadlock (open-telemetry#37630) fix(deps): update opentelemetry-go monorepo (open-telemetry#37673) fix(deps): update module github.com/shirou/gopsutil/v4 to v4.25.1 (open-telemetry#37671) fix(deps): update module github.com/spf13/pflag to v1.0.6 (open-telemetry#37658) fix(deps): update all github.com/aws packages (open-telemetry#37661) [chore] Prepare release 0.119.0 (open-telemetry#37660) make update-otel OTEL_VERSION=v0.119.0 OTEL_STABLE_VERSION=v1.25.0 (open-telemetry#37656) add documentation and warning log for deprecating AccessTokenPassthrough (open-telemetry#37575) chore: add myself, echlebek, as a codeowner (open-telemetry#37650) [processor/transform] Add support for flat configuration style (open-telemetry#37444) ...
* main: (392 commits) fix(deps): update module golang.org/x/text to v0.22.0 (open-telemetry#37686) [exporter/bmchelix] Second PR of New component: BMC Helix Exporter (open-telemetry#37350) chore(deps): update otel/opentelemetry-collector-contrib docker tag to v0.119.0 (open-telemetry#37688) [chore] fix codeowners allowlist (open-telemetry#37684) chore(deps): update otel/opentelemetry-collector docker tag to v0.119.0 (open-telemetry#37687) Update jpkroehling's affiliation (open-telemetry#37683) fix(deps): update module github.com/clickhouse/clickhouse-go/v2 to v2.30.3 (open-telemetry#37655) fix(deps): update all opentelemetry collector contrib packages to v0.119.0 (open-telemetry#37666) fix(deps): update module github.com/elastic/go-docappender/v2 to v2.4.0 (open-telemetry#37667) fix(deps): update all golang.org/x packages (open-telemetry#37680) [exporter/prometheusremotewrite] Fix WAL deadlock (open-telemetry#37630) fix(deps): update opentelemetry-go monorepo (open-telemetry#37673) fix(deps): update module github.com/shirou/gopsutil/v4 to v4.25.1 (open-telemetry#37671) fix(deps): update module github.com/spf13/pflag to v1.0.6 (open-telemetry#37658) fix(deps): update all github.com/aws packages (open-telemetry#37661) [chore] Prepare release 0.119.0 (open-telemetry#37660) make update-otel OTEL_VERSION=v0.119.0 OTEL_STABLE_VERSION=v1.25.0 (open-telemetry#37656) add documentation and warning log for deprecating AccessTokenPassthrough (open-telemetry#37575) chore: add myself, echlebek, as a codeowner (open-telemetry#37650) [processor/transform] Add support for flat configuration style (open-telemetry#37444) ...
exporter.go
to handle metric transformation and payload dispatch to BMC Helix.metrics_client.go
with HTTP client configuration.metrics_producer.go
to produce BMC Helix-compatible payloads.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:
exporter/bmchelixexporter/exporter.go
: IntroducedBmcHelixExporter
class with methods to start the exporter and push metrics to BMC Helix.metrics_producer.go
to build the BMC Helix Operations Management expected metric payloads.exporter/bmchelixexporter/metrics_client.go
: AddedMetricsClient
class responsible for sending metrics payloads to BMC Helix.Configuration Adjustments:
exporter/bmchelixexporter/config.go
: ReplacedEndpoint
andTimeout
fields withconfighttp.ClientConfig
to handle HTTP client configuration.exporter/bmchelixexporter/factory.go
: UpdatedcreateDefaultConfig
to useconfighttp.NewDefaultClientConfig
and adjusted thecreateMetricsExporter
function to initialize the exporter properly.Unit Tests:
exporter/bmchelixexporter/config_test.go
: Modified tests to accommodate changes in configuration structure and added helper functioncreateDefaultClientConfig
.exporter/bmchelixexporter/exporter_test.go
: Added unit tests fornewBmcHelixExporter
function to ensure proper initialization.exporter/bmchelixexporter/metrics_producer.go
: Added unit tests.exporter/bmchelixexporter/metrics_client.go
: Added unit tests.Changelog Entry:
.chloggen/bmchelixexporter-metrics-implementation.yaml
: Added a new changelog entry for the BMC Helix Exporter metrics implementation.Link to tracking issue
Fixes #36773