Skip to content

Commit

Permalink
Updated src/OpenTelemetry and test/OpenTelemetry.Tests files to use f… (
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-lt authored Jul 13, 2023
1 parent 3f5c774 commit 18f7978
Show file tree
Hide file tree
Showing 150 changed files with 19,070 additions and 19,218 deletions.
157 changes: 78 additions & 79 deletions src/OpenTelemetry/BaseExportProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,109 +18,108 @@

using OpenTelemetry.Internal;

namespace OpenTelemetry
namespace OpenTelemetry;

/// <summary>
/// Type of Export Processor to be used.
/// </summary>
public enum ExportProcessorType
{
/// <summary>
/// Type of Export Processor to be used.
/// Use SimpleExportProcessor.
/// Refer to the <a href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#simple-processor">
/// specification</a> for more information.
/// </summary>
public enum ExportProcessorType
{
/// <summary>
/// Use SimpleExportProcessor.
/// Refer to the <a href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#simple-processor">
/// specification</a> for more information.
/// </summary>
Simple,

/// <summary>
/// Use BatchExportProcessor.
/// Refer to <a href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#batching-processor">
/// specification</a> for more information.
/// </summary>
Batch,
}
Simple,

/// <summary>
/// Use BatchExportProcessor.
/// Refer to <a href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#batching-processor">
/// specification</a> for more information.
/// </summary>
Batch,
}

/// <summary>
/// Implements processor that exports telemetry objects.
/// </summary>
/// <typeparam name="T">The type of telemetry object to be exported.</typeparam>
public abstract class BaseExportProcessor<T> : BaseProcessor<T>
where T : class
{
protected readonly BaseExporter<T> exporter;
private readonly string friendlyTypeName;
private bool disposed;

/// <summary>
/// Implements processor that exports telemetry objects.
/// Initializes a new instance of the <see cref="BaseExportProcessor{T}"/> class.
/// </summary>
/// <typeparam name="T">The type of telemetry object to be exported.</typeparam>
public abstract class BaseExportProcessor<T> : BaseProcessor<T>
where T : class
/// <param name="exporter">Exporter instance.</param>
protected BaseExportProcessor(BaseExporter<T> exporter)
{
protected readonly BaseExporter<T> exporter;
private readonly string friendlyTypeName;
private bool disposed;

/// <summary>
/// Initializes a new instance of the <see cref="BaseExportProcessor{T}"/> class.
/// </summary>
/// <param name="exporter">Exporter instance.</param>
protected BaseExportProcessor(BaseExporter<T> exporter)
{
Guard.ThrowIfNull(exporter);
Guard.ThrowIfNull(exporter);

this.friendlyTypeName = $"{this.GetType().Name}{{{exporter.GetType().Name}}}";
this.exporter = exporter;
}
this.friendlyTypeName = $"{this.GetType().Name}{{{exporter.GetType().Name}}}";
this.exporter = exporter;
}

internal BaseExporter<T> Exporter => this.exporter;
internal BaseExporter<T> Exporter => this.exporter;

/// <inheritdoc />
public override string ToString()
=> this.friendlyTypeName;
/// <inheritdoc />
public override string ToString()
=> this.friendlyTypeName;

/// <inheritdoc />
public sealed override void OnStart(T data)
{
}
/// <inheritdoc />
public sealed override void OnStart(T data)
{
}

public override void OnEnd(T data)
{
this.OnExport(data);
}
public override void OnEnd(T data)
{
this.OnExport(data);
}

internal override void SetParentProvider(BaseProvider parentProvider)
{
base.SetParentProvider(parentProvider);
internal override void SetParentProvider(BaseProvider parentProvider)
{
base.SetParentProvider(parentProvider);

this.exporter.ParentProvider = parentProvider;
}
this.exporter.ParentProvider = parentProvider;
}

protected abstract void OnExport(T data);
protected abstract void OnExport(T data);

/// <inheritdoc />
protected override bool OnForceFlush(int timeoutMilliseconds)
{
return this.exporter.ForceFlush(timeoutMilliseconds);
}
/// <inheritdoc />
protected override bool OnForceFlush(int timeoutMilliseconds)
{
return this.exporter.ForceFlush(timeoutMilliseconds);
}

/// <inheritdoc />
protected override bool OnShutdown(int timeoutMilliseconds)
{
return this.exporter.Shutdown(timeoutMilliseconds);
}
/// <inheritdoc />
protected override bool OnShutdown(int timeoutMilliseconds)
{
return this.exporter.Shutdown(timeoutMilliseconds);
}

/// <inheritdoc/>
protected override void Dispose(bool disposing)
/// <inheritdoc/>
protected override void Dispose(bool disposing)
{
if (!this.disposed)
{
if (!this.disposed)
if (disposing)
{
if (disposing)
try
{
try
{
this.exporter.Dispose();
}
catch (Exception ex)
{
OpenTelemetrySdkEventSource.Log.SpanProcessorException(nameof(this.Dispose), ex);
}
this.exporter.Dispose();
}
catch (Exception ex)
{
OpenTelemetrySdkEventSource.Log.SpanProcessorException(nameof(this.Dispose), ex);
}

this.disposed = true;
}

base.Dispose(disposing);
this.disposed = true;
}

base.Dispose(disposing);
}
}
Loading

0 comments on commit 18f7978

Please sign in to comment.