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

export Metrics classes and types #265

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/opencensus-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ export * from './trace/instrumentation/types';
export * from './trace/propagation/types';
export * from './exporters/types';
export * from './common/types';
export * from './metrics/gauges/types';
import {Metric, MetricDescriptor, TimeSeries, MetricDescriptorType, LabelKey, LabelValue, Point as TimeSeriesPoint, DistributionValue, BucketOptions, Bucket as DistributionBucket, SummaryValue, Explicit, Exemplar, Timestamp, Snapshot, ValueAtPercentile, MetricProducerManager, MetricProducer} from './metrics/export/types';

export {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be equivalent to use export {Metric, ...} from './metrics/export/types' rather than importing them and then exporting them? If so, that feels a little more compact to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

The only reason I did this way is to resolve ambiguity. The Bucket and Point are already exported under stats module. Both the members are there for metrics module also, I have added alias for Point -> TimeSeriesPoint and Bucket -> DistributionBucket before exporting it.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, makes sense. Would it work to use export .. from ... for the things that aren't renamed and then a separate import and export for the things that get renamed?

Really a nit though so feel free to leave as is.

Metric,
MetricDescriptor,
TimeSeries,
MetricDescriptorType,
LabelKey,
LabelValue,
TimeSeriesPoint,
DistributionValue,
BucketOptions,
DistributionBucket,
SummaryValue,
Explicit,
Exemplar,
Timestamp,
Snapshot,
ValueAtPercentile,
MetricProducerManager,
MetricProducer
};

// classes

Expand Down Expand Up @@ -58,3 +81,12 @@ export {logger};

// version
export * from './common/version';

// METRICS CLASSES

export * from './metrics/metrics';
export * from './metrics/metric-registry';

// GAUGES CLASSES
export * from './metrics/gauges/derived-gauge';
export * from './metrics/gauges/gauge';
7 changes: 6 additions & 1 deletion packages/opencensus-core/test/test-metric-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import {MetricsComponent} from '../src/metrics/metric-component';
import {MetricRegistry} from '../src/metrics/metric-registry';

describe('MetricsComponent()', () => {
const metricsComponent: MetricsComponent = new MetricsComponent();
let metricsComponent: MetricsComponent;

beforeEach(() => {
metricProducerManagerInstance.removeAll();
metricsComponent = new MetricsComponent();
});

it('should return a MetricRegistry instance', () => {
assert.ok(metricsComponent.getMetricRegistry() instanceof MetricRegistry);
Expand Down