diff --git a/src/OpenTelemetry.Abstractions/Metrics/DefaultMeter.cs b/src/OpenTelemetry.Abstractions/Metrics/DefaultMeter.cs new file mode 100644 index 00000000000..c623f256ece --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/DefaultMeter.cs @@ -0,0 +1,298 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + using System; + using System.Collections.Generic; + using System.Net.NetworkInformation; + using OpenTelemetry.Metrics.Implementation; + using OpenTelemetry.Resources; + using OpenTelemetry.Tags; + using OpenTelemetry.Trace; + + /// + /// No-op implementation of a meter interface. + /// + public class DefaultMeter : IMeter + { + private static CounterDoubleBuilder counterDoubleBuilder = new CounterDoubleBuilder(); + private static CounterLongBuilder counterLongBuilder = new CounterLongBuilder(); + private static GaugeDoubleBuilder gaugeDoubleBuilder = new GaugeDoubleBuilder(); + private static GaugeLongBuilder gaugeLongBuilder = new GaugeLongBuilder(); + private static MeasureBuilder measureBuilder = new MeasureBuilder(); + + /// + public ICounterDoubleBuilder GetCounterDoubleBuilder(string name) => counterDoubleBuilder; + + /// + public ICounterLongBuilder GetCounterLongBuilder(string name) => counterLongBuilder; + + /// + public IGaugeDoubleBuilder GetGaugeDoubleBuilder(string name) => gaugeDoubleBuilder; + + /// + public IGaugeLongBuilder GetGaugeLongBuilder(string name) => gaugeLongBuilder; + + /// + public IMeasureBuilder GetMeasureBuilder(string name) => measureBuilder; + + /// + public void Record(IEnumerable measurements) + { + } + + /// + public void Record(IEnumerable measurements, ITagContext tagContext) + { + } + + /// + public void Record(IEnumerable measurements, ITagContext tagContext, SpanContext spanContext) + { + } + + private class CounterDoubleTimeSeries : ICounterDoubleTimeSeries + { + public void Add(double delta) + { + } + + public void Set(double val) + { + } + } + + private class CounterDouble : ICounterDouble + { + private static CounterDoubleTimeSeries timeSeries = new CounterDoubleTimeSeries(); + + public void Clear() + { + } + + public ICounterDoubleTimeSeries GetDefaultTimeSeries() => timeSeries; + + public ICounterDoubleTimeSeries GetOrCreateTimeSeries(IEnumerable labelValues) => timeSeries; + + public void RemoveTimeSeries(IEnumerable labelValues) + { + } + + public void SetCallback(Action metricUpdater) + { + } + } + + private class CounterDoubleBuilder : ICounterDoubleBuilder + { + private static CounterDouble counterDouble = new CounterDouble(); + + public IMetric Build() => counterDouble; + + public IMetricBuilder SetComponent(string component) => this; + + public IMetricBuilder SetConstantLabels(IDictionary constantLabels) => this; + + public IMetricBuilder SetDescription(string description) => this; + + public IMetricBuilder SetLabelKeys(IEnumerable labelKeys) => this; + + public IMetricBuilder SetResource(Resource resource) => this; + + public IMetricBuilder SetUnit(string unit) => this; + } + + private class CounterLongTimeSeries : ICounterLongTimeSeries + { + public void Add(long delta) + { + } + + public void Set(long val) + { + } + } + + private class CounterLong : ICounterLong + { + private static CounterLongTimeSeries timeSeries = new CounterLongTimeSeries(); + + public void Clear() + { + } + + public ICounterLongTimeSeries GetDefaultTimeSeries() => timeSeries; + + public ICounterLongTimeSeries GetOrCreateTimeSeries(IEnumerable labelValues) => timeSeries; + + public void RemoveTimeSeries(IEnumerable labelValues) + { + } + + public void SetCallback(Action metricUpdater) + { + } + } + + private class CounterLongBuilder : ICounterLongBuilder + { + private static CounterLong counterLong = new CounterLong(); + + public IMetric Build() => counterLong; + + public IMetricBuilder SetComponent(string component) => this; + + public IMetricBuilder SetConstantLabels(IDictionary constantLabels) => this; + + public IMetricBuilder SetDescription(string description) => this; + + public IMetricBuilder SetLabelKeys(IEnumerable labelKeys) => this; + + public IMetricBuilder SetResource(Resource resource) => this; + + public IMetricBuilder SetUnit(string unit) => this; + } + + private class GaugeDoubleTimeSeries : IGaugeDoubleTimeSeries + { + public void Add(double delta) + { + } + + public void Set(double val) + { + } + } + + private class GaugeDouble : IGaugeDouble + { + private static GaugeDoubleTimeSeries timeSeries = new GaugeDoubleTimeSeries(); + + public void Clear() + { + } + + public IGaugeDoubleTimeSeries GetDefaultTimeSeries() => timeSeries; + + public IGaugeDoubleTimeSeries GetOrCreateTimeSeries(IEnumerable labelValues) => timeSeries; + + public void RemoveTimeSeries(IEnumerable labelValues) + { + } + + public void SetCallback(Action metricUpdater) + { + } + } + + private class GaugeDoubleBuilder : IGaugeDoubleBuilder + { + private static GaugeDouble gaugeDouble = new GaugeDouble(); + + public IMetric Build() => gaugeDouble; + + public IMetricBuilder SetComponent(string component) => this; + + public IMetricBuilder SetConstantLabels(IDictionary constantLabels) => this; + + public IMetricBuilder SetDescription(string description) => this; + + public IMetricBuilder SetLabelKeys(IEnumerable labelKeys) => this; + + public IMetricBuilder SetResource(Resource resource) => this; + + public IMetricBuilder SetUnit(string unit) => this; + } + + private class GaugeLongTimeSeries : IGaugeLongTimeSeries + { + public void Add(long delta) + { + } + + public void Set(long val) + { + } + } + + private class GaugeLong : IGaugeLong + { + private static GaugeLongTimeSeries timeSeries = new GaugeLongTimeSeries(); + + public void Clear() + { + } + + public IGaugeLongTimeSeries GetDefaultTimeSeries() => timeSeries; + + public IGaugeLongTimeSeries GetOrCreateTimeSeries(IEnumerable labelValues) => timeSeries; + + public void RemoveTimeSeries(IEnumerable labelValues) + { + } + + public void SetCallback(Action metricUpdater) + { + } + } + + private class GaugeLongBuilder : IGaugeLongBuilder + { + private static GaugeLong counterLong = new GaugeLong(); + + public IMetric Build() => counterLong; + + public IMetricBuilder SetComponent(string component) => this; + + public IMetricBuilder SetConstantLabels(IDictionary constantLabels) => this; + + public IMetricBuilder SetDescription(string description) => this; + + public IMetricBuilder SetLabelKeys(IEnumerable labelKeys) => this; + + public IMetricBuilder SetResource(Resource resource) => this; + + public IMetricBuilder SetUnit(string unit) => this; + } + + private class Measurement : IMeasurement + { + } + + private class Measure : IMeasure + { + private static IMeasurement measurement = new Measurement(); + + public IMeasurement CreateDoubleMeasurement(double value) => measurement; + + public IMeasurement CreateLongMeasurement(long value) => measurement; + } + + private class MeasureBuilder : IMeasureBuilder + { + private static Measure measure = new Measure(); + + public IMeasure Build() => measure; + + public IMeasureBuilder SetDescription(string description) => this; + + public IMeasureBuilder SetType(MeasureType type) => this; + + public IMeasureBuilder SetUnit(string unit) => this; + } + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/ICounterDouble.cs b/src/OpenTelemetry.Abstractions/Metrics/ICounterDouble.cs new file mode 100644 index 00000000000..7694e10474f --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/ICounterDouble.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + using OpenTelemetry.Metrics.Implementation; + + /// + /// Counter metric, to report instantaneous measurement of a double value. Cumulative values can go + /// up or stay the same, but can never go down.Cumulative values cannot be negative. + /// + public interface ICounterDouble : IMetric + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/ICounterLong.cs b/src/OpenTelemetry.Abstractions/Metrics/ICounterLong.cs new file mode 100644 index 00000000000..d1cb99a35d8 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/ICounterLong.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + using OpenTelemetry.Metrics.Implementation; + + /// + /// Counter metric, to report instantaneous measurement of a double value. Cumulative values can go + /// up or stay the same, but can never go down.Cumulative values cannot be negative. + /// + public interface ICounterLong : IMetric + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/IGaugeDouble.cs b/src/OpenTelemetry.Abstractions/Metrics/IGaugeDouble.cs new file mode 100644 index 00000000000..b584fcfc2fa --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/IGaugeDouble.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + using OpenTelemetry.Metrics.Implementation; + + /// + /// Gauge metric, to report instantaneous measurement of a double value. Cumulative values can go + /// up or down. + /// + public interface IGaugeDouble : IMetric + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/IGaugeLong.cs b/src/OpenTelemetry.Abstractions/Metrics/IGaugeLong.cs new file mode 100644 index 00000000000..6fd9c4d04ed --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/IGaugeLong.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + using OpenTelemetry.Metrics.Implementation; + + /// + /// Gauge metric, to report instantaneous measurement of a double value. Cumulative values can go + /// up or stay the same, but can never go down.Cumulative values cannot be negative. + /// + public interface IGaugeLong : IMetric + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/IMeasure.cs b/src/OpenTelemetry.Abstractions/Metrics/IMeasure.cs new file mode 100644 index 00000000000..bc4a6ee74d2 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/IMeasure.cs @@ -0,0 +1,35 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + public interface IMeasure + { + /// + /// Records the measurement of this . + /// + /// Value to be recorded. + /// Measurement representing this value. + IMeasurement CreateDoubleMeasurement(double value); + + /// + /// Records the measurement of this . + /// + /// Value to be recorded. + /// Measurement representing this value. + IMeasurement CreateLongMeasurement(long value); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/IMeasurement.cs b/src/OpenTelemetry.Abstractions/Metrics/IMeasurement.cs new file mode 100644 index 00000000000..90318f0ffe5 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/IMeasurement.cs @@ -0,0 +1,25 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + /// + /// Immutable representation of a measurement. + /// + public interface IMeasurement + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/IMeter.cs b/src/OpenTelemetry.Abstractions/Metrics/IMeter.cs new file mode 100644 index 00000000000..6043037ae9d --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/IMeter.cs @@ -0,0 +1,71 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + using System.Collections; + using System.Collections.Generic; + using OpenTelemetry.Metrics.Implementation; + using OpenTelemetry.Tags; + using OpenTelemetry.Trace; + + /// + /// Returns a builder for . + /// + public interface IMeter + { + /// + /// Gets the builder for . + /// + /// Name of the counter. + /// The builder for the . + ICounterDoubleBuilder GetCounterDoubleBuilder(string name); + + /// + /// Gets the builder for . + /// + /// Name of the counter. + /// The builder for the . + ICounterLongBuilder GetCounterLongBuilder(string name); + + /// + /// Gets the builder for . + /// + /// Name of the counter. + /// The builder for the . + IGaugeDoubleBuilder GetGaugeDoubleBuilder(string name); + + /// + /// Gets the builder for . + /// + /// Name of the counter. + /// The builder for the . + IGaugeLongBuilder GetGaugeLongBuilder(string name); + + /// + /// Gets the builder for the . + /// + /// The name of the . + /// The to build the . + IMeasureBuilder GetMeasureBuilder(string name); + + void Record(IEnumerable measurements); + + void Record(IEnumerable measurements, ITagContext tagContext); + + void Record(IEnumerable measurements, ITagContext tagContext, SpanContext spanContext); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/IMetric{T}.cs b/src/OpenTelemetry.Abstractions/Metrics/IMetric{T}.cs new file mode 100644 index 00000000000..c461fd8e3f5 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/IMetric{T}.cs @@ -0,0 +1,72 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + using System; + using System.Collections.Generic; + using OpenTelemetry.Resources; + + /// + /// Base interface for all metrics defined in this package. + /// + /// Type of the time series of the metric. + public interface IMetric + { + /// + /// Creates a time series and returns a time series if the specified labelValues + /// is not already associated with this metric, else returns an existing time series. + /// + /// It is recommended to keep a reference to the time series instead of always calling this + /// method for every operations. + /// + /// + /// The list of label values. The number of label values must be the same to + /// that of the label keys passed to. + /// + /// A time series the value of single metric. + T GetOrCreateTimeSeries(IEnumerable labelValues); + + /// + /// Returns a time series for a metric with all labels not set (default label values). + /// + /// A time series for a metric with all labels not set (default label values) + T GetDefaultTimeSeries(); + + /// + /// Sets a callback that gets executed every time before exporting this metric. Used to + /// implement pull-based metric. + /// + /// Evaluation is deferred until needed, if this is not exported then it will never be called. + /// + /// The callback to be executed before export. + void SetCallback(Action metricUpdater); + + /// + /// Removes the time series from the metric, if it is present. i.e. references to previous time series + /// are invalid (not part of the metric). + /// + /// If value is missing for one of the predefined keys null must be used for that value. + /// + /// The list of label values + void RemoveTimeSeries(IEnumerable labelValues); + + /// + /// Removes all time series from the metric. i.e. references to all previous time series are invalid (not part of the metric). + /// + void Clear(); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterDoubleBuilder.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterDoubleBuilder.cs new file mode 100644 index 00000000000..e5c935cbd8b --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterDoubleBuilder.cs @@ -0,0 +1,25 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// The builder for the . + /// + public interface ICounterDoubleBuilder : IMetricBuilder + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterDoubleTimeSeries.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterDoubleTimeSeries.cs new file mode 100644 index 00000000000..31e33658c1a --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterDoubleTimeSeries.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// Time series type for . + /// + public interface ICounterDoubleTimeSeries + { + void Add(double delta); + + void Set(double val); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterLongBuilder.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterLongBuilder.cs new file mode 100644 index 00000000000..3b37e488422 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterLongBuilder.cs @@ -0,0 +1,25 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// The builder for the . + /// + public interface ICounterLongBuilder : IMetricBuilder + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterLongTimeSeries.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterLongTimeSeries.cs new file mode 100644 index 00000000000..0200ebd08db --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/ICounterLongTimeSeries.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// Time series type for . + /// + public interface ICounterLongTimeSeries + { + void Add(long delta); + + void Set(long val); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeDoubleBuilder.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeDoubleBuilder.cs new file mode 100644 index 00000000000..97abcdffdb0 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeDoubleBuilder.cs @@ -0,0 +1,25 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// The builder for the . + /// + public interface IGaugeDoubleBuilder : IMetricBuilder + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeDoubleTimeSeries.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeDoubleTimeSeries.cs new file mode 100644 index 00000000000..d2b44a6917d --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeDoubleTimeSeries.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// Time series type for . + /// + public interface IGaugeDoubleTimeSeries + { + void Add(double delta); + + void Set(double val); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeLongBuilder.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeLongBuilder.cs new file mode 100644 index 00000000000..54c31a1e288 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeLongBuilder.cs @@ -0,0 +1,25 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// The builder for the . + /// + public interface IGaugeLongBuilder : IMetricBuilder + { + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeLongTimeSeries.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeLongTimeSeries.cs new file mode 100644 index 00000000000..1fb581ca384 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IGaugeLongTimeSeries.cs @@ -0,0 +1,28 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + /// + /// Time series type for . + /// + public interface IGaugeLongTimeSeries + { + void Add(long delta); + + void Set(long val); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/IMeasureBuilder.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IMeasureBuilder.cs new file mode 100644 index 00000000000..65d828c48d1 --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IMeasureBuilder.cs @@ -0,0 +1,53 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + using System; + + /// + /// Builder for the . + /// + public interface IMeasureBuilder + { + /// + /// Sets the description of the . + /// + /// The detailed description of the . + /// This builder object. + IMeasureBuilder SetDescription(string description); + + /// + /// Sets the description of the . + /// + /// The detailed description of the . + /// This builder object. + IMeasureBuilder SetUnit(string unit); + + /// + /// Sets the corresponding to the underlying value of the . + /// + /// The detailed description of the . + /// This builder object. + IMeasureBuilder SetType(MeasureType type); + + /// + /// Builds the . + /// + /// The object. + IMeasure Build(); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/IMetricBuilder{T}.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IMetricBuilder{T}.cs new file mode 100644 index 00000000000..7a7ef777c0e --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/IMetricBuilder{T}.cs @@ -0,0 +1,76 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + using System.Collections.Generic; + using OpenTelemetry.Resources; + + /// + /// Metric builder interface. + /// + /// Type of time series in metric. + public interface IMetricBuilder + { + /// + /// Sets the description of the . + /// + /// Description of the metric. + /// This builder instance. + IMetricBuilder SetDescription(string description); + + /// + /// Sets the description of the . + /// + /// Unit of the metric. + /// This builder instance. + IMetricBuilder SetUnit(string unit); + + /// + /// Sets the description of the . + /// + /// List of keys for dynamic labels. + /// This builder instance. + IMetricBuilder SetLabelKeys(IEnumerable labelKeys); + + /// + /// Sets the description of the . + /// + /// Set of labels with values. + /// This builder instance. + IMetricBuilder SetConstantLabels(IDictionary constantLabels); + + /// + /// Sets the description of the . + /// + /// Component reporting this metric. + /// This builder instance. + IMetricBuilder SetComponent(string component); + + /// + /// Sets the description of the . + /// + /// Resource associated with the metric. + /// This builder instance. + IMetricBuilder SetResource(Resource resource); + + /// + /// Builds the . + /// + /// The new instance of . + IMetric Build(); + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/Implementation/MeasureType.cs b/src/OpenTelemetry.Abstractions/Metrics/Implementation/MeasureType.cs new file mode 100644 index 00000000000..d00e65bd07b --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/Implementation/MeasureType.cs @@ -0,0 +1,31 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics.Implementation +{ + public enum MeasureType + { + /// + /// Long type values. + /// + Long, + + /// + /// Double type values. + /// + Double, + } +} diff --git a/src/OpenTelemetry.Abstractions/Metrics/LabelKey.cs b/src/OpenTelemetry.Abstractions/Metrics/LabelKey.cs new file mode 100644 index 00000000000..fc9014e7dfa --- /dev/null +++ b/src/OpenTelemetry.Abstractions/Metrics/LabelKey.cs @@ -0,0 +1,53 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Metrics +{ + /// + /// The key of a label associated with a . + /// + public sealed class LabelKey + { + private LabelKey() + { + } + + /// + /// Gets a key of the label. + /// + public string Key { get; private set; } + + /// + /// Gets a human-readable description of what this label key represents. + /// + public string Description { get; private set; } + + /// + /// Creates a new instance of a . + /// + /// The key of the label. + /// A human-readable description of what this label key represents. + /// A new instance of . + public static LabelKey Create(string key, string description) + { + return new LabelKey() + { + Key = key, + Description = description, + }; + } + } +}