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

Decide how to inject MetricProducerForStats. #276

@mayurkale22

Description

@mayurkale22

https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/stats/stats.ts#L40-L46

MetricProducerForStats is MetricProducer for stats that can be registered for exporting using MetricProducerManager. If we don't add or register this stats producer into MetricProducerManager, stats data will not be exported to backend/exporter.

// It should be something like below
const metricProducer: MetricProducer = new MetricProducerForStats(statsObject);
Metrics.getMetricProducerManager().add(metricProducer);

At this moment, two approaches are there in my mind.

  1. Inside Stats ctor, add above code (statsObject -> this). Everything is working fine, but with this every stats object creation will add new entry to MetricProducerManager.
  2. Make singleton Stats class (similar to Tracing) and inject singleton instance in below code. This would be a breaking change, but this is what we have done in Java.

Background

Stats vs Metrics

  • The Stats Library allows users to record raw measurements or data without any aggregations. It also allows users to define views (that will produce metrics, when they are applied across a set of measurements) to configure how data are aggregated and broken down (using tag keys). In short, Stats is an API for recording raw measurements.

  • The Metrics (metrics.proto) is an API that works with aggregated data. We have provided Gauge API to report already aggregated data.

MetricProducerManager
At a high level, we have added MetricProducerManager to Keep a set of MetricProducer that is used by exporters to determine the metrics that need to be exported. In Node, we have two source of MetricProducer -> Stats and MetricRegistry (Gauges).

image

Note: Codahale and Micrometer is applicable for OpenCensus Java library only.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions