Skip to content

Commit

Permalink
Merge branch 'main' into issue/AWS-Lambda-SQS-SNS-support
Browse files Browse the repository at this point in the history
  • Loading branch information
rypdal committed Mar 21, 2023
2 parents 6996859 + b06a6f2 commit c98d9e9
Show file tree
Hide file tree
Showing 31 changed files with 1,715 additions and 766 deletions.
10 changes: 6 additions & 4 deletions src/OpenTelemetry.Contrib.Shared/Api/StatusHelper.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;
using System.Runtime.CompilerServices;
using OpenTelemetry.Trace;
Expand All @@ -27,7 +29,7 @@ internal static class StatusHelper
public const string ErrorStatusCodeTagValue = "ERROR";

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string GetTagValueForStatusCode(StatusCode statusCode)
public static string? GetTagValueForStatusCode(StatusCode statusCode)
{
return statusCode switch
{
Expand All @@ -53,9 +55,9 @@ public static string GetTagValueForStatusCode(StatusCode statusCode)
* first because assumption is most spans will be
* Unset, then Error. Ok is not set by the SDK.
*/
string _ when UnsetStatusCodeTagValue.Equals(statusCodeTagValue, StringComparison.OrdinalIgnoreCase) => StatusCode.Unset,
string _ when ErrorStatusCodeTagValue.Equals(statusCodeTagValue, StringComparison.OrdinalIgnoreCase) => StatusCode.Error,
string _ when OkStatusCodeTagValue.Equals(statusCodeTagValue, StringComparison.OrdinalIgnoreCase) => StatusCode.Ok,
not null when UnsetStatusCodeTagValue.Equals(statusCodeTagValue, StringComparison.OrdinalIgnoreCase) => StatusCode.Unset,
not null when ErrorStatusCodeTagValue.Equals(statusCodeTagValue, StringComparison.OrdinalIgnoreCase) => StatusCode.Error,
not null when OkStatusCodeTagValue.Equals(statusCodeTagValue, StringComparison.OrdinalIgnoreCase) => StatusCode.Ok,
_ => (StatusCode?)null,
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ OpenTelemetry.Instrumentation.MySqlData.MySqlDataInstrumentationOptions.RecordEx
OpenTelemetry.Instrumentation.MySqlData.MySqlDataInstrumentationOptions.SetDbStatement.get -> bool
OpenTelemetry.Instrumentation.MySqlData.MySqlDataInstrumentationOptions.SetDbStatement.set -> void
OpenTelemetry.Trace.TracerProviderBuilderExtensions
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddMySqlDataInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddMySqlDataInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.MySqlData.MySqlDataInstrumentationOptions> configure) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddMySqlDataInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddMySqlDataInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action<OpenTelemetry.Instrumentation.MySqlData.MySqlDataInstrumentationOptions!>? configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ internal class MySqlActivitySourceHelper
public static readonly string ActivitySourceName = AssemblyName.Name;
public static readonly string ActivityName = ActivitySourceName + ".Execute";

public static readonly IEnumerable<KeyValuePair<string, object>> CreationTags = new[]
public static readonly IEnumerable<KeyValuePair<string, object?>> CreationTags = new[]
{
new KeyValuePair<string, object>(SemanticConventions.AttributeDbSystem, MysqlDatabaseSystemName),
new KeyValuePair<string, object?>(SemanticConventions.AttributeDbSystem, MysqlDatabaseSystemName),
};

private static readonly Version Version = typeof(MySqlActivitySourceHelper).Assembly.GetName().Version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ internal class MySqlDataInstrumentation : DefaultTraceListener

private readonly MySqlDataInstrumentationOptions options;

private readonly Func<string, MySqlConnectionStringBuilder> builderFactory;
private readonly Func<string, MySqlConnectionStringBuilder>? builderFactory;

public MySqlDataInstrumentation(MySqlDataInstrumentationOptions options = null)
public MySqlDataInstrumentation(MySqlDataInstrumentationOptions? options = null)
{
this.options = options ?? new MySqlDataInstrumentationOptions();
MySqlTrace.Listeners.Clear();
Expand Down Expand Up @@ -186,7 +186,7 @@ private void BeforeExecuteCommand(MySqlDataTraceCommand command)
var activity = MySqlActivitySourceHelper.ActivitySource.StartActivity(
MySqlActivitySourceHelper.ActivityName,
ActivityKind.Client,
Activity.Current?.Context ?? default(ActivityContext),
Activity.Current?.Context ?? default,
MySqlActivitySourceHelper.CreationTags);
if (activity == null)
{
Expand Down Expand Up @@ -262,7 +262,7 @@ private void ErrorExecuteCommand(Exception exception)
}
}

private MySqlDataTraceCommand GetCommand(object driverIdObj, object cmd)
private MySqlDataTraceCommand GetCommand(object driverIdObj, object? cmd)
{
var command = new MySqlDataTraceCommand();
if (this.dbConn.TryGetValue((long)driverIdObj, out var database))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace OpenTelemetry.Instrumentation.MySqlData;
/// </summary>
internal class MySqlDataTraceCommand
{
public MySqlConnectionStringBuilder ConnectionStringBuilder { get; set; }
public MySqlConnectionStringBuilder? ConnectionStringBuilder { get; set; }

public string SqlText { get; set; }
public string SqlText { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>OpenTelemetry instrumentation for MySql.Data</Description>
<PackageTags>$(PackageTags);distributed-tracing;MySql.Data</PackageTags>
<MinVerTagPrefix>Instrumentation.MySqlData-</MinVerTagPrefix>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>OpenTelemetry instrumentation for MySql.Data</Description>
<PackageTags>$(PackageTags);distributed-tracing;MySql.Data</PackageTags>
<MinVerTagPrefix>Instrumentation.MySqlData-</MinVerTagPrefix>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MySql.Data" Version="6.10.7" />
<PackageReference Include="OpenTelemetry.Api" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MySql.Data" Version="6.10.7" />
<PackageReference Include="OpenTelemetry.Api" Version="$(OpenTelemetryCoreLatestVersion)" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Contrib.Shared\Api\SemanticConventions.cs" Link="Includes\SemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Contrib.Shared\Api\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Contrib.Shared\Api\StatusHelper.cs" Link="Includes\StatusHelper.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Internal\Guard.cs" Link="Includes\Guard.cs" />
</ItemGroup>
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Contrib.Shared\Api\SemanticConventions.cs" Link="Includes\SemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Contrib.Shared\Api\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Contrib.Shared\Api\StatusHelper.cs" Link="Includes\StatusHelper.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Internal\Guard.cs" Link="Includes\Guard.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static TracerProviderBuilder AddMySqlDataInstrumentation(this TracerProvi
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
public static TracerProviderBuilder AddMySqlDataInstrumentation(
this TracerProviderBuilder builder,
Action<MySqlDataInstrumentationOptions> configure)
Action<MySqlDataInstrumentationOptions>? configure)
{
Guard.ThrowIfNull(builder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">net6.0;$(TargetFrameworks)</TargetFrameworks> <!-- Added just to get proper nullable analysis in IDE -->
<Description>OpenTelemetry Persistent Storage Abstractions</Description>
<MinVerTagPrefix>Extensions.PersistentStorage.Abstractions-</MinVerTagPrefix>
<NoWarn>$(NoWarn),CA1031</NoWarn>
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn),1591</NoWarn>
<Nullable>enable</Nullable>
<EnableAnalysis>true</EnableAnalysis>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
OpenTelemetry.PersistentStorage.FileSystem.FileBlob
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FileBlob(string fullPath) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FullPath.get -> string
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FileBlob(string! fullPath) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FullPath.get -> string!
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.Dispose() -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.FileBlobProvider(string path, long maxSizeInBytes = 52428800, int maintenancePeriodInMilliseconds = 120000, long retentionPeriodInMilliseconds = 172800000, int writeTimeoutInMilliseconds = 60000) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.FileBlobProvider(string! path, long maxSizeInBytes = 52428800, int maintenancePeriodInMilliseconds = 120000, long retentionPeriodInMilliseconds = 172800000, int writeTimeoutInMilliseconds = 60000) -> void
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryDelete() -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryLease(int leasePeriodMilliseconds) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryRead(out byte[] buffer) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryWrite(byte[] buffer, int leasePeriodMilliseconds = 0) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnGetBlobs() -> System.Collections.Generic.IEnumerable<OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob>
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[] buffer, int leasePeriodMilliseconds, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[] buffer, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryGetBlob(out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryRead(out byte[]? buffer) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryWrite(byte[]! buffer, int leasePeriodMilliseconds = 0) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnGetBlobs() -> System.Collections.Generic.IEnumerable<OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob!>!
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[]! buffer, int leasePeriodMilliseconds, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[]! buffer, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryGetBlob(out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
virtual OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.Dispose(bool disposing) -> void
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
OpenTelemetry.PersistentStorage.FileSystem.FileBlob
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FileBlob(string fullPath) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FullPath.get -> string
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FileBlob(string! fullPath) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FullPath.get -> string!
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.Dispose() -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.FileBlobProvider(string path, long maxSizeInBytes = 52428800, int maintenancePeriodInMilliseconds = 120000, long retentionPeriodInMilliseconds = 172800000, int writeTimeoutInMilliseconds = 60000) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.FileBlobProvider(string! path, long maxSizeInBytes = 52428800, int maintenancePeriodInMilliseconds = 120000, long retentionPeriodInMilliseconds = 172800000, int writeTimeoutInMilliseconds = 60000) -> void
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryDelete() -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryLease(int leasePeriodMilliseconds) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryRead(out byte[] buffer) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryWrite(byte[] buffer, int leasePeriodMilliseconds = 0) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnGetBlobs() -> System.Collections.Generic.IEnumerable<OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob>
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[] buffer, int leasePeriodMilliseconds, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[] buffer, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryGetBlob(out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryRead(out byte[]? buffer) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryWrite(byte[]! buffer, int leasePeriodMilliseconds = 0) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnGetBlobs() -> System.Collections.Generic.IEnumerable<OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob!>!
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[]! buffer, int leasePeriodMilliseconds, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[]! buffer, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryGetBlob(out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
virtual OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.Dispose(bool disposing) -> void
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
OpenTelemetry.PersistentStorage.FileSystem.FileBlob
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FileBlob(string fullPath) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FullPath.get -> string
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FileBlob(string! fullPath) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlob.FullPath.get -> string!
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.Dispose() -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.FileBlobProvider(string path, long maxSizeInBytes = 52428800, int maintenancePeriodInMilliseconds = 120000, long retentionPeriodInMilliseconds = 172800000, int writeTimeoutInMilliseconds = 60000) -> void
OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.FileBlobProvider(string! path, long maxSizeInBytes = 52428800, int maintenancePeriodInMilliseconds = 120000, long retentionPeriodInMilliseconds = 172800000, int writeTimeoutInMilliseconds = 60000) -> void
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryDelete() -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryLease(int leasePeriodMilliseconds) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryRead(out byte[] buffer) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryWrite(byte[] buffer, int leasePeriodMilliseconds = 0) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnGetBlobs() -> System.Collections.Generic.IEnumerable<OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob>
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[] buffer, int leasePeriodMilliseconds, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[] buffer, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryGetBlob(out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryRead(out byte[]? buffer) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlob.OnTryWrite(byte[]! buffer, int leasePeriodMilliseconds = 0) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnGetBlobs() -> System.Collections.Generic.IEnumerable<OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob!>!
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[]! buffer, int leasePeriodMilliseconds, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryCreateBlob(byte[]! buffer, out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
override OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.OnTryGetBlob(out OpenTelemetry.PersistentStorage.Abstractions.PersistentBlob? blob) -> bool
virtual OpenTelemetry.PersistentStorage.FileSystem.FileBlobProvider.Dispose(bool disposing) -> void
2 changes: 1 addition & 1 deletion src/OpenTelemetry.PersistentStorage.FileSystem/FileBlob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public FileBlob(string fullPath)

public string FullPath { get; private set; }

protected override bool OnTryRead([NotNullWhen(true)] out byte[] buffer)
protected override bool OnTryRead([NotNullWhen(true)] out byte[]? buffer)
{
try
{
Expand Down
Loading

0 comments on commit c98d9e9

Please sign in to comment.