Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Add support for metrics in prometheus exporter#1105

Merged
rghetia merged 5 commits intocensus-instrumentation:devfrom
rghetia:prometheus
Apr 15, 2019
Merged

Add support for metrics in prometheus exporter#1105
rghetia merged 5 commits intocensus-instrumentation:devfrom
rghetia:prometheus

Conversation

@rghetia
Copy link
Copy Markdown
Contributor

@rghetia rghetia commented Apr 12, 2019

fixes #1040

@rghetia rghetia requested review from a team and rakyll as code owners April 12, 2019 04:12
@rghetia rghetia requested a review from songy23 April 12, 2019 04:12
t.Fatalf("failed to create prometheus exporter: %v", err)
}
view.RegisterExporter(exporter)
//view.RegisterExporter(exporter)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: if these are not needed any more then just remove them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Copy link
Copy Markdown
Contributor

@songy23 songy23 left a comment

Choose a reason for hiding this comment

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

LGTM except some nits.

// ExportMetrics exports to the Prometheus.
// Each OpenCensus Metric will be converted to
// corresponding Prometheus Metric:
// SumData will be converted to Untyped Metric,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These comments no longer apply here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed. I have referred to Metric Types (like TypeCumulativeInt64) in modified comment instead of stats aggregation type (like sum).

}
return prometheus.NewConstHistogram(desc, uint64(v.Count), v.Sum, points, labelValues...)
default:
return nil, pointTypeError(point)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: leave a TODO to support Summary metrics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

view.RegisterExporter(exporter)
reportPeriod := time.Millisecond
view.SetReportingPeriod(reportPeriod)
//view.RegisterExporter(exporter)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are a few more commented lines that can be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed all of them.

c.mu.Lock()
defer c.mu.Unlock()
func pointTypeError(point metricdata.Point) error {
return fmt.Errorf("point type %T is not yet supported", point)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: the error message could be a bit confusing, consider "point type %T doesn't match with metric type".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

@rghetia rghetia merged commit 1ef85b4 into census-instrumentation:dev Apr 15, 2019
@rghetia rghetia deleted the prometheus branch April 16, 2019 16:57
rghetia added a commit to rghetia/opencensus-go that referenced this pull request Apr 25, 2019
…n#1105)

* Add prometheus support.

* remove view related code and refactor metric specific code.

* fix review comments.

* remove dead code and fix comments.

* fix error message.
rghetia added a commit that referenced this pull request Apr 25, 2019
* Add prometheus support.

* remove view related code and refactor metric specific code.

* fix review comments.

* remove dead code and fix comments.

* fix error message.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants