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

Allow user to pass in metrics namespace #5758

Closed
wants to merge 3 commits into from

Conversation

splunkericl
Copy link
Contributor

@splunkericl splunkericl commented Jul 28, 2022

Description:
Adding a configuration that allows user to configure their metrics namespace

Link to tracking Issue:
#5692

Testing:
Added a unit test to verify namespace can be customized

Documentation:
Added godoc on the new namespace field

@splunkericl splunkericl requested review from a team and bogdandrutu July 28, 2022 22:02
@codecov
Copy link

codecov bot commented Jul 28, 2022

Codecov Report

Merging #5758 (15f2fe3) into main (b463d2a) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5758      +/-   ##
==========================================
- Coverage   91.78%   91.62%   -0.16%     
==========================================
  Files         192      192              
  Lines       11394    11429      +35     
==========================================
+ Hits        10458    10472      +14     
- Misses        742      763      +21     
  Partials      194      194              
Impacted Files Coverage Δ
service/telemetry.go 89.51% <100.00%> (+0.30%) ⬆️
exporter/exporterhelper/queued_retry_inmemory.go 79.34% <0.00%> (-12.55%) ⬇️
pdata/internal/metrics.go 87.76% <0.00%> (-4.74%) ⬇️
component/exporter.go 100.00% <0.00%> (ø)
component/receiver.go 100.00% <0.00%> (ø)
component/processor.go 100.00% <0.00%> (ø)
pdata/internal/generated_pmetric.go 97.38% <0.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b463d2a...15f2fe3. Read the comment docs.

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

@open-telemetry/collector-approvers the issue was not triaged but the feature seems reasonable to me. Any thoughts on whether we want this accepted?

service/telemetry.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -14,6 +14,7 @@

- `ocb` now exits with an error if it fails to load the build configuration. (#5731)
- Deprecate `HTTPClientSettings.ToClientWithHost` (#5737)
- Add a new field `namespace` in `service.telemetry.metrics.namespace` to allow user to customize metric namespace (#5692)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Add a new field `namespace` in `service.telemetry.metrics.namespace` to allow user to customize metric namespace (#5692)
- Add a new field `service.telemetry.metrics.namespace` to allow users to customize the collector's metric namespace (#5692)

@@ -102,4 +102,7 @@ type MetricsConfig struct {

// Address is the [address]:port that metrics exposition should be bound to.
Address string `mapstructure:"address"`

// NameSpace indicates the telemetry namespace the service will set.
NameSpace string `mapstructure:"namespace"`
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommends going with Namespace instead, since it is a single word.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good. will update

Comment on lines 177 to 182
namespace := defaultNameSpace
if cfg.Metrics.NameSpace != "" {
namespace = cfg.Metrics.NameSpace
}
opts := prometheus.Options{
Namespace: "otelcol",
Namespace: namespace,
Copy link
Member

Choose a reason for hiding this comment

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

This will only change the namespace when using OpenCensus metrics. For users that enable the useOtelForInternalMetricsfeatureGateID feature gate and use OTEL metrics, is the namespace not relevant? Or does initOpenTelemetry also need to be made aware of the namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there isn't a namespace set in the opentelemetry metrics(through useOtelForInternalMetricsfeatureGateID). I think there are still a lot of designs around that with the beta milestone so I will keep it as it is.

@dmitryax
Copy link
Member

dmitryax commented Aug 1, 2022

Issue description is bit confusing. Can you please reply to #5692 (comment)

@tigrannajaryan
Copy link
Member

@dmitryax @TylerHelmuth any other comments or good to merge?

Copy link
Member

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @splunkericl!

@@ -102,4 +102,7 @@ type MetricsConfig struct {

// Address is the [address]:port that metrics exposition should be bound to.
Address string `mapstructure:"address"`

// Namespace indicates the telemetry namespace the service will set. If nil, a default value is assigned.
Copy link
Member

Choose a reason for hiding this comment

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

The description is not very clear. As an otel collector user, I don't understand it without looking into the code. Please mention that it changes namespace of exposed OTel collector's metrics and that default namespace is otelcol. It maybe good to also show an example of how the metrics will look like if the namespace is changed for a generic metric like otelcol_process_uptime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is fair. Will add it to be more explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in the new version

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

This is only supported in opencensus (based on my knowledge), are we sure that we want to add this as another blocker to adopt opentelemetry?

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Aug 17, 2022
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants