diff --git a/samples/instrumentation-quickstart/docker-compose.yaml b/samples/instrumentation-quickstart/docker-compose.yaml index 26c2f5e5e..8a037321b 100644 --- a/samples/instrumentation-quickstart/docker-compose.yaml +++ b/samples/instrumentation-quickstart/docker-compose.yaml @@ -29,7 +29,7 @@ services: depends_on: - otelcol otelcol: - image: otel/opentelemetry-collector-contrib:0.110.0 + image: otel/opentelemetry-collector-contrib:0.115.1 volumes: - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro - logs:/var/log:ro diff --git a/samples/instrumentation-quickstart/otel-collector-config.yaml b/samples/instrumentation-quickstart/otel-collector-config.yaml index 66fdaa902..83cc66cfc 100644 --- a/samples/instrumentation-quickstart/otel-collector-config.yaml +++ b/samples/instrumentation-quickstart/otel-collector-config.yaml @@ -109,6 +109,14 @@ processors: detectors: ["env", "gcp"] service: + telemetry: + metrics: + readers: + - pull: + exporter: + prometheus: + host: '0.0.0.0' + port: 8888 pipelines: traces: receivers: ["otlp"] diff --git a/samples/instrumentation-quickstart/src/instrumentation.ts b/samples/instrumentation-quickstart/src/instrumentation.ts index eaab1a2ec..99d168293 100644 --- a/samples/instrumentation-quickstart/src/instrumentation.ts +++ b/samples/instrumentation-quickstart/src/instrumentation.ts @@ -29,6 +29,9 @@ import { import { ConsoleMetricExporter, PeriodicExportingMetricReader, + ExponentialHistogramAggregation, + DefaultAggregation, + InstrumentType, } from '@opentelemetry/sdk-metrics'; import {OTLPMetricExporter} from '@opentelemetry/exporter-metrics-otlp-proto'; @@ -48,7 +51,17 @@ function getMetricReader() { diag.info('using otel metrics exporter'); return new PeriodicExportingMetricReader({ ...readerOptions, - exporter: new OTLPMetricExporter(), + exporter: new OTLPMetricExporter({ + // Use exponential histograms for histogram instruments. + // This can be done using an environment variable after + // https://github.com/open-telemetry/opentelemetry-js/issues/3920 is implemented. + aggregationPreference: (instrumentType: InstrumentType) => { + if (instrumentType === InstrumentType.HISTOGRAM) { + return new ExponentialHistogramAggregation() + } + return new DefaultAggregation() + } + }), }); case 'console': return new PeriodicExportingMetricReader({