Skip to content
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
2 changes: 1 addition & 1 deletion samples/instrumentation-quickstart/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
15 changes: 14 additions & 1 deletion samples/instrumentation-quickstart/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import {
import {
ConsoleMetricExporter,
PeriodicExportingMetricReader,
ExponentialHistogramAggregation,
DefaultAggregation,
InstrumentType,
} from '@opentelemetry/sdk-metrics';
import {OTLPMetricExporter} from '@opentelemetry/exporter-metrics-otlp-proto';

Expand All @@ -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({
Expand Down
Loading