From 5fd3737aa3c4f27fd68bb06bfb435d8badae63f0 Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Sat, 7 Oct 2023 11:40:54 +0200 Subject: [PATCH] chore: remove outdated and empty docs (#4181) --- doc/library-author.md | 3 - doc/metrics.md | 2 +- doc/processor-api.md | 147 ------------------------------------------ doc/tracing.md | 2 +- 4 files changed, 2 insertions(+), 152 deletions(-) delete mode 100644 doc/library-author.md delete mode 100644 doc/processor-api.md diff --git a/doc/library-author.md b/doc/library-author.md deleted file mode 100644 index 44e5f1e97e..0000000000 --- a/doc/library-author.md +++ /dev/null @@ -1,3 +0,0 @@ -# OpenTelemetry for Library Authors - -TODO diff --git a/doc/metrics.md b/doc/metrics.md index 314fcbaf39..3f48775e49 100644 --- a/doc/metrics.md +++ b/doc/metrics.md @@ -1,6 +1,6 @@ # Metrics -This quick start is for end users of OpenTelemetry who wish to manually measure their applications. If you are a library author, please see the [Library Authors Guide](library-author.md). If you wish to automatically instrument your application, see the automatic instrumentation documentation for the SDK you wish to use. +This quick start is for end users of OpenTelemetry who wish to manually measure their applications. If you wish to automatically instrument your application, see the automatic instrumentation documentation for the SDK you wish to use. For a high-level overview of OpenTelemetry metrics in general and definitions of some common terms, you can refer to the [OpenTelemetry Specification Overview][spec-overview] diff --git a/doc/processor-api.md b/doc/processor-api.md deleted file mode 100644 index 58d7916e57..0000000000 --- a/doc/processor-api.md +++ /dev/null @@ -1,147 +0,0 @@ -# Processor API Guide - - - -The processor has two responsibilities: choosing which aggregator to choose for a metric instrument and store the last record for each metric ready to be exported. - -## Selecting a specific aggregator for metrics - -Sometimes you may want to use a specific aggregator for one of your metric, export an average of the last X values instead of just the last one. - -Here is what an aggregator that does that would look like: - -```ts -import { Aggregator } from '@opentelemetry/sdk-metrics'; -import { hrTime } from '@opentelemetry/core'; - -export class AverageAggregator implements Aggregator { - - private _values: number[] = []; - private _limit: number; - - constructor (limit?: number) { - this._limit = limit ?? 10; - } - - update (value: number) { - this._values.push(value); - if (this._values.length >= this._limit) { - this._values = this._values.slice(0, 10); - } - } - - toPoint() { - const sum =this._values.reduce((agg, value) => { - agg += value; - return agg; - }, 0); - return { - value: this._values.length > 0 ? sum / this._values.length : 0, - timestamp: hrTime(), - } - } -} -``` - -Now we will need to implement our own processor to configure the sdk to use our new aggregator. To simplify even more, we will just extend the `UngroupedProcessor` (which is the default) to avoid re-implementing the whole `Aggregator` interface. - -Here the result: - -```ts -import { - UngroupedProcessor, - MetricDescriptor, - CounterSumAggregator, - ObserverAggregator, - MeasureExactAggregator, -} from '@opentelemetry/sdk-metrics'; - -export class CustomProcessor extends UngroupedProcessor { - aggregatorFor (metricDescriptor: MetricDescriptor) { - if (metricDescriptor.name === 'requests') { - return new AverageAggregator(10); - } - // this is exactly what the "UngroupedProcessor" does, we will re-use it - // to fallback on the default behavior - switch (metricDescriptor.metricKind) { - case MetricKind.COUNTER: - return new CounterSumAggregator(); - case MetricKind.OBSERVER: - return new ObserverAggregator(); - default: - return new MeasureExactAggregator(); - } - } -} -``` - -Finally, we need to specify to the `MeterProvider` to use our `CustomProcessor` when creating new meter: - -```ts -import { - UngroupedProcessor, - MetricDescriptor, - CounterSumAggregator, - ObserverAggregator, - MeasureExactAggregator, - MeterProvider, - Aggregator, -} from '@opentelemetry/sdk-metrics'; -import { hrTime } from '@opentelemetry/core'; - -export class AverageAggregator implements Aggregator { - - private _values: number[] = []; - private _limit: number; - - constructor (limit?: number) { - this._limit = limit ?? 10; - } - - update (value: number) { - this._values.push(value); - if (this._values.length >= this._limit) { - this._values = this._values.slice(0, 10); - } - } - - toPoint() { - const sum =this._values.reduce((agg, value) => { - agg += value; - return agg; - }, 0); - return { - value: this._values.length > 0 ? sum / this._values.length : 0, - timestamp: hrTime(), - } - } -} - -export class CustomProcessor extends UngroupedProcessor { - aggregatorFor (metricDescriptor: MetricDescriptor) { - if (metricDescriptor.name === 'requests') { - return new AverageAggregator(10); - } - // this is exactly what the "UngroupedProcessor" does, we will re-use it - // to fallback on the default behavior - switch (metricDescriptor.metricKind) { - case MetricKind.COUNTER: - return new CounterSumAggregator(); - case MetricKind.OBSERVER: - return new ObserverAggregator(); - default: - return new MeasureExactAggregator(); - } - } -} - -const meter = new MeterProvider({ - processor: new CustomProcessor(), - interval: 1000, -}).getMeter('example-custom-processor'); - -const requestsLatency = meter.createHistogram('requests', { - monotonic: true, - description: 'Average latency' -}); -``` diff --git a/doc/tracing.md b/doc/tracing.md index 77787549bc..392ca95736 100644 --- a/doc/tracing.md +++ b/doc/tracing.md @@ -1,6 +1,6 @@ # Tracing -This quick start is for end users of OpenTelemetry who wish to manually trace their applications. If you are a library author, please see the [Library Authors Guide](library-author.md). If you wish to automatically instrument your application, see the automatic instrumentation documentation for the SDK you wish to use. +This quick start is for end users of OpenTelemetry who wish to manually trace their applications. If you wish to automatically instrument your application, see the automatic instrumentation documentation for the SDK you wish to use. For a high-level overview of OpenTelemetry tracing in general and definitions of some common terms, you can refer to the [OpenTelemetry Specification Overview][spec-overview]