Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use exponential histograms for the quickstart sample #782

Merged
merged 2 commits into from
Jan 28, 2025
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