Skip to content

Commit

Permalink
Merge branch 'main' into update-metric-instrument-regex
Browse files Browse the repository at this point in the history
  • Loading branch information
reyang authored Sep 26, 2023
2 parents 86434a1 + 48b4a8c commit 19fdf67
Show file tree
Hide file tree
Showing 46 changed files with 515 additions and 403 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
abstract OpenTelemetry.Logs.Logger.EmitLog(in OpenTelemetry.Logs.LogRecordData data, in OpenTelemetry.Logs.LogRecordAttributeList attributes) -> void
abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation<TInstrumentation>(System.Func<TInstrumentation!>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation<TInstrumentation>(System.Func<TInstrumentation>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
OpenTelemetry.Logs.IDeferredLoggerProviderBuilder
OpenTelemetry.Logs.IDeferredLoggerProviderBuilder.Configure(System.Action<System.IServiceProvider!, OpenTelemetry.Logs.LoggerProviderBuilder!>! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder!
OpenTelemetry.Logs.Logger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
abstract OpenTelemetry.Logs.Logger.EmitLog(in OpenTelemetry.Logs.LogRecordData data, in OpenTelemetry.Logs.LogRecordAttributeList attributes) -> void
abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation<TInstrumentation>(System.Func<TInstrumentation!>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation<TInstrumentation>(System.Func<TInstrumentation>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
OpenTelemetry.Logs.IDeferredLoggerProviderBuilder
OpenTelemetry.Logs.IDeferredLoggerProviderBuilder.Configure(System.Action<System.IServiceProvider!, OpenTelemetry.Logs.LoggerProviderBuilder!>! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder!
OpenTelemetry.Logs.Logger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
abstract OpenTelemetry.Logs.Logger.EmitLog(in OpenTelemetry.Logs.LogRecordData data, in OpenTelemetry.Logs.LogRecordAttributeList attributes) -> void
abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation<TInstrumentation>(System.Func<TInstrumentation!>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation<TInstrumentation>(System.Func<TInstrumentation>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
OpenTelemetry.Logs.IDeferredLoggerProviderBuilder
OpenTelemetry.Logs.IDeferredLoggerProviderBuilder.Configure(System.Action<System.IServiceProvider!, OpenTelemetry.Logs.LoggerProviderBuilder!>! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder!
OpenTelemetry.Logs.Logger
Expand Down
108 changes: 54 additions & 54 deletions src/OpenTelemetry.Api/.publicApi/Stable/net462/PublicAPI.Shipped.txt

Large diffs are not rendered by default.

108 changes: 54 additions & 54 deletions src/OpenTelemetry.Api/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/OpenTelemetry.Api/ActivityContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

using System.Diagnostics;

// The ActivityContext class is in the System.Diagnostics namespace.
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry.Api/BaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

namespace OpenTelemetry;

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry.Api/Internal/OpenTelemetryApiEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

using System.Diagnostics.Tracing;

namespace OpenTelemetry.Internal;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ protected LoggerProviderBuilder()
/// <returns>Returns <see cref="LoggerProviderBuilder"/> for chaining.</returns>
public abstract LoggerProviderBuilder AddInstrumentation<TInstrumentation>(
Func<TInstrumentation> instrumentationFactory)
where TInstrumentation : class;
where TInstrumentation : class?;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

namespace OpenTelemetry.Metrics;

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry.Api/Metrics/MeterProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

namespace OpenTelemetry.Metrics;

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/OpenTelemetry.Api/Metrics/MeterProviderBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

namespace OpenTelemetry.Metrics;

/// <summary>
Expand All @@ -36,7 +38,7 @@ protected MeterProviderBuilder()
/// <returns>Returns <see cref="MeterProviderBuilder"/> for chaining.</returns>
public abstract MeterProviderBuilder AddInstrumentation<TInstrumentation>(
Func<TInstrumentation> instrumentationFactory)
where TInstrumentation : class;
where TInstrumentation : class?;

/// <summary>
/// Adds given Meter names to the list of subscribed meters.
Expand Down
22 changes: 12 additions & 10 deletions src/OpenTelemetry.Api/Trace/ActivityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

using System.Diagnostics;
using System.Runtime.CompilerServices;
using OpenTelemetry.Internal;
Expand Down Expand Up @@ -41,10 +43,11 @@ public static class ActivityExtensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SetStatus(this Activity activity, Status status)
{
Debug.Assert(activity != null, "Activity should not be null");

activity.SetTag(SpanAttributeConstants.StatusCodeKey, StatusHelper.GetTagValueForStatusCode(status.StatusCode));
activity.SetTag(SpanAttributeConstants.StatusDescriptionKey, status.Description);
if (activity != null)
{
activity.SetTag(SpanAttributeConstants.StatusCodeKey, StatusHelper.GetTagValueForStatusCode(status.StatusCode));
activity.SetTag(SpanAttributeConstants.StatusDescriptionKey, status.Description);
}
}

/// <summary>
Expand All @@ -57,7 +60,8 @@ public static void SetStatus(this Activity activity, Status status)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Status GetStatus(this Activity activity)
{
if (!activity.TryGetStatus(out StatusCode statusCode, out string statusDescription))
if (activity == null
|| !activity.TryGetStatus(out var statusCode, out var statusDescription))
{
return Status.Unset;
}
Expand All @@ -71,10 +75,8 @@ public static Status GetStatus(this Activity activity)
/// <param name="activity">Activity instance.</param>
/// <param name="ex">Exception to be recorded.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RecordException(this Activity activity, Exception ex)
{
activity?.RecordException(ex, default);
}
public static void RecordException(this Activity activity, Exception? ex)
=> RecordException(activity, ex, default);

/// <summary>
/// Adds an activity event containing information from the specified exception and additional tags.
Expand All @@ -83,7 +85,7 @@ public static void RecordException(this Activity activity, Exception ex)
/// <param name="ex">Exception to be recorded.</param>
/// <param name="tags">Additional tags to record on the event.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RecordException(this Activity activity, Exception ex, in TagList tags)
public static void RecordException(this Activity activity, Exception? ex, in TagList tags)
{
if (ex == null || activity == null)
{
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry.Api/Trace/IDeferredTracerProviderBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

namespace OpenTelemetry.Trace;

/// <summary>
Expand Down
42 changes: 15 additions & 27 deletions src/OpenTelemetry.Api/Trace/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

using System.Diagnostics;

namespace OpenTelemetry.Trace;
Expand All @@ -30,16 +32,16 @@ namespace OpenTelemetry.Trace;
/// </summary>
/// <param name="spanContext">Span context of a linked span.</param>
public Link(in SpanContext spanContext)
: this(in spanContext, attributes: null)
{
this.ActivityLink = new ActivityLink(spanContext.ActivityContext);
}

/// <summary>
/// Initializes a new instance of the <see cref="Link"/> struct.
/// </summary>
/// <param name="spanContext">Span context of a linked span.</param>
/// <param name="attributes">Link attributes.</param>
public Link(in SpanContext spanContext, SpanAttributes attributes)
public Link(in SpanContext spanContext, SpanAttributes? attributes)
{
this.ActivityLink = new ActivityLink(spanContext.ActivityContext, attributes?.Attributes);
}
Expand All @@ -48,53 +50,39 @@ public Link(in SpanContext spanContext, SpanAttributes attributes)
/// Gets the span context of a linked span.
/// </summary>
public SpanContext Context
{
get
{
return new SpanContext(this.ActivityLink.Context);
}
}
=> new(this.ActivityLink.Context);

/// <summary>
/// Gets the collection of attributes associated with the link.
/// </summary>
public IEnumerable<KeyValuePair<string, object>> Attributes
{
get
{
return this.ActivityLink.Tags;
}
}
public IEnumerable<KeyValuePair<string, object?>>? Attributes
=> this.ActivityLink.Tags;

/// <summary>
/// Compare two <see cref="Link"/> for equality.
/// </summary>
/// <param name="link1">First link to compare.</param>
/// <param name="link2">Second link to compare.</param>
public static bool operator ==(Link link1, Link link2) => link1.Equals(link2);
public static bool operator ==(Link link1, Link link2)
=> link1.Equals(link2);

/// <summary>
/// Compare two <see cref="Link"/> for not equality.
/// </summary>
/// <param name="link1">First link to compare.</param>
/// <param name="link2">Second link to compare.</param>
public static bool operator !=(Link link1, Link link2) => !link1.Equals(link2);
public static bool operator !=(Link link1, Link link2)
=> !link1.Equals(link2);

/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is Link link) && this.ActivityLink.Equals(link.ActivityLink);
}
public override bool Equals(object? obj)
=> obj is Link link && this.ActivityLink.Equals(link.ActivityLink);

/// <inheritdoc />
public override int GetHashCode()
{
return this.ActivityLink.GetHashCode();
}
=> this.ActivityLink.GetHashCode();

/// <inheritdoc/>
public bool Equals(Link other)
{
return this.ActivityLink.Equals(other.ActivityLink);
}
=> this.ActivityLink.Equals(other.ActivityLink);
}
18 changes: 10 additions & 8 deletions src/OpenTelemetry.Api/Trace/SpanAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
// </copyright>

#nullable enable

using System.Diagnostics;
using OpenTelemetry.Internal;

Expand All @@ -37,12 +39,12 @@ public SpanAttributes()
/// Initializes a new instance of the <see cref="SpanAttributes"/> class.
/// </summary>
/// <param name="attributes">Initial attributes to store in the collection.</param>
public SpanAttributes(IEnumerable<KeyValuePair<string, object>> attributes)
public SpanAttributes(IEnumerable<KeyValuePair<string, object?>> attributes)
: this()
{
Guard.ThrowIfNull(attributes);

foreach (KeyValuePair<string, object> kvp in attributes)
foreach (KeyValuePair<string, object?> kvp in attributes)
{
this.AddInternal(kvp.Key, kvp.Value);
}
Expand All @@ -65,7 +67,7 @@ public void Add(string key, long value)
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="value">Entry value.</param>
public void Add(string key, string value)
public void Add(string key, string? value)
{
this.AddInternal(key, value);
}
Expand Down Expand Up @@ -95,7 +97,7 @@ public void Add(string key, double value)
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, long[] values)
public void Add(string key, long[]? values)
{
this.AddInternal(key, values);
}
Expand All @@ -105,7 +107,7 @@ public void Add(string key, long[] values)
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, string[] values)
public void Add(string key, string?[]? values)
{
this.AddInternal(key, values);
}
Expand All @@ -115,7 +117,7 @@ public void Add(string key, string[] values)
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, bool[] values)
public void Add(string key, bool[]? values)
{
this.AddInternal(key, values);
}
Expand All @@ -125,12 +127,12 @@ public void Add(string key, bool[] values)
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, double[] values)
public void Add(string key, double[]? values)
{
this.AddInternal(key, values);
}

private void AddInternal(string key, object value)
private void AddInternal(string key, object? value)
{
Guard.ThrowIfNull(key);

Expand Down
Loading

0 comments on commit 19fdf67

Please sign in to comment.