Skip to content

Commit

Permalink
[shared] Remove TagTransformer and improve TagWriter (#5602)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch authored May 14, 2024
1 parent a578ed3 commit cf8ca09
Show file tree
Hide file tree
Showing 14 changed files with 416 additions and 468 deletions.
2 changes: 0 additions & 2 deletions OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{A49299
src\Shared\SemanticConventions.cs = src\Shared\SemanticConventions.cs
src\Shared\SpanAttributeConstants.cs = src\Shared\SpanAttributeConstants.cs
src\Shared\StatusHelper.cs = src\Shared\StatusHelper.cs
src\Shared\TagTransformer.cs = src\Shared\TagTransformer.cs
src\Shared\TagTransformerJsonHelper.cs = src\Shared\TagTransformerJsonHelper.cs
src\Shared\ThreadSafeRandom.cs = src\Shared\ThreadSafeRandom.cs
EndProjectSection
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ protected override void WriteBooleanTag(ref ConsoleTag consoleTag, string key, b
consoleTag.Value = value ? "true" : "false";
}

protected override void WriteStringTag(ref ConsoleTag consoleTag, string key, string value)
protected override void WriteStringTag(ref ConsoleTag consoleTag, string key, ReadOnlySpan<char> value)
{
consoleTag.Key = key;
consoleTag.Value = value;
consoleTag.Value = value.ToString();
}

protected override void WriteArrayTag(ref ConsoleTag consoleTag, string key, ArraySegment<byte> arrayUtf8JsonBytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected override void WriteBooleanTag(ref RepeatedField<OtlpCommon.KeyValue> t
tags.Add(new OtlpCommon.KeyValue { Key = key, Value = ToAnyValue(value) });
}

protected override void WriteStringTag(ref RepeatedField<OtlpCommon.KeyValue> tags, string key, string value)
protected override void WriteStringTag(ref RepeatedField<OtlpCommon.KeyValue> tags, string key, ReadOnlySpan<char> value)
{
tags.Add(new OtlpCommon.KeyValue { Key = key, Value = ToAnyValue(value) });
tags.Add(new OtlpCommon.KeyValue { Key = key, Value = ToAnyValue(value.ToString()) });
}

protected override void WriteArrayTag(ref RepeatedField<OtlpCommon.KeyValue> tags, string key, ref OtlpCommon.ArrayValue value)
Expand Down Expand Up @@ -95,9 +95,9 @@ public override void WriteBooleanValue(ref OtlpCommon.ArrayValue array, bool val
array.Values.Add(ToAnyValue(value));
}

public override void WriteStringValue(ref OtlpCommon.ArrayValue array, string value)
public override void WriteStringValue(ref OtlpCommon.ArrayValue array, ReadOnlySpan<char> value)
{
array.Values.Add(ToAnyValue(value));
array.Values.Add(ToAnyValue(value.ToString()));
}

public override void EndWriteArray(ref OtlpCommon.ArrayValue array)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected override void WriteFloatingPointTag(ref Utf8JsonWriter writer, string
protected override void WriteBooleanTag(ref Utf8JsonWriter writer, string key, bool value)
=> writer.WriteString(key, value ? "true" : "false");

protected override void WriteStringTag(ref Utf8JsonWriter writer, string key, string value)
protected override void WriteStringTag(ref Utf8JsonWriter writer, string key, ReadOnlySpan<char> value)
=> writer.WriteString(key, value);

protected override void WriteArrayTag(ref Utf8JsonWriter writer, string key, ArraySegment<byte> arrayUtf8JsonBytes)
Expand Down
208 changes: 0 additions & 208 deletions src/Shared/TagTransformer.cs

This file was deleted.

53 changes: 0 additions & 53 deletions src/Shared/TagTransformerJsonHelper.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Shared/TagWriter/ArrayTagWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal abstract class ArrayTagWriter<TArrayState>

public abstract void WriteBooleanValue(ref TArrayState state, bool value);

public abstract void WriteStringValue(ref TArrayState state, string value);
public abstract void WriteStringValue(ref TArrayState state, ReadOnlySpan<char> value);

public abstract void EndWriteArray(ref TArrayState state);
}
2 changes: 1 addition & 1 deletion src/Shared/TagWriter/JsonStringArrayTagWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override void WriteNullValue(ref JsonArrayTagWriterState state)
state.Writer.WriteNullValue();
}

public override void WriteStringValue(ref JsonArrayTagWriterState state, string value)
public override void WriteStringValue(ref JsonArrayTagWriterState state, ReadOnlySpan<char> value)
{
state.Writer.WriteStringValue(value);
}
Expand Down
Loading

0 comments on commit cf8ca09

Please sign in to comment.