Skip to content

Commit

Permalink
refactor: add resource to MeterConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mwear committed Mar 9, 2020
1 parent 20d0663 commit ab8f7a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/opentelemetry-metrics/src/Meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export class Meter implements types.Meter {
/**
* Constructs a new Meter instance.
*/
constructor(config: MeterConfig = DEFAULT_CONFIG, resource: Resource) {
constructor(config: MeterConfig = DEFAULT_CONFIG) {
this._logger = config.logger || new ConsoleLogger(config.logLevel);
this._batcher = new UngroupedBatcher();
this.resource = resource;
this.resource = config.resource || Resource.createTelemetrySDKResource();
// start the push controller
const exporter = config.exporter || new NoopExporter();
const interval = config.interval;
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-metrics/src/MeterProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class MeterProvider implements types.MeterProvider {
getMeter(name: string, version = '*', config?: MeterConfig): Meter {
const key = `${name}@${version}`;
if (!this._meters.has(key)) {
this._meters.set(key, new Meter(config || this._config, this.resource));
this._meters.set(key, new Meter(config || this._config));
}

return this._meters.get(key)!;
Expand Down
4 changes: 4 additions & 0 deletions packages/opentelemetry-metrics/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { LogLevel } from '@opentelemetry/core';
import { Logger, ValueType } from '@opentelemetry/api';
import { MetricExporter } from './export/types';
import { Resource } from '@opentelemetry/resources';

/** Options needed for SDK metric creation. */
export interface MetricOptions {
Expand Down Expand Up @@ -64,6 +65,9 @@ export interface MeterConfig {

/** Metric collect interval */
interval?: number;

/** Resource associated with metric telemetry */
resource?: Resource;
}

/** Default Meter configuration. */
Expand Down

0 comments on commit ab8f7a4

Please sign in to comment.