Skip to content

Commit

Permalink
Move JSON serialization to projects that need it
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwest committed May 25, 2022
1 parent 673ade0 commit 74df0df
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
// </copyright>

using System;
using OpenTelemetry.Internal;

namespace OpenTelemetry.Exporter.Jaeger.Implementation
Expand Down Expand Up @@ -45,5 +46,8 @@ protected override JaegerTag TransformStringTag(string key, string value)
{
return new JaegerTag(key, JaegerTagType.STRING, vStr: value);
}

protected override JaegerTag TransformArrayTag(string key, Array array)
=> this.TransformStringTag(key, System.Text.Json.JsonSerializer.Serialize(array));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
// </copyright>

using System;
using OpenTelemetry.Internal;

namespace OpenTelemetry.Exporter.Zipkin.Implementation
Expand All @@ -33,5 +34,8 @@ private ZipkinTagTransformer()
protected override string TransformBooleanTag(string key, bool value) => value ? "true" : "false";

protected override string TransformStringTag(string key, string value) => value;

protected override string TransformArrayTag(string key, Array array)
=> this.TransformStringTag(key, System.Text.Json.JsonSerializer.Serialize(array));
}
}
3 changes: 1 addition & 2 deletions src/OpenTelemetry/Internal/TagTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public bool TryTransformTag(KeyValuePair<string, object> tag, out T result)

protected abstract T TransformStringTag(string key, string value);

protected virtual T TransformArrayTag(string key, Array array) =>
this.TransformStringTag(key, System.Text.Json.JsonSerializer.Serialize(array));
protected abstract T TransformArrayTag(string key, Array array);

private T TransformArrayTagInternal(string key, Array array)
{
Expand Down
7 changes: 0 additions & 7 deletions src/OpenTelemetry/OpenTelemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
<RunApiCompat>false</RunApiCompat>
</PropertyGroup>

<!--These files are shared and included by other projects.
Excluding them from compilation because they introduce an unnecessary dependency on System.Text.Json. -->
<ItemGroup>
<Compile Remove="Internal\TagAndValueTransformer.cs" />
<Compile Remove="Internal\TagTransformer.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutablePkgVer)" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(SystemReflectionEmitLightweightPkgVer)" />
Expand Down

0 comments on commit 74df0df

Please sign in to comment.