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

Update to Proto v0.5.0 #1588

Merged
merged 15 commits into from
Oct 19, 2020
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
4 changes: 2 additions & 2 deletions examples/collector-exporter-node/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: "3"
services:
# Collector
collector:
image: otel/opentelemetry-collector:latest
# image: otel/opentelemetry-collector:0.6.0
image: otel/opentelemetry-collector:0.12.0
# image: otel/opentelemetry-collector:latest
command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"]
volumes:
- ./collector-config.yaml:/conf/collector-config.yaml
Expand Down
5 changes: 5 additions & 0 deletions examples/collector-exporter-node/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
description: 'Example of a UpDownCounter',
});

const recorder = meter.createValueRecorder('test_value_recorder', {
description: 'Example of a ValueRecorder',
});

const labels = { pid: process.pid, environment: 'staging' };

setInterval(() => {
requestCounter.bind(labels).add(1);
upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
recorder.bind(labels).record(Math.random());
}, 1000);
5 changes: 5 additions & 0 deletions packages/opentelemetry-api/src/metrics/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export interface MetricOptions {
* User provided logger.
*/
logger?: Logger;

/**
* Boundaries optional for histogram
*/
boundaries?: number[];
}

export interface BatchMetricOptions extends MetricOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ import { CollectorMetricExporter } from '../src';
import {
mockCounter,
mockObserver,
mockHistogram,
ensureExportedCounterIsCorrect,
ensureExportedObserverIsCorrect,
ensureMetadataIsCorrect,
ensureResourceIsCorrect,
ensureExportedHistogramIsCorrect,
ensureExportedValueRecorderIsCorrect,
mockValueRecorder,
} from './helper';
Expand Down Expand Up @@ -117,7 +115,7 @@ const testCollectorMetricExporter = (params: TestParams) =>
server.forceShutdown();
});

beforeEach(done => {
beforeEach(async () => {
const credentials = params.useTLS
? grpc.credentials.createSsl(
fs.readFileSync('./test/certs/ca.crt'),
Expand All @@ -136,10 +134,9 @@ const testCollectorMetricExporter = (params: TestParams) =>
value: 1592602232694000000,
});
metrics = [];
metrics.push(mockCounter());
metrics.push(mockObserver());
metrics.push(mockHistogram());
metrics.push(mockValueRecorder());
metrics.push(await mockCounter());
metrics.push(await mockObserver());
metrics.push(await mockValueRecorder());

metrics[0].aggregator.update(1);

Expand All @@ -148,8 +145,6 @@ const testCollectorMetricExporter = (params: TestParams) =>

metrics[2].aggregator.update(7);
metrics[2].aggregator.update(14);
metrics[3].aggregator.update(5);
done();
});

afterEach(() => {
Expand Down Expand Up @@ -189,15 +184,21 @@ const testCollectorMetricExporter = (params: TestParams) =>
const counter =
exportedData[0].instrumentationLibraryMetrics[0].metrics[0];
const observer =
exportedData[1].instrumentationLibraryMetrics[0].metrics[0];
const histogram =
exportedData[2].instrumentationLibraryMetrics[0].metrics[0];
exportedData[0].instrumentationLibraryMetrics[0].metrics[1];
const recorder =
exportedData[3].instrumentationLibraryMetrics[0].metrics[0];
ensureExportedCounterIsCorrect(counter);
ensureExportedObserverIsCorrect(observer);
ensureExportedHistogramIsCorrect(histogram);
ensureExportedValueRecorderIsCorrect(recorder);
exportedData[0].instrumentationLibraryMetrics[0].metrics[2];
ensureExportedCounterIsCorrect(
counter,
counter.intSum?.dataPoints[0].timeUnixNano
);
ensureExportedObserverIsCorrect(
observer,
observer.doubleGauge?.dataPoints[0].timeUnixNano
);
ensureExportedValueRecorderIsCorrect(
recorder,
recorder.intHistogram?.dataPoints[0].timeUnixNano
);
assert.ok(
typeof resource !== 'undefined',
"resource doesn't exist"
Expand Down
Loading