Skip to content

Commit

Permalink
Update to Proto v0.5.0 (#1588)
Browse files Browse the repository at this point in the history
* chore: updating submodule for opentelemetry-proto

* chore: necessary changes after upgrade to proto ver. 0.5.0, aligning metrics to latest spec changes

* chore: removing examples from lerna bootstrap

* chore: cleaning ups unused interfaces

* chore: fixing unit test

* chore: updating aggregation temporality rules

* chore: updating temporality for value recorder

* chore: removing unneeded lib

* chore: span id and trace id as hex

* chore: adding value recorder to example
  • Loading branch information
obecny authored Oct 19, 2020
1 parent 1c27690 commit 00a8ce7
Show file tree
Hide file tree
Showing 27 changed files with 868 additions and 1,293 deletions.
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

0 comments on commit 00a8ce7

Please sign in to comment.