Skip to content

Commit

Permalink
Update SqlInstrumentation ActivitySource name (#3435)
Browse files Browse the repository at this point in the history
* Update SqlInstrumentation ActivitySource
  • Loading branch information
utpilla authored Jul 11, 2022
1 parent be588bd commit be6ab71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Update the `ActivitySource.Name` from "OpenTelemetry.SqlClient" to
"OpenTelemetry.Instrumentation.SqlClient".
([#3435](https://github.com/open-telemetry/opentelemetry-dotnet/issues/3435))

## 1.0.0-rc9.4

Released 2022-Jun-03
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using OpenTelemetry.Trace;

namespace OpenTelemetry.Instrumentation.SqlClient.Implementation
Expand All @@ -26,19 +27,17 @@ namespace OpenTelemetry.Instrumentation.SqlClient.Implementation
/// </summary>
internal class SqlActivitySourceHelper
{
public const string ActivitySourceName = "OpenTelemetry.SqlClient";
public const string ActivityName = ActivitySourceName + ".Execute";

public const string MicrosoftSqlServerDatabaseSystemName = "mssql";

public static readonly AssemblyName AssemblyName = typeof(SqlActivitySourceHelper).Assembly.GetName();
public static readonly string ActivitySourceName = AssemblyName.Name;
public static readonly Version Version = AssemblyName.Version;
public static readonly ActivitySource ActivitySource = new(ActivitySourceName, Version.ToString());
public static readonly string ActivityName = ActivitySourceName + ".Execute";

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

private static readonly Version Version = typeof(SqlActivitySourceHelper).Assembly.GetName().Version;
#pragma warning disable SA1202 // Elements should be ordered by access <- In this case, Version MUST come before ActivitySource otherwise null ref exception is thrown.
internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, Version.ToString());
#pragma warning restore SA1202 // Elements should be ordered by access
}
}

0 comments on commit be6ab71

Please sign in to comment.