Updating ruleset to OpenTelemetry.csproj (#601)

* Updating ruleset to OpenTelemetry.csproj

* updating return comments

Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
This commit is contained in:
Eddy Nakamura 2020-04-15 20:13:02 -03:00 committed by GitHub
parent 38850878b5
commit a7bf7f2168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 84 additions and 36 deletions

View File

@ -31,7 +31,8 @@ namespace OpenTelemetry.Collector
public DiagnosticSourceSubscriber(
ListenerHandler handler,
Func<string, object, object, bool> isEnabledFilter) : this(_ => handler, value => handler.SourceName == value.Name, isEnabledFilter)
Func<string, object, object, bool> isEnabledFilter)
: this(_ => handler, value => handler.SourceName == value.Name, isEnabledFilter)
{
}

View File

@ -18,7 +18,8 @@ using OpenTelemetry.Metrics.Export;
namespace OpenTelemetry.Metrics.Aggregators
{
public abstract class Aggregator<T> where T : struct
public abstract class Aggregator<T>
where T : struct
{
public abstract void Update(T value);

View File

@ -24,7 +24,8 @@ namespace OpenTelemetry.Metrics
{
private readonly DoubleCounterSumAggregator sumAggregator = new DoubleCounterSumAggregator();
public DoubleBoundCounterMetricSdk(RecordStatus recordStatus) : base(recordStatus)
public DoubleBoundCounterMetricSdk(RecordStatus recordStatus)
: base(recordStatus)
{
}

View File

@ -22,7 +22,8 @@ namespace OpenTelemetry.Metrics
{
internal class DoubleCounterMetricSdk : CounterMetricSdkBase<double>
{
public DoubleCounterMetricSdk(string name) : base(name)
public DoubleCounterMetricSdk(string name)
: base(name)
{
}

View File

@ -18,7 +18,8 @@ namespace OpenTelemetry.Metrics
{
internal class DoubleMeasureMetricSdk : MeasureMetricSdk<double>
{
public DoubleMeasureMetricSdk(string name) : base(name)
public DoubleMeasureMetricSdk(string name)
: base(name)
{
}

View File

@ -37,6 +37,7 @@ namespace OpenTelemetry.Metrics
if (!this.observerHandles.TryGetValue(labelset, out var boundInstrument))
{
boundInstrument = new DoubleObserverMetricHandleSdk();
// TODO cleanup of handle/aggregator. Issue #530
this.observerHandles.Add(labelset, boundInstrument);
}

View File

@ -24,7 +24,8 @@ namespace OpenTelemetry.Metrics.Export
/// <typeparam name="T">Type of the metric - long or double currently.</typeparam>
public class Metric<T>
{
public Metric(string metricNamespace,
public Metric(
string metricNamespace,
string metricName,
string desc,
IEnumerable<KeyValuePair<string, string>> labels,

View File

@ -36,13 +36,14 @@ namespace OpenTelemetry.Metrics.Export
private List<Metric<double>> doubleMetrics;
/// <summary>
/// Constructs UngroupedBatcher.
/// Initializes a new instance of the <see cref="UngroupedBatcher"/> class.
/// </summary>
/// <param name="exporter">Metric exporter instance.</param>
/// <param name="aggregationInterval">Interval at which metrics are pushed to Exporter.</param>
public UngroupedBatcher(MetricExporter exporter, TimeSpan aggregationInterval)
{
this.exporter = exporter ?? throw new ArgumentNullException(nameof(exporter));
// TODO make this thread safe.
this.longMetrics = new List<Metric<long>>();
this.doubleMetrics = new List<Metric<double>>();
@ -53,10 +54,11 @@ namespace OpenTelemetry.Metrics.Export
}
/// <summary>
/// Constructs UngroupedBatcher.
/// Initializes a new instance of the <see cref="UngroupedBatcher"/> class.
/// </summary>
/// <param name="exporter">Metric exporter instance.</param>
public UngroupedBatcher(MetricExporter exporter) : this(exporter, TimeSpan.FromSeconds(5))
public UngroupedBatcher(MetricExporter exporter)
: this(exporter, TimeSpan.FromSeconds(5))
{
}

View File

@ -24,7 +24,8 @@ namespace OpenTelemetry.Metrics
{
private readonly Int64CounterSumAggregator sumAggregator = new Int64CounterSumAggregator();
public Int64BoundCounterMetricSdk(RecordStatus recordStatus) : base(recordStatus)
public Int64BoundCounterMetricSdk(RecordStatus recordStatus)
: base(recordStatus)
{
}

View File

@ -22,7 +22,8 @@ namespace OpenTelemetry.Metrics
{
internal class Int64CounterMetricSdk : CounterMetricSdkBase<long>
{
public Int64CounterMetricSdk(string name) : base(name)
public Int64CounterMetricSdk(string name)
: base(name)
{
}

View File

@ -18,7 +18,8 @@ namespace OpenTelemetry.Metrics
{
internal class Int64MeasureMetricSdk : MeasureMetricSdk<long>
{
public Int64MeasureMetricSdk(string name) : base(name)
public Int64MeasureMetricSdk(string name)
: base(name)
{
}

View File

@ -37,6 +37,7 @@ namespace OpenTelemetry.Metrics
if (!this.observerHandles.TryGetValue(labelset, out var boundInstrument))
{
boundInstrument = new Int64ObserverMetricHandleSdk();
// TODO cleanup of handle/aggregator. Issue #530
this.observerHandles.Add(labelset, boundInstrument);
}

View File

@ -32,7 +32,7 @@ namespace OpenTelemetry.Metrics
private string labelSetEncoded;
/// <summary>
/// Initializes a new instance of the <see cref="LabelSet"/> class.
/// Initializes a new instance of the <see cref="LabelSetSdk"/> class.
/// </summary>
/// <param name="labels">labels from which labelset should be constructed.</param>
internal LabelSetSdk(IEnumerable<KeyValuePair<string, string>> labels)

View File

@ -32,7 +32,7 @@ namespace OpenTelemetry.Metrics
UpdatePending,
/// <summary>
/// This status is applied to UpdatePending instruments after Collect() is done.
/// This status is applied to UpdatePending instruments after Collect() is done.
/// This will be moved to CandidateForRemoval during the next Collect() cycle.
/// If an update occurs, the instrument promotes them to UpdatePending.
/// </summary>

View File

@ -9,7 +9,7 @@
</PropertyGroup>
<PropertyGroup>
<CodeAnalysisRuleSet>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))/build/OpenTelemetry.prod.loose.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))/build/OpenTelemetry.prod.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>

View File

@ -36,7 +36,7 @@ namespace OpenTelemetry.Resources
// this implementation follows https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/sdk-resource.md
/// <summary>
/// Creates a new <see cref="Resource"/>.
/// Initializes a new instance of the <see cref="Resource"/> class.
/// </summary>
/// <param name="attributes">An <see cref="IDictionary{String, Object}"/> of attributes that describe the resource.</param>
public Resource(IEnumerable<KeyValuePair<string, object>> attributes)

View File

@ -30,6 +30,7 @@ namespace OpenTelemetry.Resources
/// <param name="serviceInstanceId">Unique identifier of the service instance.</param>
/// <param name="serviceNamespace">Optional namespace of the service.</param>
/// <param name="serviceVersion">Optional version of the service.</param>
/// <returns>Returns a new <see cref="Resource"/>.</returns>
public static Resource CreateServiceResource(string serviceName, string serviceInstanceId = null, string serviceNamespace = null, string serviceVersion = null)
{
if (serviceName == null)

View File

@ -40,6 +40,7 @@ namespace OpenTelemetry.Trace.Configuration
/// Adds chained processor to the pipeline. Processors are executed in the order they were added.
/// </summary>
/// <param name="processorFactory">Function that creates processor from the next one.</param>
/// <returns>Returns <see cref="SpanProcessorPipelineBuilder"/>.</returns>
public SpanProcessorPipelineBuilder AddProcessor(Func<SpanProcessor, SpanProcessor> processorFactory)
{
if (processorFactory == null)
@ -61,6 +62,7 @@ namespace OpenTelemetry.Trace.Configuration
/// Configures last processor that invokes exporter. When not set, <see cref="BatchingSpanProcessor"/> is used.
/// </summary>
/// <param name="processorFactory">Factory that creates exporting processor from the exporter.</param>
/// <returns>Returns <see cref="SpanProcessorPipelineBuilder"/>.</returns>
public SpanProcessorPipelineBuilder SetExportingProcessor(Func<SpanExporter, SpanProcessor> processorFactory)
{
this.lastProcessorFactory = processorFactory ?? throw new ArgumentNullException(nameof(processorFactory));
@ -71,6 +73,7 @@ namespace OpenTelemetry.Trace.Configuration
/// Configures exporter.
/// </summary>
/// <param name="exporter">Exporter instance.</param>
/// <returns>Returns <see cref="SpanProcessorPipelineBuilder"/>.</returns>
public SpanProcessorPipelineBuilder SetExporter(SpanExporter exporter)
{
this.Exporter = exporter ?? throw new ArgumentNullException(nameof(exporter));

View File

@ -43,6 +43,7 @@ namespace OpenTelemetry.Trace.Configuration
/// Configures sampler.
/// </summary>
/// <param name="sampler">Sampler instance.</param>
/// <returns>Returns <see cref="TracerBuilder"/> for chaining.</returns>
public TracerBuilder SetSampler(Sampler sampler)
{
this.Sampler = sampler ?? throw new ArgumentNullException(nameof(sampler));
@ -50,10 +51,10 @@ namespace OpenTelemetry.Trace.Configuration
}
/// <summary>
/// Sets the <see cref="Resource"/> describing the app associated with all traces. Overwrites currently set resource.
/// Sets the <see cref="Resource"/> describing the app associated with all traces. Overwrites currently set resource.
/// </summary>
/// <param name="resource">Resource to be associate with all traces.</param>
/// <returns>Trace builder for chaining.</returns>
/// <returns>Returns <see cref="TracerBuilder"/> for chaining.</returns>
public TracerBuilder SetResource(Resource resource)
{
this.Resource = resource ?? Resource.Empty;
@ -64,6 +65,7 @@ namespace OpenTelemetry.Trace.Configuration
/// Adds processing and exporting pipeline. Pipelines are executed sequentially in the order they are added.
/// </summary>
/// <param name="configure">Function that configures pipeline.</param>
/// <returns>Returns <see cref="TracerBuilder"/> for chaining.</returns>
public TracerBuilder AddProcessorPipeline(Action<SpanProcessorPipelineBuilder> configure)
{
if (configure == null)
@ -87,6 +89,7 @@ namespace OpenTelemetry.Trace.Configuration
/// </summary>
/// <typeparam name="TCollector">Type of collector class.</typeparam>
/// <param name="collectorFactory">Function that builds collector from <see cref="Tracer"/>.</param>
/// <returns>Returns <see cref="TracerBuilder"/> for chaining.</returns>
public TracerBuilder AddCollector<TCollector>(
Func<Tracer, TCollector> collectorFactory)
where TCollector : class
@ -114,6 +117,7 @@ namespace OpenTelemetry.Trace.Configuration
/// Configures tracing options.
/// </summary>
/// <param name="options">Instance of <see cref="TracerConfiguration"/>.</param>
/// <returns>Returns <see cref="TracerBuilder"/> for chaining.</returns>
public TracerBuilder SetTracerOptions(TracerConfiguration options)
{
this.TracerConfigurationOptions = options ?? throw new ArgumentNullException(nameof(options));

View File

@ -82,6 +82,7 @@ namespace OpenTelemetry.Trace.Configuration
/// Creates tracerSdk factory.
/// </summary>
/// <param name="configure">Function that configures tracerSdk factory.</param>
/// <returns>Returns new <see cref="TracerFactory"/>.</returns>
public static TracerFactory Create(Action<TracerBuilder> configure)
{
if (configure == null)

View File

@ -41,7 +41,7 @@ namespace OpenTelemetry.Trace.Export
private bool stopping = false;
/// <summary>
/// Constructs batching processor with default parameters:
/// Initializes a new instance of the <see cref="BatchingSpanProcessor"/> class with default parameters:
/// <list type="bullet">
/// <item>
/// <description>maxQueueSize = 2048,</description>
@ -55,12 +55,13 @@ namespace OpenTelemetry.Trace.Export
/// </list>
/// </summary>
/// <param name="exporter">Exporter instance.</param>
public BatchingSpanProcessor(SpanExporter exporter) : this(exporter, DefaultMaxQueueSize, DefaultScheduleDelay, DefaultMaxExportBatchSize)
public BatchingSpanProcessor(SpanExporter exporter)
: this(exporter, DefaultMaxQueueSize, DefaultScheduleDelay, DefaultMaxExportBatchSize)
{
}
/// <summary>
/// Constructs batching processor with custom settings.
/// Initializes a new instance of the <see cref="BatchingSpanProcessor"/> class with custom settings.
/// </summary>
/// <param name="exporter">Exporter instance.</param>
/// <param name="maxQueueSize">Maximum queue size. After the size is reached spans are dropped by processor.</param>

View File

@ -30,7 +30,7 @@ namespace OpenTelemetry.Trace.Export
private long spanCount = 0;
/// <summary>
/// Constructs simple processor.
/// Initializes a new instance of the <see cref="SimpleSpanProcessor"/> class.
/// </summary>
/// <param name="exporter">Span processor instance.</param>
public SimpleSpanProcessor(SpanExporter exporter)

View File

@ -29,8 +29,8 @@ namespace OpenTelemetry.Trace.Export
private readonly SpanSdk span;
/// <summary>
/// Creates SpanData instance.
/// <remarks>This constructor should be used to export out of band spans such as
/// Initializes a new instance of the <see cref="SpanData"/> struct.
/// <remarks>This constructor should be used to export out of band spans such as
/// compatible events created without OpenTelemetry API or in a different process</remarks>
/// </summary>
/// <param name="name">Span name.</param>
@ -64,7 +64,8 @@ namespace OpenTelemetry.Trace.Export
kind,
startTimestamp,
attributes,
events, links,
events,
links,
resource,
status,
endTimestamp,
@ -72,7 +73,7 @@ namespace OpenTelemetry.Trace.Export
}
/// <summary>
/// Creates SpanData from SpanSdk.
/// Initializes a new instance of the <see cref="SpanData"/> struct from SpanSdk.
/// </summary>
/// <param name="span">Span instance.</param>
internal SpanData(SpanSdk span)

View File

@ -54,6 +54,7 @@ namespace OpenTelemetry.Trace.Export
/// Shuts down exporter asynchronously.
/// </summary>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Returns <see cref="Task"/>.</returns>
public abstract Task ShutdownAsync(CancellationToken cancellationToken);
}
}

View File

@ -19,7 +19,7 @@ using System.Threading.Tasks;
namespace OpenTelemetry.Trace.Export
{
/// <summary>
/// Span processor base class.
/// Span processor base class.
/// </summary>
public abstract class SpanProcessor
{
@ -39,6 +39,7 @@ namespace OpenTelemetry.Trace.Export
/// Shuts down span processor asynchronously.
/// </summary>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Returns <see cref="Task"/>.</returns>
public abstract Task ShutdownAsync(CancellationToken cancellationToken);
}
}

View File

@ -730,7 +730,8 @@ namespace OpenTelemetry.Trace
IEnumerable<KeyValuePair<string, string>> tracestate = null;
if (parentContext.IsValid)
{
activity.SetParentId(parentContext.TraceId,
activity.SetParentId(
parentContext.TraceId,
parentContext.SpanId,
parentContext.TraceOptions);
if (parentContext.Tracestate != null && parentContext.Tracestate.Any())
@ -808,7 +809,8 @@ namespace OpenTelemetry.Trace
}
else
{
this.Links = parentLinks.GetRange(parentLinks.Count - this.tracerConfiguration.MaxNumberOfLinks,
this.Links = parentLinks.GetRange(
parentLinks.Count - this.tracerConfiguration.MaxNumberOfLinks,
this.tracerConfiguration.MaxNumberOfLinks);
}
}

View File

@ -38,7 +38,7 @@ namespace OpenTelemetry.Trace
}
/// <summary>
/// Creates an instance of <see cref="TracerSdk"/>.
/// Initializes a new instance of the <see cref="TracerSdk"/> class.
/// </summary>
/// <param name="spanProcessor">Span processor.</param>
/// <param name="sampler">Sampler to use.</param>
@ -86,8 +86,15 @@ namespace OpenTelemetry.Trace
parent = this.CurrentSpan;
}
return SpanSdk.CreateFromParentSpan(operationName, parent, kind, options, this.sampler, this.tracerConfiguration,
this.spanProcessor, this.LibraryResource);
return SpanSdk.CreateFromParentSpan(
operationName,
parent,
kind,
options,
this.sampler,
this.tracerConfiguration,
this.spanProcessor,
this.LibraryResource);
}
/// <inheritdoc/>
@ -95,12 +102,25 @@ namespace OpenTelemetry.Trace
{
if (parent.IsValid)
{
return SpanSdk.CreateFromParentContext(operationName, parent, kind, options, this.sampler, this.tracerConfiguration,
this.spanProcessor, this.LibraryResource);
return SpanSdk.CreateFromParentContext(
operationName,
parent,
kind,
options,
this.sampler,
this.tracerConfiguration,
this.spanProcessor,
this.LibraryResource);
}
return SpanSdk.CreateRoot(operationName, kind, options, this.sampler, this.tracerConfiguration,
this.spanProcessor, this.LibraryResource);
return SpanSdk.CreateRoot(
operationName,
kind,
options,
this.sampler,
this.tracerConfiguration,
this.spanProcessor,
this.LibraryResource);
}
/// <inheritdoc/>