Modify metric api as per offline feebacks (#326)
* Modify metric api as per offline feebacks * FileName change * fix missing measure methods on Meter * fix no op meter
This commit is contained in:
parent
2a931fcdee
commit
a7449e619f
|
|
@ -0,0 +1,59 @@
|
|||
// <copyright file="Counter.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Counter instrument.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
|
||||
public abstract class Counter<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds or Increments the counter.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value by which the counter should be incremented.</param>
|
||||
/// <param name="labelset">The labelset associated with this value.</param>
|
||||
public abstract void Add(in SpanContext context, T value, LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Adds or Increments the counter.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value by which the counter should be incremented.</param>
|
||||
/// <param name="labels">The labels or dimensions associated with this value.</param>
|
||||
public abstract void Add(in SpanContext context, T value, IEnumerable<KeyValuePair<string, string>> labels);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labelset.
|
||||
/// </summary>
|
||||
/// <param name="labelset">The labelset from which handle should be constructed.</param>
|
||||
/// <returns>The handle.</returns>
|
||||
public abstract CounterHandle<T> GetHandle(LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labels.
|
||||
/// </summary>
|
||||
/// <param name="labels">The labels or dimensions associated with this value.</param>
|
||||
/// <returns>The handle.</returns>
|
||||
public abstract CounterHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="ICounterHandle.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="CounterHandle.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -14,17 +14,24 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Handle to the counter with the defined <see cref="LabelSet"/>.
|
||||
/// </summary>
|
||||
public interface ICounterHandle
|
||||
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
|
||||
public struct CounterHandle<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds or Increments the value of the counter handle.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value by which the counter handle should be incremented.</param>
|
||||
void Add(int value);
|
||||
public void Add(in SpanContext context, T value)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
// <copyright file="Guage.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Gauge instrument.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of gauge. Only long and double are supported now.</typeparam>
|
||||
public abstract class Guage<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the value of the guague.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value to which the Gauge should be set.</param>
|
||||
/// <param name="labelset">The labelset associated with this value.</param>
|
||||
public abstract void Set(in SpanContext context, T value, LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the guague.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value to which the Gauge should be set.</param>
|
||||
/// <param name="labels">The labels or dimensions associated with this value.</param>
|
||||
public abstract void Set(in SpanContext context, T value, IEnumerable<KeyValuePair<string, string>> labels);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labelset.
|
||||
/// </summary>
|
||||
/// <param name="labelset">The labelset from which handle should be constructed.</param>
|
||||
/// <returns>The handle.</returns>
|
||||
public abstract CounterHandle<T> GetHandle(LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labels.
|
||||
/// </summary>
|
||||
/// <param name="labels">The labels or dimensions associated with this value.</param>
|
||||
/// <returns>The handle.</returns>
|
||||
public abstract CounterHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="IGuageHandle.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="GuageHandle.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -14,17 +14,27 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Handle to the gauge with the defined <see cref="LabelSet"/>.
|
||||
/// </summary>
|
||||
public interface IGuageHandle
|
||||
/// <typeparam name="T">The type of the Gauge. Only long and double are supported now.</typeparam>
|
||||
public struct GuageHandle<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the value of the guague.
|
||||
/// </summary>
|
||||
/// <param name="value">value to set the guage to.</param>
|
||||
void Set(int value);
|
||||
/// <summary>
|
||||
/// Sets the value of the guague handle.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value to which the Gauge should be set.</param>
|
||||
public void Set(in SpanContext context, T value)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// <copyright file="ICounter.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Counter instrument.
|
||||
/// </summary>
|
||||
public interface ICounter
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds or Increments the counter.
|
||||
/// </summary>
|
||||
/// <param name="value">value by which the counter should be incremented.</param>
|
||||
/// <param name="labelset">The labelset associated with this value.</param>
|
||||
void Add(int value, LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labelset.
|
||||
/// </summary>
|
||||
/// <param name="labelset">The labelset from which handle should be constructed.</param>
|
||||
/// <returns>The <see cref="ICounterHandle" /> with label.</returns>
|
||||
ICounterHandle GetHandle(LabelSet labelset);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// <copyright file="IGuage.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Gauge instrument.
|
||||
/// </summary>
|
||||
public interface IGuage
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the value of the guague.
|
||||
/// </summary>
|
||||
/// <param name="value">value by which the counter should be incremented.</param>
|
||||
/// <param name="labelset">The labelset associated with this value.</param>
|
||||
void Set(int value, LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labelset.
|
||||
/// </summary>
|
||||
/// <param name="labelset">The labelset from which handle should be constructed.</param>
|
||||
/// <returns>The <see cref="IGuageHandle" /> with label.</returns>
|
||||
IGuageHandle GetHandle(LabelSet labelset);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// <copyright file="IMeasure.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Measure instrument.
|
||||
/// </summary>
|
||||
public interface IMeasure
|
||||
{
|
||||
/// <summary>
|
||||
/// Records a measure.
|
||||
/// </summary>
|
||||
/// <param name="value">value by which the counter should be incremented.</param>
|
||||
/// <param name="labelset">The labelset associated with this value.</param>
|
||||
void Record(int value, LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labelset.
|
||||
/// </summary>
|
||||
/// <param name="labelset">The labelset from which handle should be constructed.</param>
|
||||
/// <returns>The <see cref="IMeasureHandle" /> with label.</returns>
|
||||
IMeasureHandle GetHandle(LabelSet labelset);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
// <copyright file="IMeter.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Main interface to obtain metric instruments.
|
||||
/// </summary>
|
||||
public interface IMeter
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ICounter"/> with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the <see cref="ICounter"/>.</param>
|
||||
/// <returns>The <see cref="ICounter"/> instance.</returns>
|
||||
ICounter CreateCounter(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IGuage"/> with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the <see cref="IGuage"/>.</param>
|
||||
/// <returns>The <see cref="IGuage"/> instance.</returns>
|
||||
IGuage CreateGauge(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IMeasure"/> with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the <see cref="IMeasure"/>.</param>
|
||||
/// <returns>The <see cref="IMeasure"/> instance.</returns>
|
||||
IMeasure CreateMeasure(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Constructs or retrieves the <see cref="LabelSet"/> from the given label key-value pairs.
|
||||
/// </summary>
|
||||
/// <param name="labels">Label key value pairs.</param>
|
||||
/// <returns>The <see cref="LabelSet"/> with given label key value pairs.</returns>
|
||||
LabelSet GetLabelSet(IEnumerable<KeyValuePair<string, string>> labels);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Name value pairs of metric labels.
|
||||
/// Normalized name value pairs of metric labels.
|
||||
/// </summary>
|
||||
public class LabelSet
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
// <copyright file="Measure.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Measure instrument.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of counter. Only long and double are supported now.</typeparam>
|
||||
public abstract class Measure<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Records a measure.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value to record.</param>
|
||||
/// <param name="labelset">The labelset associated with this value.</param>
|
||||
public abstract void Record(in SpanContext context, T value, LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Records a measure.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value to record.</param>
|
||||
/// <param name="labels">The labels or dimensions associated with this value.</param>
|
||||
public abstract void Record(in SpanContext context, int value, IEnumerable<KeyValuePair<string, string>> labels);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labelset.
|
||||
/// </summary>
|
||||
/// <param name="labelset">The labelset from which handle should be constructed.</param>
|
||||
/// <returns>The handle.</returns>
|
||||
public abstract MeasureHandle<T> GetHandle(LabelSet labelset);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the handle with given labelset.
|
||||
/// </summary>
|
||||
/// <param name="labels">The labels or dimensions associated with this value.</param>
|
||||
/// <returns>The handle.</returns>
|
||||
public abstract MeasureHandle<T> GetHandle(IEnumerable<KeyValuePair<string, string>> labels);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="IMeasureHandle.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="MeasureHandle.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -14,17 +14,27 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Handle to the measure with the defined <see cref="LabelSet"/>.
|
||||
/// </summary>
|
||||
public interface IMeasureHandle
|
||||
/// <typeparam name="T">The type of the Measure. Only long and double are supported now.</typeparam>
|
||||
public struct MeasureHandle<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// Records a measure.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Sets the value of the guague handle.
|
||||
/// </summary>
|
||||
/// <param name="context">the associated span context.</param>
|
||||
/// <param name="value">value to record.</param>
|
||||
void Record(int value);
|
||||
public void Record(in SpanContext context, T value)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
// <copyright file="Meter.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Main interface to obtain metric instruments.
|
||||
/// </summary>
|
||||
public abstract class Meter
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a counter for long with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the counter.</param>
|
||||
/// <param name="monotonic">indicates if only positive values are expected.</param>
|
||||
/// <returns>The counter instance.</returns>
|
||||
public abstract Counter<long> CreateLongCounter(string name, bool monotonic = true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a counter for double with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">indicates if only positive values are expected.</param>
|
||||
/// <param name="monotonic">The name of the counter.</param>
|
||||
/// <returns>The counter instance.</returns>
|
||||
public abstract Counter<double> CreateDoubleCounter(string name, bool monotonic = true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a guage for long with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the counter.</param>
|
||||
/// <param name="monotonic">indicates if only positive values are expected.</param>
|
||||
/// <returns>The guage instance.</returns>
|
||||
public abstract Guage<long> CreateLongGauge(string name, bool monotonic = false);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a guage for long with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the counter.</param>
|
||||
/// <param name="monotonic">indicates if only positive values are expected.</param>
|
||||
/// <returns>The guage instance.</returns>
|
||||
public abstract Guage<double> CreateDoubleGauge(string name, bool monotonic = false);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a measure for long with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the measure.</param>
|
||||
/// <param name="absolute">indicates if only positive values are expected.</param>
|
||||
/// <returns>The measure instance.</returns>
|
||||
public abstract Measure<long> CreateLongMeasure(string name, bool absolute = true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a measure for long with given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the measure.</param>
|
||||
/// <param name="absolute">indicates if only positive values are expected.</param>
|
||||
/// <returns>The measure instance.</returns>
|
||||
public abstract Measure<double> CreateDoubleMeasure(string name, bool absolute = true);
|
||||
|
||||
/// <summary>
|
||||
/// Constructs or retrieves the <see cref="LabelSet"/> from the given label key-value pairs.
|
||||
/// </summary>
|
||||
/// <param name="labels">Label key value pairs.</param>
|
||||
/// <returns>The <see cref="LabelSet"/> with given label key value pairs.</returns>
|
||||
public abstract LabelSet GetLabelSet(IEnumerable<KeyValuePair<string, string>> labels);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ namespace OpenTelemetry.Metrics
|
|||
/// </summary>
|
||||
public class MeterFactoryBase
|
||||
{
|
||||
private static NoOpMeter noOpMeter = new NoOpMeter();
|
||||
private static MeterFactoryBase defaultFactory = new MeterFactoryBase();
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -33,11 +34,12 @@ namespace OpenTelemetry.Metrics
|
|||
/// <summary>
|
||||
/// Returns an IMeter for a given name and version.
|
||||
/// </summary>
|
||||
/// <param name="componentName">Name of the instrumentation library or component this Metric is meant for.</param>
|
||||
/// <returns>Meter with the given component name.</returns>
|
||||
public virtual IMeter GetMeter(string componentName)
|
||||
/// <param name="name">Name of the instrumentation library.</param>
|
||||
/// <param name="version">Version of the instrumentation library (optional).</param>
|
||||
/// <returns>Meter with the given component name and version.</returns>
|
||||
public virtual Meter GetMeter(string name, string version = null)
|
||||
{
|
||||
return defaultFactory.GetMeter(componentName);
|
||||
return noOpMeter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
// <copyright file="NoOpMeter.cs" company="OpenTelemetry Authors">
|
||||
// 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.
|
||||
// </copyright>
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
internal sealed class NoOpMeter : Meter
|
||||
{
|
||||
public NoOpMeter()
|
||||
{
|
||||
}
|
||||
|
||||
public override Counter<double> CreateDoubleCounter(string name, bool monotonic = true)
|
||||
{
|
||||
// return no op
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override Guage<double> CreateDoubleGauge(string name, bool monotonic = false)
|
||||
{
|
||||
// return no op
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override Measure<double> CreateDoubleMeasure(string name, bool absolute = true)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override Counter<long> CreateLongCounter(string name, bool monotonic = true)
|
||||
{
|
||||
// return no op
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override Guage<long> CreateLongGauge(string name, bool monotonic = false)
|
||||
{
|
||||
// return no op
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override Measure<long> CreateLongMeasure(string name, bool absolute = true)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override LabelSet GetLabelSet(IEnumerable<KeyValuePair<string, string>> labels)
|
||||
{
|
||||
// return no op
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue