diff --git a/examples/otlp-exporter-node/metrics.js b/examples/otlp-exporter-node/metrics.js index ea019ee05c8..eb477874e89 100644 --- a/examples/otlp-exporter-node/metrics.js +++ b/examples/otlp-exporter-node/metrics.js @@ -6,6 +6,7 @@ const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-htt // const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-proto'); // const { ConsoleMetricExporter } = require('@opentelemetry/sdk-metrics'); const { + ExplicitBucketHistogramAggregation, ExponentialHistogramAggregation, MeterProvider, PeriodicExportingMetricReader, @@ -25,20 +26,25 @@ const metricExporter = new OTLPMetricExporter({ // }, }); +// Define view for the bucket sizes for the histogram metric +const histogramView = new View({ + aggregation: new ExplicitBucketHistogramAggregation([0, 10, 100, 1000]), + instrumentName: 'test_histogram', +}); // Define view for the exponential histogram metric const expHistogramView = new View({ aggregation: new ExponentialHistogramAggregation(), instrumentName: 'test_exponential_histogram', }); // Note, the instrumentName is the same as the name that has been passed for -// the Meter#createHistogram function for exponentialHistogram. +// the Meter#createHistogram functions. // Create an instance of the metric provider const meterProvider = new MeterProvider({ resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: 'basic-metric-service', }), - views: [expHistogramView], + views: [histogramView, expHistogramView], }); meterProvider.addMetricReader( @@ -61,7 +67,6 @@ const upDownCounter = meter.createUpDownCounter('test_up_down_counter', { const histogram = meter.createHistogram('test_histogram', { description: 'Example of a Histogram', - boundaries: [0, 10, 100, 1000], }); const exponentialHistogram = meter.createHistogram('test_exp_histogram', {