Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
simaoribeiro committed Nov 7, 2023
1 parent cf88390 commit 5242704
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/KafkaFlow.Abstractions/IConsumerContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace KafkaFlow
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

Expand Down
2 changes: 0 additions & 2 deletions src/KafkaFlow.Abstractions/IProducerContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace KafkaFlow;

using System.Collections.Generic;

/// <summary>
/// Some producer metadata
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/KafkaFlow.OpenTelemetry/ActivitySourceAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace KafkaFlow.OpenTelemetry
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Conventions = SemanticConventions::OpenTelemetry.Trace.TraceSemanticConventions;

Expand All @@ -24,7 +25,7 @@ internal static class ActivitySourceAccessor
public static void SetGenericTags(Activity activity, IEnumerable<string> bootstrapServers)
{
activity?.SetTag(Conventions.AttributeMessagingSystem, MessagingSystemId);
activity?.SetTag(Conventions.AttributePeerService, string.Join(",", bootstrapServers));
activity?.SetTag(Conventions.AttributePeerService, string.Join(",", bootstrapServers ?? Enumerable.Empty<string>()));
}

public static ActivityEvent CreateExceptionEvent(Exception exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,7 @@ private static IEnumerable<string> ExtractTraceContextIntoBasicProperties(IMessa

private static void SetConsumerTags(IMessageContext context, Activity activity)
{
string messageKey = string.Empty;

try
{
messageKey = Encoding.UTF8.GetString(context.Message.Key as byte[]);
}
catch
{
// Do nothing
}
string messageKey = context.Message.Key != null ? Encoding.UTF8.GetString(context.Message.Key as byte[]) : string.Empty;

activity.SetTag(ActivitySourceAccessor.AttributeMessagingOperation, ProcessString);
activity.SetTag(AttributeMessagingSourceName, context.ConsumerContext.Topic);
Expand Down
1 change: 0 additions & 1 deletion src/KafkaFlow/Consumers/ConsumerContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace KafkaFlow.Consumers
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Confluent.Kafka;
Expand Down
6 changes: 1 addition & 5 deletions src/KafkaFlow/Producers/ProducerContext.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
namespace KafkaFlow.Producers
{
using System.Collections.Generic;

internal class ProducerContext : IProducerContext
{
public ProducerContext(
string topic,
IDependencyResolver producerDependencyResolver)
public ProducerContext(string topic, IDependencyResolver producerDependencyResolver)
{
this.Topic = topic;
this.DependencyResolver = producerDependencyResolver;
Expand Down

0 comments on commit 5242704

Please sign in to comment.