Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ExporterGeneva]Remove ConvertToJson option #514

Merged
merged 27 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7fc318c
Fix issue- #3149
xyq175com Jul 2, 2022
1e8bb47
Merge pull request #1 from fidelity/Fix-issue-3149
xyq175com Jul 5, 2022
c560b8a
Fix issue- #3149
xyq175com Jul 2, 2022
ae0118c
Merge branch 'main' of https://github.com/fidelity/opentelemetry-dotn…
xyq175com Jul 19, 2022
7c49525
Update GenevaLogExporter.cs
xyq175com Jul 19, 2022
99243f1
Update GenevaTraceExporter.cs
xyq175com Jul 19, 2022
83b700e
Update ServerTracingInterceptor.cs
xyq175com Jul 19, 2022
f1da0b2
Update GenevaLogExporter.cs
xyq175com Jul 21, 2022
0bccfef
Update GenevaLogExporter.cs
xyq175com Jul 21, 2022
bec3cab
Update GenevaTraceExporter.cs
xyq175com Jul 21, 2022
bd56c87
Update GenevaTraceExporter.cs
xyq175com Jul 21, 2022
d40a7ba
Update GenevaLogExporter.cs
xyq175com Jul 21, 2022
a6f1b33
Merge branch 'open-telemetry:main' into fix_issue_395
xyq175com Jul 26, 2022
c0ca3b7
Update GenevaExporterOptions.cs
xyq175com Jul 26, 2022
dc57b4b
Update GenevaTraceExporter.cs
xyq175com Jul 26, 2022
1923bc0
Update GenevaLogExporter.cs
xyq175com Jul 26, 2022
bad6050
Update GenevaExporterOptions.cs
xyq175com Jul 26, 2022
f720a87
Update GenevaExporterOptions.cs
xyq175com Jul 26, 2022
dee3d27
Update GenevaExporterOptions.cs
xyq175com Jul 26, 2022
5b35e23
Update GenevaExporterOptions.cs
xyq175com Jul 26, 2022
d6a0f0c
Update GenevaExporterOptions.cs
xyq175com Jul 26, 2022
85179ed
Update GenevaExporterOptions.cs
xyq175com Jul 26, 2022
6f24239
fix_issue_395
xyq175com Jul 27, 2022
b7dad9e
Merge branch 'open-telemetry:main' into fix_issue_395
xyq175com Jul 27, 2022
7cbbbcb
Update GenevaTraceExporterTests.cs
xyq175com Jul 27, 2022
7abd65b
Update GenevaTraceExporterTests.cs
xyq175com Jul 27, 2022
9b96d60
Update GenevaTraceExporterTests.cs
xyq175com Jul 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,30 @@ public IReadOnlyDictionary<string, object> PrepopulatedFields
var copy = new Dictionary<string, object>(value.Count + 1) { [Schema.V40.PartA.Ver] = schemaVersion };
foreach (var entry in value)
{
copy[entry.Key] = entry.Value; // shallow copy
var val = entry.Value;
xyq175com marked this conversation as resolved.
Show resolved Hide resolved
switch (val)
{
case bool vb:
case byte vui8:
case sbyte vi8:
case short vi16:
case ushort vui16:
case int vi32:
case uint vui32:
case long vi64:
case ulong vui64:
case float vf:
case double vd:
case string vs:
break;
default:
throw new ArgumentException($"Type: {entry.Value.GetType()} is not supported. Only bool, byte, sbyte, short, ushort, int, uint, long, ulong, float, double, and string are the supported types for PrepopulatedFields values.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this throw NullReferenceException if value is null?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this addressed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"for PrepopulatedFields values" can be removed since this is self-explanatory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this addressed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

copy[entry.Key] = val; // shallow copy
}

this._fields = copy;
}
}

internal Func<object, string> ConvertToJson = obj => "ERROR: GenevaExporterOptions.ConvertToJson not configured.";
}
23 changes: 0 additions & 23 deletions src/OpenTelemetry.Exporter.Geneva/GenevaLogExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class GenevaLogExporter : GenevaBaseExporter<LogRecord>
private readonly IDataTransport m_dataTransport;
private readonly bool shouldPassThruTableMappings;
private bool isDisposed;
private Func<object, string> convertToJson;

public GenevaLogExporter(GenevaExporterOptions options)
{
Expand Down Expand Up @@ -108,8 +107,6 @@ public GenevaLogExporter(GenevaExporterOptions options)
throw new ArgumentOutOfRangeException(nameof(connectionStringBuilder.Protocol));
}

this.convertToJson = options.ConvertToJson;

if (options.PrepopulatedFields != null)
{
this.m_prepopulatedFieldKeys = new List<string>();
Expand Down Expand Up @@ -288,26 +285,6 @@ internal int SerializeLogRecord(LogRecord logRecord)
{
var key = this.m_prepopulatedFieldKeys[i];
var value = this.m_prepopulatedFields[key];
switch (value)
{
case bool vb:
case byte vui8:
case sbyte vi8:
case short vi16:
case ushort vui16:
case int vi32:
case uint vui32:
case long vi64:
case ulong vui64:
case float vf:
case double vd:
case string vs:
break;
default:
xyq175com marked this conversation as resolved.
Show resolved Hide resolved
value = this.convertToJson(value);
break;
}

cursor = AddPartAField(buffer, cursor, key, value);
cntFields += 1;
}
Expand Down
20 changes: 0 additions & 20 deletions src/OpenTelemetry.Exporter.Geneva/GenevaTraceExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,6 @@ public GenevaTraceExporter(GenevaExporterOptions options)
foreach (var entry in options.PrepopulatedFields)
{
var value = entry.Value;
switch (value)
{
case bool vb:
case byte vui8:
case sbyte vi8:
case short vi16:
case ushort vui16:
case int vi32:
case uint vui32:
case long vi64:
case ulong vui64:
case float vf:
case double vd:
case string vs:
break;
default:
value = options.ConvertToJson(value);
break;
}

cursor = AddPartAField(buffer, cursor, entry.Key, value);
this.m_cntPrepopulatedFields += 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ public void GenevaTraceExporter_constructor_Invalid_Input()
ConnectionString = null,
});
});

// unsupported types(char) for PrepopulatedFields
Assert.Throws<ArgumentException>(() =>
{
using var exporter = new GenevaTraceExporter(new GenevaExporterOptions
{
ConnectionString = "EtwSession=OpenTelemetry",
PrepopulatedFields = new Dictionary<string, object>
{
["cloud.role"] = "BusyWorker",
["cloud.roleInstance"] = "CY1SCH030021417",
["cloud.roleVer"] = (char)106,
},
});
});
}

[Fact]
Expand Down