Skip to content

Commit

Permalink
Fix activity (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
chad122 authored Apr 7, 2023
1 parent dc9f790 commit dfcc422
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ClickHouse.Client/Diagnostic/ActivitySourceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ internal static class ActivitySourceHelper
return activity;
}

internal static void SetConnectionTags(this Activity? activity, string connectionString, string sql)
internal static void SetConnectionTags(this Activity? activity, string connectionString, string? sql)
{
var builder = new ClickHouseConnectionStringBuilder() { ConnectionString = connectionString };
activity?.SetTag(Tag_DbConnectionString, connectionString);
activity?.SetTag(Tag_DbName, builder.Database);
activity?.SetTag(Tag_User, builder.Username);
activity?.SetTag(Tag_Service, new UriBuilder(builder.Protocol, builder.Host, builder.Port).Uri.ToString());
activity?.SetTag(Tag_DbStatement, sql.Length > StatementMaxLen ? sql.Substring(0, StatementMaxLen) : sql);
activity?.SetTag(Tag_DbStatement, sql is not null && sql.Length > StatementMaxLen ? sql.Substring(0, StatementMaxLen) : sql);
}

internal static void SetSuccess(this Activity? activity)
Expand All @@ -53,7 +53,7 @@ internal static void SetSuccess(this Activity? activity)
activity?.Stop();
}

internal static void SetException(this Activity? activity, Exception exception)
internal static void SetException(this Activity? activity, Exception? exception)
{
var description = exception.Message;
#if NET6_0_OR_GREATER
Expand All @@ -63,8 +63,8 @@ internal static void SetException(this Activity? activity, Exception exception)
activity?.SetTag("otel.status_description", description);
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection
{
{ "exception.type", exception.GetType().FullName },
{ "exception.message", exception.Message },
{ "exception.type", exception?.GetType().FullName },
{ "exception.message", exception?.Message },
}));
activity?.Stop();
}
Expand Down

0 comments on commit dfcc422

Please sign in to comment.