Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Remove mandatory opencensus_task label from node and respect metric prefix #184

Merged
merged 4 commits into from
Aug 29, 2019

Conversation

songy23
Copy link
Contributor

@songy23 songy23 commented Aug 29, 2019

No description provided.

Copy link
Contributor

@rghetia rghetia left a comment

Choose a reason for hiding this comment

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

With the second commit opencensus_task is not replaced. Should the title be changed then?

metrics_proto_test.go Outdated Show resolved Hide resolved
metrics_proto.go Outdated
func (se *statsExporter) metricTypeFromProto(name string) string {
prefix := se.o.MetricPrefix
if prefix != "" {
if !strings.HasSuffix(prefix, "/") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check can be done at initialization of the exporter because it is not changing (se.o.MetricPrefix) and avoid doing it all the time. Also if empty can be set to the default value, so this function would become:

se.metricPrefix is pre-calculated.
func (se *statsExporter) metricTypeFromProto(name string) string {
if !hasDomain(name) {
name = se.metricPrefix + name
}
return name
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check can be done at initialization of the exporter because it is not changing (se.o.MetricPrefix) and avoid doing it all the time.

Moved to initialization.

Also if empty can be set to the default value

This is true but there are cases when prefix is not empty but we still need to apply the custom.googleapis.com/opencensus/ domain. For example see https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/pull/184/files#diff-4b2a059ff46795cb078274ba257d81a7R768.

// hasDomain checks if the metric name already has a domain in it.
func hasDomain(name string) bool {
for _, domain := range domains {
if strings.Contains(name, domain) {
Copy link
Contributor

Choose a reason for hiding this comment

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

HasPrefix probably?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, because domains can have different prefixes e.g appengine.googleapis.com, container.googleapis.com, etc.

@songy23 songy23 changed the title Remove opencensus_task label and respect metric prefix Remove mandatory opencensus_task label from node and respect metric prefix Aug 29, 2019
@songy23 songy23 force-pushed the fix-label-and-prefix branch from fbf8a86 to 40caee4 Compare August 29, 2019 19:06
metrics_proto.go Outdated Show resolved Hide resolved
@songy23 songy23 force-pushed the fix-label-and-prefix branch from abbddc0 to cf3aad7 Compare August 29, 2019 20:04
@songy23 songy23 merged commit a8e01fd into census-ecosystem:master Aug 29, 2019
@songy23 songy23 deleted the fix-label-and-prefix branch August 29, 2019 20:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants