Skip to content

Commit

Permalink
[Exporter.Geneva] Update OTel SDK prerelease version (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla authored Jun 2, 2023
1 parent 6517935 commit 0b90344
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<MicrosoftPublicApiAnalyzersPkgVer>[3.3.3]</MicrosoftPublicApiAnalyzersPkgVer>
<MicrosoftSourceLinkGitHubPkgVer>[1.1.1,2.0)</MicrosoftSourceLinkGitHubPkgVer>
<OpenTelemetryCoreLatestVersion>[1.4.0,2.0)</OpenTelemetryCoreLatestVersion>
<OpenTelemetryCoreLatestPrereleaseVersion>[1.5.0-alpha.1]</OpenTelemetryCoreLatestPrereleaseVersion>
<OpenTelemetryCoreLatestPrereleaseVersion>[1.5.0-rc.1]</OpenTelemetryCoreLatestPrereleaseVersion>
<StackExchangeRedisPkgVer>[2.1.58,3.0)</StackExchangeRedisPkgVer>
<CassandraCSharpDriverPkgVer>[3.16.0,4.0)</CassandraCSharpDriverPkgVer>
<StyleCopAnalyzersPkgVer>[1.2.0-beta.435,2.0)</StyleCopAnalyzersPkgVer>
Expand Down
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

## Unreleased

* Fix an issue with getting sanitized category name in pass-through table name
mapping cases for `TldLogExporter`.
([#1175](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1175))

* TldLogExporter to export `SpanId` value in `ext_dt_spanId` field instead of
`TraceId` value.
([#1184](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1184))
* Add support for abstract domain sockets.
([#1199](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1199))

* Update OTel SDK version to `1.5.0-rc.1`.
([#1210](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1210))

## 1.5.0-alpha.3

Released 2023-Apr-19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// </copyright>

using System;
using System.Diagnostics;
using OpenTelemetry.Internal;
using OpenTelemetry.Trace;

Expand All @@ -26,34 +27,31 @@ public static TracerProviderBuilder AddGenevaTraceExporter(this TracerProviderBu
{
Guard.ThrowIfNull(builder);

if (builder is IDeferredTracerProviderBuilder deferredTracerProviderBuilder)
return builder.AddProcessor(sp =>
{
return deferredTracerProviderBuilder.Configure((sp, builder) =>
{
AddGenevaTraceExporter(builder, sp.GetOptions<GenevaExporterOptions>(), configure);
});
}
var exporterOptions = sp.GetOptions<GenevaExporterOptions>();

return AddGenevaTraceExporter(builder, new GenevaExporterOptions(), configure);
return BuildGenevaTraceExporter(exporterOptions, configure);
});
}

private static TracerProviderBuilder AddGenevaTraceExporter(this TracerProviderBuilder builder, GenevaExporterOptions options, Action<GenevaExporterOptions> configure)
private static BaseProcessor<Activity> BuildGenevaTraceExporter(GenevaExporterOptions options, Action<GenevaExporterOptions> configure)
{
configure?.Invoke(options);
var exporter = new GenevaTraceExporter(options);
if (exporter.IsUsingUnixDomainSocket)
{
var batchOptions = new BatchExportActivityProcessorOptions();
return builder.AddProcessor(new BatchActivityExportProcessor(
return new BatchActivityExportProcessor(
exporter,
batchOptions.MaxQueueSize,
batchOptions.ScheduledDelayMilliseconds,
batchOptions.ExporterTimeoutMilliseconds,
batchOptions.MaxExportBatchSize));
batchOptions.MaxExportBatchSize);
}
else
{
return builder.AddProcessor(new ReentrantActivityExportProcessor(exporter));
return new ReentrantActivityExportProcessor(exporter);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,18 @@ public static MeterProviderBuilder AddGenevaMetricExporter(this MeterProviderBui
{
Guard.ThrowIfNull(builder);

if (builder is IDeferredMeterProviderBuilder deferredMeterProviderBuilder)
return builder.AddReader(sp =>
{
return deferredMeterProviderBuilder.Configure((sp, builder) =>
{
AddGenevaMetricExporter(builder, sp.GetOptions<GenevaMetricExporterOptions>(), configure);
});
}
var exporterOptions = sp.GetOptions<GenevaMetricExporterOptions>();

return AddGenevaMetricExporter(builder, new GenevaMetricExporterOptions(), configure);
return BuildGenevaMetricExporter(exporterOptions, configure);
});
}

private static MeterProviderBuilder AddGenevaMetricExporter(MeterProviderBuilder builder, GenevaMetricExporterOptions options, Action<GenevaMetricExporterOptions> configure = null)
private static MetricReader BuildGenevaMetricExporter(GenevaMetricExporterOptions options, Action<GenevaMetricExporterOptions> configure = null)
{
configure?.Invoke(options);
return builder.AddReader(new PeriodicExportingMetricReader(new GenevaMetricExporter(options), options.MetricExportIntervalMilliseconds)
{ TemporalityPreference = MetricReaderTemporalityPreference.Delta });
return new PeriodicExportingMetricReader(new GenevaMetricExporter(options), options.MetricExportIntervalMilliseconds)
{ TemporalityPreference = MetricReaderTemporalityPreference.Delta };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ internal bool IsUsingUnixDomainSocket

internal int SerializeLogRecord(LogRecord logRecord)
{
// `LogRecord.State` and `LogRecord.StateValues` were marked Obsolete in https://github.com/open-telemetry/opentelemetry-dotnet/pull/4334
#pragma warning disable 0618
IReadOnlyList<KeyValuePair<string, object>> listKvp;
if (logRecord.State == null)
{
Expand All @@ -150,6 +152,7 @@ internal int SerializeLogRecord(LogRecord logRecord)
// Attempt to see if State could be ROL_KVP.
listKvp = logRecord.State as IReadOnlyList<KeyValuePair<string, object>>;
}
#pragma warning restore 0618

var buffer = m_buffer.Value;
if (buffer == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public void Dispose()
internal void SerializeLogRecord(LogRecord logRecord)
{
IReadOnlyList<KeyValuePair<string, object>> listKvp;

// `LogRecord.State` and `LogRecord.StateValues` were marked Obsolete in https://github.com/open-telemetry/opentelemetry-dotnet/pull/4334
#pragma warning disable 0618
if (logRecord.State == null)
{
// When State is null, OTel SDK guarantees StateValues is populated
Expand All @@ -198,6 +201,7 @@ internal void SerializeLogRecord(LogRecord logRecord)
// Attempt to see if State could be ROL_KVP.
listKvp = logRecord.State as IReadOnlyList<KeyValuePair<string, object>>;
}
#pragma warning restore 0618

// Structured log.
// 2 scenarios.
Expand Down
44 changes: 17 additions & 27 deletions test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,9 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage)
_ = exporter.SerializeLogRecord(logRecordList[0]);
object fluentdData = MessagePack.MessagePackSerializer.Deserialize<object>(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance);
var body = GetField(fluentdData, "body");
if (includeFormattedMessage)
{
Assert.Equal("Formatted Message", body);
}
else
{
Assert.Null(body);
}

// Body gets populated as "Formatted Message" regardless of the value of `IncludeFormattedMessage`
Assert.Equal("Formatted Message", body);

Assert.Equal("Value1", GetField(fluentdData, "Key1"));
Assert.Equal("Value2", GetField(fluentdData, "Key2"));
Expand All @@ -599,14 +594,9 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage)
_ = exporter.SerializeLogRecord(logRecordList[0]);
fluentdData = MessagePack.MessagePackSerializer.Deserialize<object>(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance);
body = GetField(fluentdData, "body");
if (includeFormattedMessage)
{
Assert.Equal("Formatted Message", body);
}
else
{
Assert.Null(body);
}

// Body gets populated as "Formatted Message" regardless of the value of `IncludeFormattedMessage`
Assert.Equal("Formatted Message", body);

// ARRANGE
logRecordList.Clear();
Expand All @@ -627,8 +617,8 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage)
fluentdData = MessagePack.MessagePackSerializer.Deserialize<object>(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance);
body = GetField(fluentdData, "body");

// Formatter is null, hence body is always null
Assert.Null(body);
// Even though Formatter is null, body is populated with the state
Assert.Equal("somestringasdata", body);

// ARRANGE
logRecordList.Clear();
Expand All @@ -654,15 +644,8 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage)

body = GetField(fluentdData, "body");

// Only populate body if FormattedMessage is enabled
if (includeFormattedMessage)
{
Assert.Equal("Example formatted message.", body);
}
else
{
Assert.Null(body);
}
// Body gets populated as "Formatted Message" regardless of the value of `IncludeFormattedMessage`
Assert.Equal("Example formatted message.", body);
}
finally
{
Expand Down Expand Up @@ -1376,6 +1359,9 @@ private void AssertFluentdForwardModeForLogRecord(GenevaExporterOptions exporter

bool isUnstructuredLog = true;
IReadOnlyList<KeyValuePair<string, object>> stateKeyValuePairList;

// `LogRecord.State` and `LogRecord.StateValues` were marked Obsolete in https://github.com/open-telemetry/opentelemetry-dotnet/pull/4334
#pragma warning disable 0618
if (logRecord.State == null)
{
stateKeyValuePairList = logRecord.StateValues;
Expand All @@ -1384,6 +1370,7 @@ private void AssertFluentdForwardModeForLogRecord(GenevaExporterOptions exporter
{
stateKeyValuePairList = logRecord.State as IReadOnlyList<KeyValuePair<string, object>>;
}
#pragma warning restore 0618

if (stateKeyValuePairList != null)
{
Expand All @@ -1392,10 +1379,13 @@ private void AssertFluentdForwardModeForLogRecord(GenevaExporterOptions exporter

if (isUnstructuredLog)
{
// `LogRecord.State` and `LogRecord.StateValues` were marked Obsolete in https://github.com/open-telemetry/opentelemetry-dotnet/pull/4334
#pragma warning disable 0618
if (logRecord.State != null)
{
Assert.Equal(logRecord.State.ToString(), mapping["body"]);
}
#pragma warning restore 0618
else
{
Assert.Equal(stateKeyValuePairList[0].Value, mapping["body"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ public void GenevaTraceExporter_Success_Windows()
var source = new ActivitySource(sourceName);
using (var parent = source.StartActivity("HttpIn", ActivityKind.Server))
{
parent?.SetTag("http.method", "GET");
parent?.SetTag("http.url", "https://localhost/wiki/Rabbit");
parent.SetTag("http.method", "GET");
parent.SetTag("http.url", "https://localhost/wiki/Rabbit");
using (var child = source.StartActivity("HttpOut", ActivityKind.Client))
{
child?.SetTag("http.method", "GET");
child?.SetTag("http.url", "https://www.wikipedia.org/wiki/Rabbit");
child?.SetTag("http.status_code", 404);
child.SetTag("http.method", "GET");
child.SetTag("http.url", "https://www.wikipedia.org/wiki/Rabbit");
child.SetTag("http.status_code", 404);
}

parent?.SetTag("http.status_code", 200);
Expand Down

0 comments on commit 0b90344

Please sign in to comment.