From 7b68f6e52a91ca282b8d38fcaba9a20da427e726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 20 Sep 2023 00:30:05 +0200 Subject: [PATCH 01/15] Nullable OpenTelemetry.Instrumentation.EventCounters.Tests (#1360) --- .../EventCountersMetricsTests.cs | 23 +++++++------------ ...Instrumentation.EventCounters.Tests.csproj | 1 - 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs index 3476430c35..f68d3121b0 100644 --- a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs +++ b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs @@ -41,7 +41,7 @@ public void EventCounter() options.AddEventSources(source.Name); }) .AddInMemoryExporter(metricItems) - .Build(); + .Build()!; // Act counter.WriteMetric(1997.0202); @@ -67,7 +67,7 @@ public void IncrementingEventCounter() options.AddEventSources(source.Name); }) .AddInMemoryExporter(metricItems) - .Build(); + .Build()!; // Act incCounter.Increment(1); @@ -96,7 +96,7 @@ public void PollingCounter() options.AddEventSources(source.Name); }) .AddInMemoryExporter(metricItems) - .Build(); + .Build()!; // Act var metric = AwaitExport(meterProvider, metricItems, expectedInstrumentName: "ec.c.poll-c"); @@ -122,7 +122,7 @@ public void IncrementingPollingCounter() options.AddEventSources(source.Name); }) .AddInMemoryExporter(metricItems) - .Build(); + .Build()!; // Act var metric = AwaitExport(meterProvider, metricItems, expectedInstrumentName: "ec.d.inc-poll-c"); @@ -133,13 +133,6 @@ public void IncrementingPollingCounter() Assert.Equal(1, GetActualValue(metric)); } - [Fact] - public void ThrowExceptionWhenBuilderIsNull() - { - MeterProviderBuilder builder = null; - Assert.Throws(() => builder.AddEventCountersInstrumentation()); - } - [Fact] public void ThrowExceptionForUnsupportedEventSources() { @@ -177,7 +170,7 @@ public void EventSourceNameShortening(string sourceName, string eventName, strin options.AddEventSources(source.Name); }) .AddInMemoryExporter(metricItems) - .Build(); + .Build()!; // Act connections.Increment(1); @@ -235,16 +228,16 @@ private static double GetActualValue(Metric metric) return sum; } - private static Metric AwaitExport(MeterProvider meterProvider, List exportedItems, string expectedInstrumentName) + private static Metric? AwaitExport(MeterProvider meterProvider, List exportedItems, string expectedInstrumentName) { - Metric metric = null; + Metric? metric = null; SpinWait.SpinUntil( () => { Thread.Sleep(100); meterProvider.ForceFlush(); - metric = exportedItems.Where(x => x.Name == expectedInstrumentName).FirstOrDefault(); + metric = exportedItems.FirstOrDefault(x => x.Name == expectedInstrumentName); return metric != null; }, 10_000); diff --git a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj index c7a95c7e4a..81177f9a06 100644 --- a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj @@ -4,7 +4,6 @@ net7.0;net6.0 true - disable From 71655cebf4862bb06ff23e55068a7ff667b0fed4 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 19 Sep 2023 15:52:25 -0700 Subject: [PATCH 02/15] [OneCollectorExporter] Perf improvements (#1361) --- .../CHANGELOG.md | 7 +++ .../Internal/ExtensionFieldInformation.cs | 29 +++++++++++++ .../ExtensionFieldInformationManager.cs | 43 +++++++++++-------- .../CommonSchemaJsonSerializationHelper.cs | 23 ++++++++++ .../CommonSchemaJsonSerializationState.cs | 33 ++++++++++---- ...ommonSchemaJsonSerializationHelperTests.cs | 7 ++- ...CommonSchemaJsonSerializationStateTests.cs | 6 +-- .../ExtensionFieldInformationManagerTests.cs | 14 ++++-- ...ogRecordCommonSchemaJsonSerializerTests.cs | 38 ++++++++-------- 9 files changed, 149 insertions(+), 51 deletions(-) create mode 100644 src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformation.cs diff --git a/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md b/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md index 8b7b8b531b..cab0a366f9 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md @@ -22,6 +22,13 @@ extension because it is not currently supported by the OneCollector service. ([#1345](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1345)) +* Added dedicated handling for `IReadOnlyList>` + types during serialization to improve performance. + ([#1361](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1361)) + +* Added caching of extension property UTF8 JSON strings to improve performance. + ([#1361](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1361)) + ## 1.5.1 Released 2023-Aug-07 diff --git a/src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformation.cs b/src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformation.cs new file mode 100644 index 0000000000..596c2943d9 --- /dev/null +++ b/src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformation.cs @@ -0,0 +1,29 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System.Text.Json; + +namespace OpenTelemetry.Exporter.OneCollector; + +internal sealed class ExtensionFieldInformation +{ + public string? ExtensionName; + public JsonEncodedText EncodedExtensionName; + public string? FieldName; + public JsonEncodedText EncodedFieldName; + + public bool IsValid => this.ExtensionName != null; +} diff --git a/src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformationManager.cs b/src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformationManager.cs index f2a92b62d1..98bd8dd745 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformationManager.cs +++ b/src/OpenTelemetry.Exporter.OneCollector/Internal/ExtensionFieldInformationManager.cs @@ -16,6 +16,10 @@ using System.Collections; using System.Diagnostics; +#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif +using System.Text.Json; namespace OpenTelemetry.Exporter.OneCollector; @@ -28,9 +32,14 @@ internal sealed class ExtensionFieldInformationManager public int CountOfCachedExtensionFields => this.fieldInformationCache.Count; - public bool TryResolveExtensionFieldInformation(string fullFieldName, out (string ExtensionName, string FieldName) resolvedFieldInformation) + public bool TryResolveExtensionFieldInformation( + string fullFieldName, +#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER + [NotNullWhen(true)] +#endif + out ExtensionFieldInformation? resolvedFieldInformation) { - if (this.fieldInformationCache[fullFieldName] is not FieldInformation fieldInformation) + if (this.fieldInformationCache[fullFieldName] is not ExtensionFieldInformation fieldInformation) { fieldInformation = this.ResolveExtensionFieldInformationRare(fullFieldName); } @@ -41,39 +50,44 @@ public bool TryResolveExtensionFieldInformation(string fullFieldName, out (strin return false; } - resolvedFieldInformation = new(fieldInformation.ExtensionName!, fieldInformation.FieldName!); + resolvedFieldInformation = fieldInformation; return true; } - private static FieldInformation BuildFieldInformation(string fullFieldName) + private static ExtensionFieldInformation BuildFieldInformation(string fullFieldName) { Debug.Assert(fullFieldName.Length >= 4, "fullFieldName length was invalid"); Debug.Assert(fullFieldName.StartsWith("ext.", StringComparison.OrdinalIgnoreCase), "fullFieldName did not start with 'ext.'"); - var extensionName = fullFieldName.AsSpan().Slice(4); + var extensionName = fullFieldName.AsSpan().Slice(4).TrimEnd(); var locationOfDot = extensionName.IndexOf('.'); if (locationOfDot <= 0) { return new(); } - var fieldName = extensionName.Slice(locationOfDot + 1); + var fieldName = extensionName.Slice(locationOfDot + 1).TrimStart(); if (fieldName.Length <= 0) { return new(); } - extensionName = extensionName.Slice(0, locationOfDot); + extensionName = extensionName.Slice(0, locationOfDot).TrimEnd(); + if (extensionName.Length <= 0) + { + return new(); + } - return new FieldInformation + return new ExtensionFieldInformation { ExtensionName = extensionName.ToString(), + EncodedExtensionName = JsonEncodedText.Encode(extensionName), FieldName = fieldName.ToString(), - IsValid = true, + EncodedFieldName = JsonEncodedText.Encode(fieldName), }; } - private FieldInformation ResolveExtensionFieldInformationRare(string fullFieldName) + private ExtensionFieldInformation ResolveExtensionFieldInformationRare(string fullFieldName) { if (this.fieldInformationCache.Count >= MaxNumberOfCachedFieldInformations) { @@ -82,7 +96,7 @@ private FieldInformation ResolveExtensionFieldInformationRare(string fullFieldNa lock (this.fieldInformationCache) { - if (this.fieldInformationCache[fullFieldName] is not FieldInformation fieldInformation) + if (this.fieldInformationCache[fullFieldName] is not ExtensionFieldInformation fieldInformation) { fieldInformation = BuildFieldInformation(fullFieldName); if (this.fieldInformationCache.Count < MaxNumberOfCachedFieldInformations) @@ -94,11 +108,4 @@ private FieldInformation ResolveExtensionFieldInformationRare(string fullFieldNa return fieldInformation; } } - - private sealed class FieldInformation - { - public string? ExtensionName; - public string? FieldName; - public bool IsValid; - } } diff --git a/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationHelper.cs b/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationHelper.cs index dd687a15b3..fa015b281c 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationHelper.cs +++ b/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationHelper.cs @@ -158,6 +158,10 @@ public static void SerializeValueToJson(object? value, Utf8JsonWriter writer) SerializeArrayValueToJson(v, writer); return; + case IReadOnlyList> v: + SerializeMapValueToJson(v, writer); + return; + case IEnumerable> v: SerializeMapValueToJson(v, writer); return; @@ -180,6 +184,25 @@ private static void SerializeArrayValueToJson(Array value, Utf8JsonWriter writer writer.WriteEndArray(); } + private static void SerializeMapValueToJson(IReadOnlyList> value, Utf8JsonWriter writer) + { + writer.WriteStartObject(); + + for (int i = 0; i < value.Count; i++) + { + var element = value[i]; + + if (string.IsNullOrEmpty(element.Key)) + { + continue; + } + + SerializeKeyValueToJson(element.Key, element.Value, writer); + } + + writer.WriteEndObject(); + } + private static void SerializeMapValueToJson(IEnumerable> value, Utf8JsonWriter writer) { writer.WriteStartObject(); diff --git a/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationState.cs b/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationState.cs index 52b992aaa1..cc464979fe 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationState.cs +++ b/src/OpenTelemetry.Exporter.OneCollector/Internal/Serialization/CommonSchemaJsonSerializationState.cs @@ -14,6 +14,7 @@ // limitations under the License. // +using System.Diagnostics; #if NET6_0_OR_GREATER using System.Runtime.InteropServices; #endif @@ -26,7 +27,7 @@ internal sealed class CommonSchemaJsonSerializationState public const int MaxNumberOfExtensionKeys = 64; public const int MaxNumberOfExtensionValuesPerKey = 16; private readonly Dictionary keys = new(4, StringComparer.OrdinalIgnoreCase); - private readonly List> allValues = new(16); + private readonly List> allValues = new(16); private string itemType; private int nextKeysToAllValuesLookupIndex; private KeyValueLookup[] keysToAllValuesLookup = new KeyValueLookup[4]; @@ -47,12 +48,17 @@ public void AddExtensionAttribute(KeyValuePair attribute) { if (!ExtensionFieldInformationManager.SharedCache.TryResolveExtensionFieldInformation( attribute.Key, - out (string ExtensionName, string FieldName) fieldInformation)) + out var fieldInformation)) { OneCollectorExporterEventSource.Log.AttributeDropped(this.itemType, attribute.Key, "Invalid extension field name"); return; } + Debug.Assert(fieldInformation?.ExtensionName != null, "fieldInformation.ExtensionName was null"); + Debug.Assert(fieldInformation?.EncodedExtensionName.EncodedUtf8Bytes.Length > 0, "fieldInformation.EncodedExtensionName was empty"); + Debug.Assert(fieldInformation?.FieldName != null, "fieldInformation.FieldName was null"); + Debug.Assert(fieldInformation?.EncodedFieldName.EncodedUtf8Bytes.Length > 0, "fieldInformation.EncodedFieldName was empty"); + #if NET6_0_OR_GREATER ref var lookupIndex = ref CollectionsMarshal.GetValueRefOrAddDefault(this.keys, fieldInformation.ExtensionName, out var existed); if (!existed) @@ -60,10 +66,10 @@ public void AddExtensionAttribute(KeyValuePair attribute) this.AssignNewExtensionToLookupIndex(ref lookupIndex); } #else - if (!this.keys.TryGetValue(fieldInformation.ExtensionName, out int lookupIndex)) + if (!this.keys.TryGetValue(fieldInformation!.ExtensionName!, out int lookupIndex)) { this.AssignNewExtensionToLookupIndex(ref lookupIndex); - this.keys[fieldInformation.ExtensionName] = lookupIndex; + this.keys[fieldInformation.ExtensionName!] = lookupIndex; } #endif @@ -82,7 +88,7 @@ public void AddExtensionAttribute(KeyValuePair attribute) } int index = this.allValues.Count; - this.allValues.Add(new KeyValuePair(fieldInformation.FieldName, attribute.Value)); + this.allValues.Add(new KeyValuePair(fieldInformation, attribute.Value)); unsafe { @@ -107,7 +113,7 @@ public void SerializeExtensionPropertiesToJson(bool writeExtensionObjectEnvelope foreach (var extensionPropertyKey in this.keys) { - writer.WriteStartObject(extensionPropertyKey.Key); + var wroteStartObject = false; ref KeyValueLookup keyLookup = ref this.keysToAllValuesLookup[extensionPropertyKey.Value]; @@ -120,12 +126,23 @@ public void SerializeExtensionPropertiesToJson(bool writeExtensionObjectEnvelope #else var attribute = allValues[keyLookup.ValueIndicies[i]]; #endif + var fieldInformation = attribute.Key; + + if (!wroteStartObject) + { + writer.WriteStartObject(fieldInformation.EncodedExtensionName); + wroteStartObject = true; + } - CommonSchemaJsonSerializationHelper.SerializeKeyValueToJson(attribute.Key, attribute.Value, writer); + writer.WritePropertyName(fieldInformation.EncodedFieldName); + CommonSchemaJsonSerializationHelper.SerializeValueToJson(attribute.Value, writer); } } - writer.WriteEndObject(); + if (wroteStartObject) + { + writer.WriteEndObject(); + } } if (writeExtensionObjectEnvelope) diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationHelperTests.cs b/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationHelperTests.cs index cb7673710b..ab3adfc7c6 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationHelperTests.cs +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationHelperTests.cs @@ -82,8 +82,11 @@ public void SerializeComplexValueToJsonTest() var array = new[] { 0, 1, 18 }; this.SerializeValueToJsonTest(array, "[0,1,18]"); - var map = new List> { new KeyValuePair("key1", "value1") }; - this.SerializeValueToJsonTest(map, "{\"key1\":\"value1\"}"); + var listMap = new List> { new KeyValuePair("key1", "value1") }; + this.SerializeValueToJsonTest(listMap, "{\"key1\":\"value1\"}"); + + var dictMap = new Dictionary { ["key1"] = "value1" }; + this.SerializeValueToJsonTest(dictMap, "{\"key1\":\"value1\"}"); var typeWithToString = new TypeWithToString(); this.SerializeValueToJsonTest(typeWithToString, "\"Hello world\""); diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationStateTests.cs b/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationStateTests.cs index 0363ca3996..37a50d3f6d 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationStateTests.cs +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/CommonSchemaJsonSerializationStateTests.cs @@ -50,7 +50,7 @@ public void AddExtensionAttributeTest() var json = Encoding.UTF8.GetString(stream.ToArray()); Assert.Equal( - "{\"ext\":{\"something\":{\"field1\":1,\"field2\":2,\"field3\":3,\"field4\":6},\"food\":{\"field1\":4,\"field2\":5}}}", + """{"ext":{"something":{"field1":1,"field2":2,"field3":3,"field4":6},"food":{"field1":4,"field2":5}}}""", json); stream.SetLength(0); @@ -74,7 +74,7 @@ public void AddExtensionAttributeTest() json = Encoding.UTF8.GetString(stream.ToArray()); Assert.Equal( - "{\"ext\":{\"something\":{\"field1\":1},\"food\":{\"field1\":1}}}", + """{"ext":{"something":{"field1":1},"food":{"field1":1}}}""", json); } @@ -102,7 +102,7 @@ public void AddExtensionAttributeDuplicatesTest() var json = Encoding.UTF8.GetString(stream.ToArray()); Assert.Equal( - "{\"ext\":{\"something\":{\"field1\":1,\"field1\":2}}}", + """{"ext":{"something":{"field1":1,"field1":2}}}""", json); } diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/ExtensionFieldInformationManagerTests.cs b/test/OpenTelemetry.Exporter.OneCollector.Tests/ExtensionFieldInformationManagerTests.cs index e2b0de5890..fa07ae22c8 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/ExtensionFieldInformationManagerTests.cs +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/ExtensionFieldInformationManagerTests.cs @@ -28,6 +28,7 @@ public void FieldInformationIsCachedTest() var result = extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext.something.fieldName1", out var fieldInformation); Assert.True(result); + Assert.NotNull(fieldInformation); Assert.Equal("something", fieldInformation.ExtensionName); Assert.Equal("fieldName1", fieldInformation.FieldName); @@ -38,6 +39,7 @@ public void FieldInformationIsCachedTest() Assert.Equal(1, extensionFieldInformationManager.CountOfCachedExtensionFields); Assert.True(result); + Assert.NotNull(fieldInformation); Assert.Equal("something", fieldInformation.ExtensionName); Assert.Equal("fieldName1", fieldInformation.FieldName); @@ -46,6 +48,7 @@ public void FieldInformationIsCachedTest() Assert.Equal(2, extensionFieldInformationManager.CountOfCachedExtensionFields); Assert.True(result); + Assert.NotNull(fieldInformation); Assert.Equal("something", fieldInformation.ExtensionName); Assert.Equal("field.Name2", fieldInformation.FieldName); } @@ -54,19 +57,23 @@ public void FieldInformationIsCachedTest() public void InvalidFieldNamesIgnoredTest() { var extensionFieldInformationManager = new ExtensionFieldInformationManager(); - Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext.", out _)); Assert.Equal(1, extensionFieldInformationManager.CountOfCachedExtensionFields); - Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext.", out _)); + Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("EXT.", out _)); Assert.Equal(1, extensionFieldInformationManager.CountOfCachedExtensionFields); + Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext..", out _)); + Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext. .", out _)); + Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext..field", out _)); Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext.something", out _)); Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext.something.", out _)); + Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext.SOMETHING.", out _)); + Assert.False(extensionFieldInformationManager.TryResolveExtensionFieldInformation("ext.something. ", out _)); - Assert.Equal(3, extensionFieldInformationManager.CountOfCachedExtensionFields); + Assert.Equal(7, extensionFieldInformationManager.CountOfCachedExtensionFields); } [Fact] @@ -81,6 +88,7 @@ public void FieldInformationCacheLimitTest() var result = extensionFieldInformationManager.TryResolveExtensionFieldInformation($"ext.something.{fieldName}", out var fieldInformation); Assert.True(result); + Assert.NotNull(fieldInformation); Assert.Equal("something", fieldInformation.ExtensionName); Assert.Equal(fieldName, fieldInformation.FieldName); } diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/LogRecordCommonSchemaJsonSerializerTests.cs b/test/OpenTelemetry.Exporter.OneCollector.Tests/LogRecordCommonSchemaJsonSerializerTests.cs index 22386f8a10..5642b73b19 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/LogRecordCommonSchemaJsonSerializerTests.cs +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/LogRecordCommonSchemaJsonSerializerTests.cs @@ -32,7 +32,7 @@ public void EmptyLogRecordJsonTest() string json = GetLogRecordJson(1, (index, logRecord) => { }); Assert.Equal( - "{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{\"severityText\":\"Trace\",\"severityNumber\":1}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1}}""" + "\n", json); } @@ -42,8 +42,8 @@ public void MultipleEmptyLogRecordJsonTest() string json = GetLogRecordJson(2, (index, logRecord) => { }); Assert.Equal( - "{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{\"severityText\":\"Trace\",\"severityNumber\":1}}\n" - + "{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{\"severityText\":\"Trace\",\"severityNumber\":1}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1}}""" + "\n" + + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1}}""" + "\n", json); } @@ -63,7 +63,7 @@ public void LogRecordLogLevelJsonTest(LogLevel logLevel, string severityText, in }); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"{severityText}\",\"severityNumber\":{severityNumber}}}}}\n", + $$$"""{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"{{{severityText}}}","severityNumber":{{{severityNumber}}}}}""" + "\n", json); } @@ -79,7 +79,7 @@ public void LogRecordCategoryNameAndEventNameJsonTest(string categoryName, strin }); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"{categoryName}.{eventName ?? "Name"}\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1}}}}\n", + $$$"""{"ver":"4.0","name":"{{{categoryName}}}.{{{eventName ?? "Name"}}}","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1}}""" + "\n", json); } @@ -92,7 +92,7 @@ public void LogRecordEventIdJsonTest() }); Assert.Equal( - "{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{\"eventId\":18,\"severityText\":\"Trace\",\"severityNumber\":1}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"eventId":18,"severityText":"Trace","severityNumber":1}}""" + "\n", json); } @@ -105,7 +105,7 @@ public void LogRecordTimestampJsonTest() }); Assert.Equal( - "{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2023-01-18T10:18:00Z\",\"iKey\":\"o:tenant-token\",\"data\":{\"severityText\":\"Trace\",\"severityNumber\":1}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2023-01-18T10:18:00Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1}}""" + "\n", json); } @@ -119,7 +119,7 @@ public void LogRecordOriginalFormatBodyJsonTest() }); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1,\"body\":\"hello world\",\"formattedMessage\":\"goodbye world\"}}}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1,"body":"hello world","formattedMessage":"goodbye world"}}""" + "\n", json); } @@ -133,7 +133,7 @@ public void LogRecordBodyJsonTest() }); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1,\"body\":\"hello world\",\"formattedMessage\":\"goodbye world\"}}}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1,"body":"hello world","formattedMessage":"goodbye world"}}""" + "\n", json); } @@ -146,7 +146,7 @@ public void LogRecordFormattedMessageBodyJsonTest() }); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1,\"body\":\"goodbye world\",\"formattedMessage\":\"goodbye world\"}}}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1,"body":"goodbye world","formattedMessage":"goodbye world"}}""" + "\n", json); } @@ -164,7 +164,7 @@ public void LogRecordResourceJsonTest() string json = GetLogRecordJson(1, (index, logRecord) => { }, resource); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1,\"resourceKey1\":\"resourceValue1\",\"resourceKey2\":\"resourceValue2\"}}}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1,"resourceKey1":"resourceValue1","resourceKey2":"resourceValue2"}}""" + "\n", json); } @@ -178,7 +178,7 @@ public void LogRecordScopesJsonTest() string json = GetLogRecordJson(1, (index, logRecord) => { }, scopeProvider: scopeProvider); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1,\"scope1Key1\":\"scope1Value1\",\"scope1Key2\":\"scope1Value2\",\"scope2Key1\":\"scope2Value1\"}}}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1,"scope1Key1":"scope1Value1","scope1Key2":"scope1Value2","scope2Key1":"scope2Value1"}}""" + "\n", json); } @@ -191,7 +191,7 @@ public void LogRecordStateValuesJsonTest() }); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1,\"stateKey1\":\"stateValue1\",\"stateKey2\":\"stateValue2\"}}}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1,"stateKey1":"stateValue1","stateKey2":"stateValue2"}}""" + "\n", json); } @@ -209,7 +209,9 @@ public void LogRecordTraceContextJsonTest() }); Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1}},\"ext\":{{\"dt\":{{\"traceId\":\"{traceId}\",\"spanId\":\"{spanId}\"}}}}}}\n", + $$$$""" + {"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1},"ext":{"dt":{"traceId":"{{{{traceId}}}}","spanId":"{{{{spanId}}}}"}}} + """ + "\n", json); } @@ -227,11 +229,13 @@ public void LogRecordExceptionJsonTest(bool includeStackTraceAsString) includeStackTraceAsString: includeStackTraceAsString); var stackJson = includeStackTraceAsString - ? $",\"stack\":\"System.InvalidOperationException: Operation is not valid due to the current state of the object.\"" + ? ",\"stack\":\"System.InvalidOperationException: Operation is not valid due to the current state of the object.\"" : string.Empty; Assert.Equal( - $"{{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{{\"severityText\":\"Trace\",\"severityNumber\":1}},\"ext\":{{\"ex\":{{\"type\":\"System.InvalidOperationException\",\"msg\":\"Operation is not valid due to the current state of the object.\"{stackJson}}}}}}}\n", + $$$$""" + {"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1},"ext":{"ex":{"type":"System.InvalidOperationException","msg":"Operation is not valid due to the current state of the object."{{{{stackJson}}}}}}} + """ + "\n", json); } @@ -258,7 +262,7 @@ public void LogRecordExtensionsJsonTest() scopeProvider); Assert.Equal( - "{\"ver\":\"4.0\",\"name\":\"Namespace.Name\",\"time\":\"2032-01-18T10:11:12Z\",\"iKey\":\"o:tenant-token\",\"data\":{\"severityText\":\"Trace\",\"severityNumber\":1},\"ext\":{\"state\":{\"field\":\"stateValue1\"},\"resource\":{\"field\":\"resourceValue1\"},\"scope\":{\"field\":\"scopeValue1\"}}}\n", + """{"ver":"4.0","name":"Namespace.Name","time":"2032-01-18T10:11:12Z","iKey":"o:tenant-token","data":{"severityText":"Trace","severityNumber":1},"ext":{"state":{"field":"stateValue1"},"resource":{"field":"resourceValue1"},"scope":{"field":"scopeValue1"}}}""" + "\n", json); } From 49365fc57c3feb7b4480d3bd09255403b420612d Mon Sep 17 00:00:00 2001 From: Matt Hensley <130569+matt-hensley@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:28:00 -0400 Subject: [PATCH 03/15] OWIN HTTP server metrics (#1335) --- .../.publicApi/net462/PublicAPI.Unshipped.txt | 2 + .../CHANGELOG.md | 2 + .../Implementation/DiagnosticsMiddleware.cs | 36 ++++++- .../OwinInstrumentationMetrics.cs | 31 ++++++ ...mentationMeterProviderBuilderExtensions.cs | 40 +++++++ .../README.md | 28 ++++- src/Shared/SemanticConventions.cs | 6 ++ .../DiagnosticsMiddlewareTests.cs | 100 ++++++++++++++++-- 8 files changed, 232 insertions(+), 13 deletions(-) create mode 100644 src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationMetrics.cs create mode 100644 src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationMeterProviderBuilderExtensions.cs diff --git a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt index 23c619652b..761ae2d2ff 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt @@ -9,8 +9,10 @@ OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Filter.set -> void OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.OwinInstrumentationOptions() -> void OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.get -> bool OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.set -> void +OpenTelemetry.Metrics.OwinInstrumentationMeterProviderBuilderExtensions OpenTelemetry.Trace.TracerProviderBuilderExtensions Owin.AppBuilderExtensions +static OpenTelemetry.Metrics.OwinInstrumentationMeterProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder static Owin.AppBuilderExtensions.UseOpenTelemetry(this Owin.IAppBuilder appBuilder) -> Owin.IAppBuilder \ No newline at end of file diff --git a/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md index 6fcb6bdf0d..ec16d15b46 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md @@ -6,6 +6,8 @@ ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) * Removes `AddOwinInstrumentation` method with default configure parameter. ([#929](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/929)) +* Adds HTTP server metrics via `AddOwinInstrumentation` extension method on `MeterProviderBuilder` + ([#1335](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1335)) ## 1.0.0-rc.3 diff --git a/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs b/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs index 1d0bd2ba8f..85b041bd24 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs +++ b/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs @@ -21,6 +21,7 @@ using System.Threading.Tasks; using Microsoft.Owin; using OpenTelemetry.Context.Propagation; +using OpenTelemetry.Instrumentation.Owin.Implementation; using OpenTelemetry.Trace; namespace OpenTelemetry.Instrumentation.Owin; @@ -46,15 +47,23 @@ public DiagnosticsMiddleware(OwinMiddleware next) /// public override async Task Invoke(IOwinContext owinContext) { + long startTimestamp = -1; + try { BeginRequest(owinContext); + + if (OwinInstrumentationMetrics.HttpServerDuration.Enabled && !owinContext.Environment.ContainsKey(ContextKey)) + { + startTimestamp = Stopwatch.GetTimestamp(); + } + await this.Next.Invoke(owinContext).ConfigureAwait(false); - RequestEnd(owinContext, null); + RequestEnd(owinContext, null, startTimestamp); } catch (Exception ex) { - RequestEnd(owinContext, ex); + RequestEnd(owinContext, ex, startTimestamp); throw; } } @@ -151,7 +160,7 @@ private static void BeginRequest(IOwinContext owinContext) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void RequestEnd(IOwinContext owinContext, Exception exception) + private static void RequestEnd(IOwinContext owinContext, Exception exception, long startTimestamp) { if (owinContext.Environment.TryGetValue(ContextKey, out object context) && context is Activity activity) @@ -199,11 +208,32 @@ private static void RequestEnd(IOwinContext owinContext, Exception exception) activity.Stop(); + if (OwinInstrumentationMetrics.HttpServerDuration.Enabled) + { + OwinInstrumentationMetrics.HttpServerDuration.Record( + activity.Duration.TotalSeconds, + new(SemanticConventions.AttributeHttpRequestMethod, owinContext.Request.Method), + new(SemanticConventions.AttributeUrlScheme, owinContext.Request.Scheme), + new(SemanticConventions.AttributeHttpResponseStatusCode, owinContext.Response.StatusCode)); + } + if (!(Propagators.DefaultTextMapPropagator is TraceContextPropagator)) { Baggage.Current = default; } } + else if (OwinInstrumentationMetrics.HttpServerDuration.Enabled) + { + var endTimestamp = Stopwatch.GetTimestamp(); + var duration = endTimestamp - startTimestamp; + var durationS = duration / Stopwatch.Frequency; + + OwinInstrumentationMetrics.HttpServerDuration.Record( + durationS, + new(SemanticConventions.AttributeHttpRequestMethod, owinContext.Request.Method), + new(SemanticConventions.AttributeUrlScheme, owinContext.Request.Scheme), + new(SemanticConventions.AttributeHttpResponseStatusCode, owinContext.Response.StatusCode)); + } } /// diff --git a/src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationMetrics.cs b/src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationMetrics.cs new file mode 100644 index 0000000000..b19e7a47f2 --- /dev/null +++ b/src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationMetrics.cs @@ -0,0 +1,31 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System.Diagnostics.Metrics; +using System.Reflection; + +namespace OpenTelemetry.Instrumentation.Owin.Implementation; + +internal static class OwinInstrumentationMetrics +{ + internal static readonly AssemblyName AssemblyName = typeof(OwinInstrumentationMetrics).Assembly.GetName(); + + public static string MeterName => AssemblyName.Name; + + public static Meter Instance => new Meter(MeterName, AssemblyName.Version.ToString()); + + public static Histogram HttpServerDuration => Instance.CreateHistogram("http.server.request.duration", "s", "Measures the duration of inbound HTTP requests."); +} diff --git a/src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationMeterProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationMeterProviderBuilderExtensions.cs new file mode 100644 index 0000000000..fc6a0408f4 --- /dev/null +++ b/src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationMeterProviderBuilderExtensions.cs @@ -0,0 +1,40 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using OpenTelemetry.Instrumentation.Owin.Implementation; +using OpenTelemetry.Internal; + +namespace OpenTelemetry.Metrics; + +/// +/// Extension methods to simplify registering of OWIN request instrumentation. +/// +public static class OwinInstrumentationMeterProviderBuilderExtensions +{ + /// + /// Enables the incoming requests automatic data collection for OWIN. + /// + /// being configured. + /// The instance of to chain the calls. + public static MeterProviderBuilder AddOwinInstrumentation( + this MeterProviderBuilder builder) + { + Guard.ThrowIfNull(builder); + + builder.AddMeter(OwinInstrumentationMetrics.MeterName); + return builder; + } +} diff --git a/src/OpenTelemetry.Instrumentation.Owin/README.md b/src/OpenTelemetry.Instrumentation.Owin/README.md index a5172d1b49..efc1d3d5e3 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/README.md +++ b/src/OpenTelemetry.Instrumentation.Owin/README.md @@ -38,7 +38,9 @@ done before any other middleware registrations. }); ``` -### Step 3: Configure OpenTelemetry TracerProvider +### Step 3: Enable OWIN Instrumentation at application startup + +#### Configure OpenTelemetry TracerProvider Call the `AddOwinInstrumentation` `TracerProviderBuilder` extension to register OpenTelemetry instrumentation which listens to the OWIN diagnostic events. @@ -51,6 +53,30 @@ OpenTelemetry instrumentation which listens to the OWIN diagnostic events. .Build(); ``` +#### Configure OpenTelemetry MeterProvider + +Call the `AddOwinInstrumentation` `MeterProviderBuilder` extension to register +OpenTelemetry instrumentation which generates request duration metrics for OWIN requests. + +The metric implemention does not rely on tracing, and will generate metrics +even if tracing is disabled. + +```csharp + using var openTelemetry = Sdk.CreateMeterProviderBuilder() + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Owin-Example")) + .AddOwinInstrumentation() + .AddConsoleExporter() + .Build(); +``` + +The instrumentation is implemented based on [metrics semantic +conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/http-metrics.md#metric-httpserverduration). +Currently, the instrumentation supports the following metric. + +| Name | Instrument Type | Unit | Description | +|-------|-----------------|------|-------------| +| `http.server.request.duration` | Histogram | `s` | Measures the duration of inbound HTTP requests. | + ## Customize OWIN span names The OpenTelemetry OWIN instrumentation will create spans with very generic names diff --git a/src/Shared/SemanticConventions.cs b/src/Shared/SemanticConventions.cs index ab5aca7023..e4040c6b11 100644 --- a/src/Shared/SemanticConventions.cs +++ b/src/Shared/SemanticConventions.cs @@ -108,5 +108,11 @@ internal static class SemanticConventions public const string AttributeExceptionType = "exception.type"; public const string AttributeExceptionMessage = "exception.message"; public const string AttributeExceptionStacktrace = "exception.stacktrace"; + + // v1.21.0 + // https://github.com/open-telemetry/semantic-conventions/blob/v1.21.0/docs/http/http-metrics.md#http-server + public const string AttributeHttpRequestMethod = "http.request.method"; // replaces: "http.method" (AttributeHttpMethod) + public const string AttributeHttpResponseStatusCode = "http.response.status_code"; // replaces: "http.status_code" (AttributeHttpStatusCode) + public const string AttributeUrlScheme = "url.scheme"; // replaces: "http.scheme" (AttributeHttpScheme) #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } diff --git a/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs b/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs index 4d90b5073b..1caa391c1f 100644 --- a/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs +++ b/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs @@ -24,6 +24,8 @@ using System.Web.Http; using Microsoft.Owin; using Microsoft.Owin.Hosting; +using OpenTelemetry.Instrumentation.Owin.Implementation; +using OpenTelemetry.Metrics; using OpenTelemetry.Trace; using Owin; using Xunit; @@ -106,15 +108,28 @@ public void Dispose() } [Theory] - [InlineData(true, false)] - [InlineData(true, true)] - [InlineData(false)] + [InlineData(true, false, false)] [InlineData(true, false, true)] - [InlineData(true, false, true, true)] - [InlineData(true, false, false, false, true)] - [InlineData(true, false, false, false, true, true)] + [InlineData(true, false, false, true)] + [InlineData(true, false, false, true, true)] + [InlineData(true, false, false, false, false, true)] + [InlineData(true, false, false, false, false, true, true)] + [InlineData(true, true, false)] + [InlineData(true, true, true)] + [InlineData(true, true, false, true)] + [InlineData(true, true, false, true, true)] + [InlineData(true, true, false, false, false, true)] + [InlineData(true, true, false, false, false, true, true)] + [InlineData(false, true, false)] + [InlineData(false, true, true)] + [InlineData(false, true, false, true)] + [InlineData(false, true, false, true, true)] + [InlineData(false, true, false, false, false, true)] + [InlineData(false, true, false, false, false, true, true)] + [InlineData(false, false)] public async Task OutgoingRequestInstrumentationTest( - bool instrument, + bool instrumentTraces, + bool instrumentMetrics, bool filter = false, bool enrich = false, bool enrichmentException = false, @@ -122,11 +137,14 @@ public async Task OutgoingRequestInstrumentationTest( bool recordException = false) { List stoppedActivities = new List(); + List exportedMetrics = new List(); var builder = Sdk.CreateTracerProviderBuilder() .AddInMemoryExporter(stoppedActivities); + var meterBuilder = Sdk.CreateMeterProviderBuilder() + .AddInMemoryExporter(exportedMetrics); - if (instrument) + if (instrumentTraces) { builder .AddOwinInstrumentation(options => @@ -159,7 +177,13 @@ public async Task OutgoingRequestInstrumentationTest( }); } + if (instrumentMetrics) + { + meterBuilder.AddOwinInstrumentation(); + } + using TracerProvider tracerProvider = builder.Build(); + using MeterProvider meterProvider = meterBuilder.Build(); using HttpClient client = new HttpClient(); @@ -177,7 +201,7 @@ Owin has finished to inspect the activity status. */ Assert.True(this.requestCompleteHandle.WaitOne(3000)); - if (instrument) + if (instrumentTraces) { if (!filter) { @@ -222,5 +246,63 @@ Owin has finished to inspect the activity status. */ { Assert.Empty(stoppedActivities); } + + if (instrumentMetrics) + { + meterProvider.Dispose(); + var metric = exportedMetrics[0]; + var metricPoints = this.GetMetricPoints(metric); + var metricPoint = Assert.Single(metricPoints); + + Assert.Equal(OwinInstrumentationMetrics.MeterName, metric.MeterName); + Assert.Equal("http.server.request.duration", metric.Name); + Assert.Equal(MetricType.Histogram, metric.MetricType); + Assert.Equal(1, metricPoint.GetHistogramCount()); + Assert.Equal(3, metricPoint.Tags.Count); + + foreach (var tag in metricPoint.Tags) + { + switch (tag.Key) + { + case SemanticConventions.AttributeHttpMethod: + Assert.Equal("GET", tag.Value); + break; + case SemanticConventions.AttributeHttpScheme: + Assert.Equal(requestUri.Scheme, tag.Value); + break; + case SemanticConventions.AttributeHttpStatusCode: + Assert.Equal(generateRemoteException ? 500 : 200, tag.Value); + break; + } + } + } + else + { + Assert.Empty(exportedMetrics); + } + + if (instrumentMetrics && instrumentTraces && !filter) + { + var metric = Assert.Single(exportedMetrics); + var activity = Assert.Single(stoppedActivities); + var metricPoints = this.GetMetricPoints(metric); + var metricPoint = Assert.Single(metricPoints); + + // metric value and span duration should match + // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-metrics.md#metric-httpserverrequestduration + Assert.Equal(activity.Duration.TotalSeconds, metricPoint.GetHistogramSum()); + } + } + + private List GetMetricPoints(Metric metric) + { + List metricPoints = new(); + + foreach (var metricPoint in metric.GetMetricPoints()) + { + metricPoints.Add(metricPoint); + } + + return metricPoints; } } From bd71b460e01ac0a7c080598983bb8de01383a186 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 20 Sep 2023 09:45:44 -0700 Subject: [PATCH 04/15] [repo] Dedicated workflows for Instrumentation.Process & Exporter.OneCollector (#1355) Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> --- .github/codecov.yml | 25 +++++++- .../workflows/ci-Exporter.OneCollector.yml | 57 +++++++++++++++++++ .../workflows/ci-Instrumentation.Process.yml | 54 +++++++++++++----- .github/workflows/ci-aot.yml | 7 --- .github/workflows/ci.yml | 36 ++++++++++-- .github/workflows/dotnet-core-cov.yml | 53 ----------------- .github/workflows/dotnet-format.yml | 5 -- .github/workflows/integration-md.yml | 4 -- .github/workflows/integration.yml | 4 -- .github/workflows/markdownlint.yml | 4 -- .github/workflows/sanitycheck.yml | 2 - build/Common.nonprod.props | 9 ++- build/Common.props | 2 - build/process-codecoverage.ps1 | 12 ---- opentelemetry-dotnet-contrib.sln | 6 +- ...OpenTelemetry.Exporter.Geneva.Tests.csproj | 12 +--- ...enTelemetry.Exporter.InfluxDB.Tests.csproj | 6 +- ...penTelemetry.Exporter.Instana.Tests.csproj | 8 +-- ...lemetry.Exporter.OneCollector.Tests.csproj | 6 +- ...elemetry.Exporter.Stackdriver.Tests.csproj | 6 +- .../OpenTelemetry.Extensions.AWS.Tests.csproj | 6 +- ...lemetry.Extensions.Enrichment.Tests.csproj | 6 +- .../OpenTelemetry.Extensions.Tests.csproj | 6 +- ...Telemetry.Instrumentation.AWS.Tests.csproj | 6 +- ...try.Instrumentation.AWSLambda.Tests.csproj | 6 +- ...on.AspNet.TelemetryHttpModule.Tests.csproj | 9 ++- ...emetry.Instrumentation.AspNet.Tests.csproj | 6 +- ...try.Instrumentation.Cassandra.Tests.csproj | 6 +- ...mentation.ElasticsearchClient.Tests.csproj | 6 +- ...mentation.EntityFrameworkCore.Tests.csproj | 6 +- ...Instrumentation.EventCounters.Tests.csproj | 7 +-- ...etry.Instrumentation.GrpcCore.Tests.csproj | 7 +-- ...etry.Instrumentation.Hangfire.Tests.csproj | 6 +- ...elemetry.Instrumentation.Owin.Tests.csproj | 6 +- ...metry.Instrumentation.Process.Tests.csproj | 7 +-- ...emetry.Instrumentation.Quartz.Tests.csproj | 6 +- ...metry.Instrumentation.Runtime.Tests.csproj | 7 +-- ...umentation.StackExchangeRedis.Tests.csproj | 6 +- ...Telemetry.Instrumentation.Wcf.Tests.csproj | 6 +- ....PersistentStorage.FileSystem.Tests.csproj | 6 +- ...lemetry.ResourceDetectors.AWS.Tests.csproj | 6 +- ...metry.ResourceDetectors.Azure.Tests.csproj | 8 +-- ...y.ResourceDetectors.Container.Tests.csproj | 6 +- .../OpenTelemetry.Sampler.AWS.Tests.csproj | 6 +- 44 files changed, 194 insertions(+), 277 deletions(-) create mode 100644 .github/workflows/ci-Exporter.OneCollector.yml delete mode 100644 .github/workflows/dotnet-core-cov.yml delete mode 100644 build/process-codecoverage.ps1 diff --git a/.github/codecov.yml b/.github/codecov.yml index df54634a71..bf6b155120 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -23,6 +23,25 @@ comment: require_changes: no ignore: - - "**.md" - - "src/OpenTelemetry.Contrib.Shared" # copied from main OTel project and has code coverage there - - "test/**/*" + - "**/*.md" + - "src/Shared" # copied from main OTel project and has code coverage there + - "test" + - "examples" + - "build" + +flags: + unittests: + carryforward: true + paths: + - src + + unittests-Exporter.OneCollector: + carryforward: true + paths: + - src/OpenTelemetry.Exporter.OneCollector + + unittests-Instrumentation.Process: + carryforward: true + paths: + - src/OpenTelemetry.Instrumentation.Process + diff --git a/.github/workflows/ci-Exporter.OneCollector.yml b/.github/workflows/ci-Exporter.OneCollector.yml new file mode 100644 index 0000000000..7af1185e2c --- /dev/null +++ b/.github/workflows/ci-Exporter.OneCollector.yml @@ -0,0 +1,57 @@ +name: Build OpenTelemetry.Exporter.OneCollector + +on: + pull_request: + branches: [ 'main*', 'exporter*' ] + paths: + - '*/OpenTelemetry.Exporter.OneCollector*/**' + - 'build/**' + - '!**.md' + +env: + PROJECT: OpenTelemetry.Exporter.OneCollector + +jobs: + build-test: + + strategy: + fail-fast: false # ensures the entire test matrix is run, even if one permutation fails + matrix: + os: [ windows-latest, ubuntu-latest ] + version: [ net462, net6.0, net7.0 ] + exclude: + - os: ubuntu-latest + version: net462 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + + - name: dotnet restore build/Projects/${{env.PROJECT}}.proj + run: dotnet restore build/Projects/${{env.PROJECT}}.proj + + - name: dotnet build build/Projects/${{env.PROJECT}}.proj + run: dotnet build build/Projects/${{env.PROJECT}}.proj --configuration Release --no-restore + + - name: dotnet test test/${{env.PROJECT}}.Tests + run: dotnet test test/${{env.PROJECT}}.Tests --collect:"Code Coverage" --results-directory:TestResults --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true + + - name: Install coverage tool + run: dotnet tool install -g dotnet-coverage + + - name: Merging test results + run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage + + - uses: codecov/codecov-action@v3.1.4 + continue-on-error: true # Note: Don't fail for upload failures + env: + OS: ${{ matrix.os }} + TFM: ${{ matrix.version }} + with: + file: TestResults/Cobertura.xml + env_vars: OS,TFM + flags: unittests-Exporter.OneCollector + name: Code Coverage for Exporter.OneCollector on [${{ matrix.os }}.${{ matrix.version }}] diff --git a/.github/workflows/ci-Instrumentation.Process.yml b/.github/workflows/ci-Instrumentation.Process.yml index bd0b9bb5cf..d0db0b9c39 100644 --- a/.github/workflows/ci-Instrumentation.Process.yml +++ b/.github/workflows/ci-Instrumentation.Process.yml @@ -1,33 +1,57 @@ -name: Instrumentation.Process +name: Build OpenTelemetry.Instrumentation.Process on: pull_request: - branches: [ 'main*' ] + branches: [ 'main*', 'instrumentation*' ] paths: - - 'src/OpenTelemetry.Instrumentation.Process/**' - - 'test/OpenTelemetry.Instrumentation.Process.Tests/**' + - '*/OpenTelemetry.Instrumentation.Process*/**' + - 'build/**' + - '!**.md' env: - COMPONENT_NAME: OpenTelemetry.Instrumentation.Process + PROJECT: OpenTelemetry.Instrumentation.Process jobs: - unit-test: + build-test: + strategy: fail-fast: false # ensures the entire test matrix is run, even if one permutation fails matrix: - os: [ ubuntu-latest, windows-latest ] + os: [ windows-latest, ubuntu-latest ] + version: [ net462, net6.0, net7.0 ] + exclude: + - os: ubuntu-latest + version: net462 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - name: Install .NET 7 SDK - uses: actions/setup-dotnet@v3.2.0 - with: - dotnet-version: '7.0.x' + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + + - name: dotnet restore test/${{ env.PROJECT }}.Tests + run: dotnet restore test/${{ env.PROJECT }}.Tests + + - name: dotnet build test/${{ env.PROJECT }}.Tests + run: dotnet build test/${{ env.PROJECT }}.Tests --configuration Release --no-restore - - name: Build - run: dotnet build --configuration Release test/${{ env.COMPONENT_NAME }}.Tests/${{ env.COMPONENT_NAME }}.Tests.csproj + - name: dotnet test test/${{ env.PROJECT }}.Tests + run: dotnet test test/${{ env.PROJECT }}.Tests --collect:"Code Coverage" --results-directory:"TestResults" --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true - - name: Test - run: dotnet test test/${{ env.COMPONENT_NAME }}.Tests/bin/Release/**/${{ env.COMPONENT_NAME }}.Tests.dll --logger:"console;verbosity=detailed" + - name: Install coverage tool + run: dotnet tool install -g dotnet-coverage + + - name: Merging test results + run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage + + - uses: codecov/codecov-action@v3.1.4 + continue-on-error: true # Note: Don't fail for upload failures + env: + OS: ${{ matrix.os }} + TFM: ${{ matrix.version }} + with: + file: TestResults/Cobertura.xml + env_vars: OS,TFM + flags: unittests-Instrumentation.Process + name: Code Coverage for Instrumentation.Process on [${{ matrix.os }}.${{ matrix.version }}] diff --git a/.github/workflows/ci-aot.yml b/.github/workflows/ci-aot.yml index ff44f35e24..676e4ccfff 100644 --- a/.github/workflows/ci-aot.yml +++ b/.github/workflows/ci-aot.yml @@ -1,13 +1,6 @@ name: Publish AOTCompatibility testApp on: - push: - branches: [ 'main*' ] - paths: - - 'src/OpenTelemetry.Instrumentation.Runtime/**' - - '!src/OpenTelemetry.Instrumentation.Runtime/README.md' - - 'src/OpenTelemetry.Instrumentation.EventCounters/**' - - '!src/OpenTelemetry.Instrumentation.EventCounters/README.md' pull_request: branches: [ 'main*' ] paths: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93d5d72a49..a67fa19e3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,14 +1,12 @@ name: Build on: - push: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] - paths-ignore: - - '**.md' pull_request: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] paths-ignore: - '**.md' + - '*/OpenTelemetry.Instrumentation.Process*/**' + - '*/OpenTelemetry.Exporter.OneCollector*/**' jobs: build-test: @@ -29,11 +27,37 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v3 - - name: Install dependencies + - name: Restore run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore - name: Test ${{ matrix.version }} - run: dotnet test **/bin/**/${{ matrix.version }}/*.Tests.dll --logger:"console;verbosity=detailed" + shell: pwsh + run: | + $projects = Get-ChildItem ` + -Path test/*.Tests/*.csproj ` + -Exclude OpenTelemetry.Instrumentation.Process.Tests.csproj, OpenTelemetry.Exporter.OneCollector.Tests.csproj + + ForEach ($project in $projects) + { + dotnet test $project.FullName --collect:"Code Coverage" --results-directory:"TestResults" --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true + } + + - name: Install coverage tool + run: dotnet tool install -g dotnet-coverage + + - name: Merging test results + run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage + + - uses: codecov/codecov-action@v3.1.4 + continue-on-error: true # Note: Don't fail for upload failures + env: + OS: ${{ matrix.os }} + TFM: ${{ matrix.version }} + with: + file: TestResults/Cobertura.xml + env_vars: OS,TFM + flags: unittests + name: Code Coverage for solution on [${{ matrix.os }}.${{ matrix.version }}] diff --git a/.github/workflows/dotnet-core-cov.yml b/.github/workflows/dotnet-core-cov.yml deleted file mode 100644 index 388ac5730f..0000000000 --- a/.github/workflows/dotnet-core-cov.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Code Coverage - -on: - push: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] - paths-ignore: - - '**.md' - pull_request: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] - paths-ignore: - - '**.md' - -jobs: - build-test-report: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: Install dependencies - run: dotnet restore - - - name: dotnet build - run: dotnet build --configuration Release --no-restore - - - name: dotnet test - run: dotnet test --collect:"Code Coverage" --results-directory:"TestResults" --configuration Release --no-build -- RunConfiguration.DisableAppDomain=true - - - name: Process code coverage - run: .\build\process-codecoverage.ps1 - shell: powershell - - - name: Install report tool - run: dotnet tool install -g dotnet-reportgenerator-globaltool - - - name: Merging test results - run: reportgenerator -reports:TestResults/**/*.xml -targetdir:TestResults -reporttypes:Cobertura - - - uses: codecov/codecov-action@v3.1.4 - with: - file: TestResults/Cobertura.xml - env_vars: OS - name: Code Coverage for ${{ matrix.os }} diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml index f9886e9f5e..a74d0b8b66 100644 --- a/.github/workflows/dotnet-format.yml +++ b/.github/workflows/dotnet-format.yml @@ -1,11 +1,6 @@ name: dotnet format on: - push: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] - paths: - - '**.cs' - - '.editorconfig' pull_request: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] paths: diff --git a/.github/workflows/integration-md.yml b/.github/workflows/integration-md.yml index 66a9949582..915c8e70cb 100644 --- a/.github/workflows/integration-md.yml +++ b/.github/workflows/integration-md.yml @@ -1,10 +1,6 @@ name: Integration Tests on: - push: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] - paths: - - '**.md' pull_request: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] paths: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index b11a2b163c..da281d5359 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,10 +1,6 @@ name: Integration Tests on: - push: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] - paths-ignore: - - '**.md' pull_request: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] paths-ignore: diff --git a/.github/workflows/markdownlint.yml b/.github/workflows/markdownlint.yml index 736387a7d5..b7a318dbb8 100644 --- a/.github/workflows/markdownlint.yml +++ b/.github/workflows/markdownlint.yml @@ -1,10 +1,6 @@ name: markdownlint on: - push: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] - paths: - - '**.md' pull_request: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] paths: diff --git a/.github/workflows/sanitycheck.yml b/.github/workflows/sanitycheck.yml index 6cf97382ae..67676f3b6c 100644 --- a/.github/workflows/sanitycheck.yml +++ b/.github/workflows/sanitycheck.yml @@ -1,8 +1,6 @@ name: sanitycheck on: - push: - branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] pull_request: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props index 5fcb3187f5..b82f905d82 100644 --- a/build/Common.nonprod.props +++ b/build/Common.nonprod.props @@ -21,16 +21,19 @@ Refer to https://docs.microsoft.com/en-us/nuget/concepts/package-versioning for semver syntax. --> [0.13.6,0.14) - [6.0.0,7.0.0) [2.3.1,3.0) [5.0.0,7.0) - [17.6.3,18.0) + [17.7.2,18.0) [4.18.4,5.0) $(OpenTelemetryCoreLatestVersion) $(OpenTelemetryCoreLatestPrereleaseVersion) [2.5.0,3.0) [2.5.0,3.0) [1.5.32,2.0) - + + + + + diff --git a/build/Common.props b/build/Common.props index 84556f1c15..7ed5728f63 100644 --- a/build/Common.props +++ b/build/Common.props @@ -29,7 +29,6 @@ Refer to https://docs.microsoft.com/en-us/nuget/concepts/package-versioning for semver syntax. --> [4.3.0,5.0) - [17.6.3] [2.1.0,5.0) [3.1.0,) [1.0.3,2.0) @@ -53,7 +52,6 @@ - diff --git a/build/process-codecoverage.ps1 b/build/process-codecoverage.ps1 deleted file mode 100644 index ff0bdf6d8f..0000000000 --- a/build/process-codecoverage.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -[xml]$commonProps = Get-Content -Path $PSScriptRoot\Common.props -$microsoftCodeCoveragePkgVer = [string]$commonProps.Project.PropertyGroup.MicrosoftCodeCoveragePkgVer # This is collected in the format: "[16.10.0]" -$microsoftCodeCoveragePkgVer = $microsoftCodeCoveragePkgVer.Trim(); -$microsoftCodeCoveragePkgVer = $microsoftCodeCoveragePkgVer.SubString(1, $microsoftCodeCoveragePkgVer.Length - 2) # Removing square brackets -$files = Get-ChildItem "TestResults" -Filter "*.coverage" -Recurse -Write-Host $env:USERPROFILE -foreach ($file in $files) -{ - $command = $env:USERPROFILE+ '\.nuget\packages\microsoft.codecoverage\' + $microsoftCodeCoveragePkgVer + '\build\netstandard2.0\CodeCoverage\CodeCoverage.exe analyze /output:' + $file.DirectoryName + '\' + $file.Name + '.xml '+ $file.FullName - Write-Host $command - Invoke-Expression $command -} diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 26a25d4d9f..9bea2b5871 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -9,6 +9,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{07AA0F83-22F6-4B8C-921D-029D3384CB17}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + CODEOWNERS = CODEOWNERS CONTRIBUTING.md = CONTRIBUTING.md global.json = global.json NuGet.config = NuGet.config @@ -18,8 +19,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{1A06E14B-DD2F-4536-9D2E-F708C0C43555}" ProjectSection(SolutionItems) = preProject - CODEOWNERS = CODEOWNERS + .github\codecov.yml = .github\codecov.yml .github\component_owners.yml = .github\component_owners.yml + .github\dependabot.yml = .github\dependabot.yml + .github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{43CAFE52-F329-4431-87DA-7FEE1454D9A9}" @@ -27,6 +30,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\assign-reviewers.yml = .github\workflows\assign-reviewers.yml .github\workflows\ci-aot.yml = .github\workflows\ci-aot.yml .github\workflows\ci-Exporter.OneCollector-Integration.yml = .github\workflows\ci-Exporter.OneCollector-Integration.yml + .github\workflows\ci-Exporter.OneCollector.yml = .github\workflows\ci-Exporter.OneCollector.yml .github\workflows\ci-Instrumentation.Process.yml = .github\workflows\ci-Instrumentation.Process.yml .github\workflows\ci-md.yml = .github\workflows\ci-md.yml .github\workflows\ci.yml = .github\workflows\ci.yml diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj b/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj index c3933d601a..0bfa4aa284 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj @@ -11,25 +11,17 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + diff --git a/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj b/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj index 77f722d9ed..0a8afbb0b4 100644 --- a/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj +++ b/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj @@ -9,12 +9,8 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj b/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj index 9327ebdc7d..8894e13e55 100644 --- a/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj @@ -8,18 +8,14 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + - + diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj index e2a610d9f9..e63fc170e3 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj @@ -9,12 +9,8 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj b/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj index 52327d652c..caf7104c03 100644 --- a/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj @@ -11,14 +11,10 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj b/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj index 73a3269b37..7a272b6e5c 100644 --- a/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj +++ b/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj @@ -6,13 +6,9 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj b/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj index bb5034a279..ea02e4ed0b 100644 --- a/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj +++ b/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj @@ -8,12 +8,8 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj b/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj index 5c804515d1..f337a44e1e 100644 --- a/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj +++ b/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj @@ -8,13 +8,9 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj b/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj index 45403f5832..2995cb98a4 100644 --- a/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj @@ -8,14 +8,10 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj index 95fbba74b5..6e716a4a7a 100644 --- a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj @@ -8,13 +8,9 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj index c68c2175a8..8be1376e77 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj @@ -7,14 +7,13 @@ - + + + - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj index f59b1e785e..ac0591b22c 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj @@ -6,14 +6,10 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj b/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj index 95016b6ae9..717529ac0a 100644 --- a/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj @@ -7,15 +7,11 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj b/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj index d380a9ce76..f86a5a1482 100644 --- a/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj @@ -9,14 +9,10 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj b/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj index d5a316695c..6efa9fde6f 100644 --- a/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj @@ -15,13 +15,9 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj index 81177f9a06..3bed24dd3e 100644 --- a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj @@ -7,14 +7,9 @@ - - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj index 103afee76e..aa506d3a03 100644 --- a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj @@ -5,14 +5,9 @@ disable - - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj index 7da4e0ba0f..8b951ec26c 100644 --- a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj @@ -9,13 +9,9 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj b/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj index cef5be2a1d..2b113bd700 100644 --- a/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj @@ -7,12 +7,8 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj b/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj index a391effc6c..50bb75e806 100644 --- a/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj @@ -7,14 +7,9 @@ - - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj b/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj index 3844899e19..81596ee50a 100644 --- a/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj @@ -9,15 +9,11 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj b/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj index 8555b84cb5..ff5d8c5322 100644 --- a/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj @@ -7,14 +7,9 @@ - - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj index 77f29289fb..dfa8a0ba02 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj @@ -19,14 +19,10 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj b/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj index 3aa11db7b8..32a62abd6c 100644 --- a/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj @@ -9,13 +9,9 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj b/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj index 76d872a709..f3b6f2bb07 100644 --- a/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj +++ b/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj @@ -7,12 +7,8 @@ - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + diff --git a/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj index 12b3750bb0..0bfd267363 100644 --- a/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj @@ -9,13 +9,9 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj index 97f3e5715f..034ad49ca2 100644 --- a/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -7,12 +7,8 @@ - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + diff --git a/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj index 6c4811cb1f..ff9dc21b7b 100644 --- a/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj @@ -9,12 +9,8 @@ - - - all - runtime; build; native; contentfiles; analyzers - + diff --git a/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj b/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj index e0fb3a51f5..24f730fd7b 100644 --- a/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj +++ b/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj @@ -6,12 +6,8 @@ - - - all - runtime; build; native; contentfiles; analyzers - + From d3fd7f4f2553f1ffd752d94f9a060dfa09681627 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 20 Sep 2023 10:46:56 -0700 Subject: [PATCH 05/15] [onecollector] Add integration tests (#1347) --- .../package-Exporter.OneCollector.yml | 18 +- opentelemetry-dotnet-contrib.sln | 5 +- .../EventSourceTestHelper.cs | 18 +- .../OpenTelemetry.Contrib.Tests.Shared.csproj | 2 +- .../SkipUnlessEnvVarFoundFactAttribute.cs | 22 +- .../SkipUnlessEnvVarFoundTheoryAttribute.cs | 11 +- .../OneCollectorIntegrationTests.cs | 316 ++++++++++++++++++ ...lemetry.Exporter.OneCollector.Tests.csproj | 2 + 8 files changed, 367 insertions(+), 27 deletions(-) create mode 100644 test/OpenTelemetry.Exporter.OneCollector.Tests/OneCollectorIntegrationTests.cs diff --git a/.github/workflows/package-Exporter.OneCollector.yml b/.github/workflows/package-Exporter.OneCollector.yml index 7d36af02c3..216cfe1bbb 100644 --- a/.github/workflows/package-Exporter.OneCollector.yml +++ b/.github/workflows/package-Exporter.OneCollector.yml @@ -31,17 +31,19 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v3 - - name: Install dependencies - run: dotnet restore src/${{env.PROJECT}} + - name: dotnet restore build/Projects/${{env.PROJECT}}.proj + run: dotnet restore build/Projects/${{env.PROJECT}}.proj - - name: dotnet build ${{env.PROJECT}} - run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true + - name: dotnet build build/Projects/${{env.PROJECT}}.proj + run: dotnet build build/Projects/${{env.PROJECT}}.proj --configuration Release --no-restore -p:Deterministic=true - - name: dotnet test ${{env.PROJECT}} - run: dotnet test test/${{env.PROJECT}}.Tests + - name: dotnet test test/${{env.PROJECT}}.Tests + run: dotnet test test/${{env.PROJECT}}.Tests --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" + env: + OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY: ${{ secrets.OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY }} - - name: dotnet pack ${{env.PROJECT}} - run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build + - name: dotnet pack build/Projects/${{env.PROJECT}}.proj + run: dotnet pack build/Projects/${{env.PROJECT}}.proj --configuration Release --no-build --no-restore - name: Publish Artifacts uses: actions/upload-artifact@v3 diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 9bea2b5871..18622206c3 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -83,7 +83,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{824BD1DE build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png build\OpenTelemetryContrib.prod.ruleset = build\OpenTelemetryContrib.prod.ruleset build\OpenTelemetryContrib.test.ruleset = build\OpenTelemetryContrib.test.ruleset - build\process-codecoverage.ps1 = build\process-codecoverage.ps1 build\sanitycheck.py = build\sanitycheck.py build\stylecop.json = build\stylecop.json build\test-aot-compatibility.ps1 = build\test-aot-compatibility.ps1 @@ -303,7 +302,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{9B examples\Directory.Build.targets = examples\Directory.Build.targets EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{D1D1B96A-77E5-443E-8B5C-93D6CE5F5337}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{048509D6-FB49-4B84-832A-90E55520B97B}" ProjectSection(SolutionItems) = preProject build\Projects\OpenTelemetry.Exporter.OneCollector.proj = build\Projects\OpenTelemetry.Exporter.OneCollector.proj EndProjectSection @@ -716,7 +715,7 @@ Global {B4951583-D432-4E87-85CF-498FDD6A35E6} = {2D354354-BAFB-490B-A26F-6A16A52A1A45} {31937862-0C88-41C0-AFD6-F97A7BF803A9} = {2097345F-4DD3-477D-BC54-A922F9B2B402} {9B30F5FD-3309-49CB-9CAD-D3372FAFD796} = {824BD1DE-3FA8-4FE0-823A-FD365EAC78AF} - {D1D1B96A-77E5-443E-8B5C-93D6CE5F5337} = {824BD1DE-3FA8-4FE0-823A-FD365EAC78AF} + {048509D6-FB49-4B84-832A-90E55520B97B} = {824BD1DE-3FA8-4FE0-823A-FD365EAC78AF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66} diff --git a/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs b/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs index 3b93d7d67a..740782be5e 100644 --- a/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs +++ b/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs @@ -56,7 +56,9 @@ private static void VerifyMethodImplementation(EventSource eventSource, MethodIn } catch (Exception e) { - var name = eventMethod.DeclaringType.Name + "." + eventMethod.Name; + var name = eventMethod.DeclaringType == null + ? eventMethod.Name + : eventMethod.DeclaringType.Name + "." + eventMethod.Name; throw new Exception("Method '" + name + "' is implemented incorrectly.", e); } @@ -87,7 +89,8 @@ private static object GenerateArgument(ParameterInfo parameter) if (parameter.ParameterType.IsValueType) { - return Activator.CreateInstance(parameter.ParameterType); + return Activator.CreateInstance(parameter.ParameterType) + ?? throw new NotSupportedException($"Could not create an instance of the '{parameter.ParameterType}' type."); } throw new NotSupportedException("Complex types are not supported"); @@ -108,9 +111,14 @@ private static void VerifyEventLevel(MethodInfo eventMethod, EventWrittenEventAr private static void VerifyEventMessage(MethodInfo eventMethod, EventWrittenEventArgs actualEvent, object[] eventArguments) { string expectedMessage = eventArguments.Length == 0 - ? GetEventAttribute(eventMethod).Message - : string.Format(CultureInfo.InvariantCulture, GetEventAttribute(eventMethod).Message, eventArguments); - string actualMessage = string.Format(CultureInfo.InvariantCulture, actualEvent.Message, actualEvent.Payload.ToArray()); + ? GetEventAttribute(eventMethod).Message! + : string.Format(CultureInfo.InvariantCulture, GetEventAttribute(eventMethod).Message!, eventArguments); + + string actualMessage = string.Format( + CultureInfo.InvariantCulture, + actualEvent.Message!, + actualEvent.Payload?.ToArray() ?? Array.Empty()); + AssertEqual(nameof(VerifyEventMessage), expectedMessage, actualMessage); } diff --git a/test/OpenTelemetry.Contrib.Tests.Shared/OpenTelemetry.Contrib.Tests.Shared.csproj b/test/OpenTelemetry.Contrib.Tests.Shared/OpenTelemetry.Contrib.Tests.Shared.csproj index 32de4e5218..6c18cec2b5 100644 --- a/test/OpenTelemetry.Contrib.Tests.Shared/OpenTelemetry.Contrib.Tests.Shared.csproj +++ b/test/OpenTelemetry.Contrib.Tests.Shared/OpenTelemetry.Contrib.Tests.Shared.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + netstandard2.0;net462;net6.0 false diff --git a/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundFactAttribute.cs b/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundFactAttribute.cs index afb6cd8318..4d22828bda 100644 --- a/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundFactAttribute.cs +++ b/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundFactAttribute.cs @@ -14,26 +14,34 @@ // limitations under the License. // +#pragma warning disable IDE0005 // Using directive is unnecessary. <- Projects with ImplicitUsings enabled will see warnings on using System + +#nullable enable + using System; using Xunit; namespace OpenTelemetry.Tests; -#nullable enable -internal class SkipUnlessEnvVarFoundFactAttribute : FactAttribute +internal sealed class SkipUnlessEnvVarFoundFactAttribute : FactAttribute { public SkipUnlessEnvVarFoundFactAttribute(string environmentVariable) { - var environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariable, EnvironmentVariableTarget.Process)!; - - if (string.IsNullOrEmpty(environmentVariableValue)) + if (string.IsNullOrEmpty(GetEnvironmentVariable(environmentVariable))) { - environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariable, EnvironmentVariableTarget.Machine); + this.Skip = $"Skipped because {environmentVariable} environment variable was not configured."; } + } + + public static string? GetEnvironmentVariable(string environmentVariableName) + { + var environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariableName, EnvironmentVariableTarget.Process); if (string.IsNullOrEmpty(environmentVariableValue)) { - this.Skip = $"Skipped because {environmentVariable} environment variable was not configured."; + environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariableName, EnvironmentVariableTarget.Machine); } + + return environmentVariableValue; } } diff --git a/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundTheoryAttribute.cs b/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundTheoryAttribute.cs index 34b96ceae4..17ea6d220d 100644 --- a/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundTheoryAttribute.cs +++ b/test/OpenTelemetry.Contrib.Tests.Shared/SkipUnlessEnvVarFoundTheoryAttribute.cs @@ -13,12 +13,17 @@ // See the License for the specific language governing permissions and // limitations under the License. // + +#pragma warning disable IDE0005 // Using directive is unnecessary. <- Projects with ImplicitUsings enabled will see warnings on using System + +#nullable enable + using System; using Xunit; namespace OpenTelemetry.Tests; -internal class SkipUnlessEnvVarFoundTheoryAttribute : TheoryAttribute +internal sealed class SkipUnlessEnvVarFoundTheoryAttribute : TheoryAttribute { public SkipUnlessEnvVarFoundTheoryAttribute(string environmentVariable) { @@ -28,9 +33,9 @@ public SkipUnlessEnvVarFoundTheoryAttribute(string environmentVariable) } } - public static string GetEnvironmentVariable(string environmentVariableName) + public static string? GetEnvironmentVariable(string environmentVariableName) { - string environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariableName, EnvironmentVariableTarget.Process); + var environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariableName, EnvironmentVariableTarget.Process); if (string.IsNullOrEmpty(environmentVariableValue)) { diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/OneCollectorIntegrationTests.cs b/test/OpenTelemetry.Exporter.OneCollector.Tests/OneCollectorIntegrationTests.cs new file mode 100644 index 0000000000..3993f6bd5c --- /dev/null +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/OneCollectorIntegrationTests.cs @@ -0,0 +1,316 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System.Diagnostics; +using System.Text; +using System.Text.Json; +using Microsoft.Extensions.Logging; +using OpenTelemetry.Internal; +using OpenTelemetry.Logs; +using OpenTelemetry.Resources; +using OpenTelemetry.Tests; +using Xunit; +using Xunit.Abstractions; + +namespace OpenTelemetry.Exporter.OneCollector.Tests; + +[Trait("CategoryName", "OneCollectorIntegrationTests")] +public class OneCollectorIntegrationTests +{ + private const string OneCollectorInstrumentationKeyEnvName = "OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY"; + private readonly ITestOutputHelper testOutputHelper; + + public OneCollectorIntegrationTests(ITestOutputHelper output) + { + this.testOutputHelper = output; + } + + [SkipUnlessEnvVarFoundFact(OneCollectorInstrumentationKeyEnvName)] + public void LogWithEventIdAndNameIntegrationTest() + { + this.RunIntegrationTest( + logger => + { + logger.LogInformation( + new EventId(18, "MyEvent"), + "Hello world"); + }, + out var succeeded, + out var actualJson); + + Assert.True(succeeded); + Assert.NotNull(actualJson); + + AssertActualJson( + actualJson, + root => + { + Assert.Equal($"{nameof(OneCollectorIntegrationTests)}.MyEvent", root.GetProperty("name").GetString()); + }, + data => + { + Assert.Equal("Information", data.GetProperty("severityText").GetString()); + Assert.Equal(9, data.GetProperty("severityNumber").GetInt32()); + Assert.Equal("Hello world", data.GetProperty("body").GetString()); + Assert.Equal(18, data.GetProperty("eventId").GetInt32()); + }); + } + + [SkipUnlessEnvVarFoundFact(OneCollectorInstrumentationKeyEnvName)] + public void LogWithEventNameOnlyIntegrationTest() + { + this.RunIntegrationTest( + logger => + { + logger.LogInformation( + new EventId(0, "MyEvent"), + "Hello world"); + }, + out var succeeded, + out var actualJson); + + Assert.True(succeeded); + Assert.NotNull(actualJson); + + AssertActualJson( + actualJson, + root => + { + Assert.Equal($"{nameof(OneCollectorIntegrationTests)}.MyEvent", root.GetProperty("name").GetString()); + }, + data => + { + Assert.Equal("Information", data.GetProperty("severityText").GetString()); + Assert.Equal(9, data.GetProperty("severityNumber").GetInt32()); + Assert.Equal("Hello world", data.GetProperty("body").GetString()); + AssertPropertyDoesNotExist(data, "eventId"); + }); + } + + [SkipUnlessEnvVarFoundFact(OneCollectorInstrumentationKeyEnvName)] + public void LogWithDataIntegrationTest() + { + this.RunIntegrationTest( + logger => + { + logger.LogInformation("Hello world {StructuredData}", "Goodbye world"); + }, + out var succeeded, + out var actualJson); + + Assert.True(succeeded); + Assert.NotNull(actualJson); + + AssertActualJson( + actualJson, + root => + { + Assert.Equal($"{nameof(OneCollectorIntegrationTests)}.Log", root.GetProperty("name").GetString()); + }, + data => + { + Assert.Equal("Information", data.GetProperty("severityText").GetString()); + Assert.Equal(9, data.GetProperty("severityNumber").GetInt32()); + Assert.Equal("Hello world {StructuredData}", data.GetProperty("body").GetString()); + Assert.Equal("Goodbye world", data.GetProperty("StructuredData").GetString()); + }); + } + + [SkipUnlessEnvVarFoundTheory(OneCollectorInstrumentationKeyEnvName)] + [InlineData(false)] + [InlineData(true)] + public void LogWithExceptionIntegrationTest(bool includeStackTrace) + { + var ex = new Exception("Test exception"); + + this.RunIntegrationTest( + logger => + { + logger.LogInformation(ex, "Hello world"); + }, + out var succeeded, + out var actualJson, + configureBuilderAction: builder => builder + .ConfigureSerializationOptions(options => options.ExceptionStackTraceHandling = includeStackTrace + ? OneCollectorExporterSerializationExceptionStackTraceHandlingType.IncludeAsString + : OneCollectorExporterSerializationExceptionStackTraceHandlingType.Ignore)); + + // TODO: Switch this to true. OneCollector doesn't currently support + // ext.ex (Exception Extension) but it should soon. + Assert.False(succeeded); + Assert.NotNull(actualJson); + + AssertActualJson( + actualJson, + root => + { + Assert.Equal($"{nameof(OneCollectorIntegrationTests)}.Log", root.GetProperty("name").GetString()); + }, + data => + { + Assert.Equal("Information", data.GetProperty("severityText").GetString()); + Assert.Equal(9, data.GetProperty("severityNumber").GetInt32()); + Assert.Equal("Hello world", data.GetProperty("body").GetString()); + }, + extensions => + { + var exceptionExtension = extensions.GetProperty("ex"); + + var type = exceptionExtension.GetProperty("type").GetString(); + var msg = exceptionExtension.GetProperty("msg").GetString(); + + Assert.Equal(ex.GetType().FullName, type); + Assert.Equal(ex.Message, msg); + + if (!includeStackTrace) + { + AssertPropertyDoesNotExist(exceptionExtension, "stack"); + } + else + { + var stack = exceptionExtension.GetProperty("stack").GetString(); + + Assert.Equal(ex.ToInvariantString(), stack); + } + }); + } + + [SkipUnlessEnvVarFoundFact(OneCollectorInstrumentationKeyEnvName)] + public void LogWithActivityIntegrationTest() + { + using var activity = new Activity("TestOperation"); + activity.Start(); + + this.RunIntegrationTest( + logger => + { + logger.LogInformation("Hello world"); + }, + out var succeeded, + out var actualJson); + + Assert.True(succeeded); + Assert.NotNull(actualJson); + + AssertActualJson( + actualJson, + root => + { + Assert.Equal($"{nameof(OneCollectorIntegrationTests)}.Log", root.GetProperty("name").GetString()); + }, + data => + { + Assert.Equal("Information", data.GetProperty("severityText").GetString()); + Assert.Equal(9, data.GetProperty("severityNumber").GetInt32()); + Assert.Equal("Hello world", data.GetProperty("body").GetString()); + }, + extensions => + { + var distributedTraceExtension = extensions.GetProperty("dt"); + + var traceId = distributedTraceExtension.GetProperty("traceId").GetString(); + var spanId = distributedTraceExtension.GetProperty("spanId").GetString(); + + Assert.Equal(activity.TraceId.ToHexString(), traceId); + Assert.Equal(activity.SpanId.ToHexString(), spanId); + }); + } + + private static void AssertActualJson( + string actualJson, + Action assertRootElement, + Action assertDataElement, + Action? assertExtensionElement = null) + { + var document = JsonDocument.Parse(actualJson); + + var rootElement = document.RootElement; + + Assert.Equal("4.0", rootElement.GetProperty("ver").GetString()); + Assert.True(!string.IsNullOrWhiteSpace(rootElement.GetProperty("time").GetString())); + Assert.True(!string.IsNullOrWhiteSpace(rootElement.GetProperty("iKey").GetString())); + + assertRootElement(rootElement); + + var data = rootElement.GetProperty("data"); + + assertDataElement(data); + + if (assertExtensionElement != null) + { + var extensions = rootElement.GetProperty("ext"); + + assertExtensionElement(extensions); + } + else + { + AssertPropertyDoesNotExist(rootElement, "ext"); + } + } + + private static void AssertPropertyDoesNotExist(JsonElement element, string propertyName) + { + if (element.TryGetProperty(propertyName, out _)) + { + Assert.Fail($"Property '{propertyName}' was found in JSON"); + } + } + + private void RunIntegrationTest( + Action testAction, + out bool succeeded, + out string? actualJson, + Action? configureOptionsAction = null, + Action? configureBuilderAction = null) + { + var innerSucceeded = false; + string? innerActualJson = null; + + using (var loggerFactory = LoggerFactory.Create(logging => logging + .AddOpenTelemetry(options => + { + options + .SetResourceBuilder(ResourceBuilder.CreateEmpty()) + .AddOneCollectorExporter(builder => + { + builder.SetConnectionString($"InstrumentationKey={Environment.GetEnvironmentVariable(OneCollectorInstrumentationKeyEnvName)}"); + + builder.ConfigureExporter(e => e.RegisterPayloadTransmittedCallback(OneCollectorExporterPayloadTransmittedCallbackAction, includeFailures: true)); + + configureBuilderAction?.Invoke(builder); + }); + + configureOptionsAction?.Invoke(options); + }))) + { + testAction(loggerFactory.CreateLogger(nameof(OneCollectorIntegrationTests))); + } + + succeeded = innerSucceeded; + actualJson = innerActualJson; + + this.testOutputHelper.WriteLine($"ActualJson: {actualJson}"); + + void OneCollectorExporterPayloadTransmittedCallbackAction( + in OneCollectorExporterPayloadTransmittedCallbackArguments args) + { + innerSucceeded = args.Succeeded; + using var memoryStream = new MemoryStream(); + args.CopyPayloadToStream(memoryStream); + innerActualJson = Encoding.UTF8.GetString(memoryStream.ToArray()); + } + } +} diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj index e63fc170e3..7870b2458d 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj @@ -20,6 +20,8 @@ + + From d4d77ec286546668da3356e1102cb90e684933c3 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 20 Sep 2023 10:53:55 -0700 Subject: [PATCH 06/15] [OneCollector] 1.6.0-beta.1 release (#1364) --- src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md b/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md index cab0a366f9..46d31e859c 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.6.0-beta.1 + +Released 2023-Sep-20 + * Update OpenTelemetry to 1.6.0 ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) From b923963d9e17b1ce61b2f532454cb783d2cb0c90 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 20 Sep 2023 11:10:20 -0700 Subject: [PATCH 07/15] [repo] Move xunit references for test projects into props (#1363) Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> --- build/Common.nonprod.props | 8 ++++++-- .../OpenTelemetry.Exporter.Geneva.Tests.csproj | 9 --------- .../OpenTelemetry.Exporter.InfluxDB.Tests.csproj | 3 --- .../OpenTelemetry.Exporter.Instana.Tests.csproj | 2 -- .../OpenTelemetry.Exporter.OneCollector.Tests.csproj | 3 --- .../OpenTelemetry.Exporter.Stackdriver.Tests.csproj | 3 --- .../OpenTelemetry.Extensions.AWS.Tests.csproj | 3 --- .../OpenTelemetry.Extensions.Enrichment.Tests.csproj | 6 ------ .../OpenTelemetry.Extensions.Tests.csproj | 6 ------ .../OpenTelemetry.Instrumentation.AWS.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj | 3 --- ...strumentation.AspNet.TelemetryHttpModule.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.AspNet.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.Cassandra.Tests.csproj | 3 --- ...etry.Instrumentation.ElasticsearchClient.Tests.csproj | 4 ---- ...etry.Instrumentation.EntityFrameworkCore.Tests.csproj | 3 --- ...nTelemetry.Instrumentation.EventCounters.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj | 7 ++++--- .../OpenTelemetry.Instrumentation.Hangfire.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.Owin.Tests.csproj | 6 ------ .../OpenTelemetry.Instrumentation.Process.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.Quartz.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.Runtime.Tests.csproj | 3 --- ...metry.Instrumentation.StackExchangeRedis.Tests.csproj | 3 --- .../OpenTelemetry.Instrumentation.Wcf.Tests.csproj | 4 +--- ...enTelemetry.PersistentStorage.FileSystem.Tests.csproj | 5 ----- .../OpenTelemetry.ResourceDetectors.AWS.Tests.csproj | 5 ++--- .../OpenTelemetry.ResourceDetectors.Azure.Tests.csproj | 6 +----- ...penTelemetry.ResourceDetectors.Container.Tests.csproj | 6 ------ .../OpenTelemetry.Sampler.AWS.Tests.csproj | 3 --- 30 files changed, 14 insertions(+), 111 deletions(-) diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props index b82f905d82..df9574bca7 100644 --- a/build/Common.nonprod.props +++ b/build/Common.nonprod.props @@ -32,8 +32,12 @@ [1.5.32,2.0) - - + + + + + + diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj b/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj index 0bfa4aa284..bfffacbcc4 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/OpenTelemetry.Exporter.Geneva.Tests.csproj @@ -16,15 +16,6 @@ - - - - - - - - - diff --git a/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj b/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj index 0a8afbb0b4..87bf79f2a0 100644 --- a/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj +++ b/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj @@ -9,10 +9,7 @@ - - - diff --git a/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj b/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj index 8894e13e55..585b0cf1da 100644 --- a/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Instana.Tests/OpenTelemetry.Exporter.Instana.Tests.csproj @@ -9,8 +9,6 @@ - - diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj index 7870b2458d..67ad9a00f3 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj @@ -9,10 +9,7 @@ - - - diff --git a/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj b/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj index caf7104c03..d0cd829938 100644 --- a/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj @@ -13,8 +13,5 @@ - - - diff --git a/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj b/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj index 7a272b6e5c..75526609ef 100644 --- a/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj +++ b/test/OpenTelemetry.Extensions.AWS.Tests/OpenTelemetry.Extensions.AWS.Tests.csproj @@ -6,10 +6,7 @@ - - - diff --git a/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj b/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj index ea02e4ed0b..e0814e4c98 100644 --- a/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj +++ b/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetry.Extensions.Enrichment.Tests.csproj @@ -7,12 +7,6 @@ disable - - - - - - diff --git a/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj b/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj index f337a44e1e..3b61643e38 100644 --- a/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj +++ b/test/OpenTelemetry.Extensions.Tests/OpenTelemetry.Extensions.Tests.csproj @@ -9,12 +9,6 @@ - - - - - - diff --git a/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj b/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj index 2995cb98a4..f646ccf58e 100644 --- a/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AWS.Tests/OpenTelemetry.Instrumentation.AWS.Tests.csproj @@ -8,11 +8,8 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj index 6e716a4a7a..38af282d51 100644 --- a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/OpenTelemetry.Instrumentation.AWSLambda.Tests.csproj @@ -8,10 +8,7 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj index 8be1376e77..88d63d331b 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj @@ -12,9 +12,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj index ac0591b22c..382363406d 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj @@ -8,9 +8,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj b/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj index 717529ac0a..965d9f2ce6 100644 --- a/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Cassandra.Tests/OpenTelemetry.Instrumentation.Cassandra.Tests.csproj @@ -9,11 +9,8 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj b/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj index f86a5a1482..7b69af190b 100644 --- a/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests/OpenTelemetry.Instrumentation.ElasticsearchClient.Tests.csproj @@ -11,10 +11,6 @@ - - - - diff --git a/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj b/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj index 6efa9fde6f..ac4831069b 100644 --- a/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests.csproj @@ -16,9 +16,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj index 3bed24dd3e..32a467c3b6 100644 --- a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/OpenTelemetry.Instrumentation.EventCounters.Tests.csproj @@ -8,9 +8,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj index aa506d3a03..38995ee86f 100644 --- a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/OpenTelemetry.Instrumentation.GrpcCore.Tests.csproj @@ -4,18 +4,19 @@ net6.0 disable + - - - + + + diff --git a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj index 8b951ec26c..199b37903a 100644 --- a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/OpenTelemetry.Instrumentation.Hangfire.Tests.csproj @@ -10,9 +10,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj b/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj index 2b113bd700..1ef3fee142 100644 --- a/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj @@ -6,12 +6,6 @@ disable - - - - - - diff --git a/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj b/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj index 50bb75e806..6b4c458df2 100644 --- a/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Process.Tests/OpenTelemetry.Instrumentation.Process.Tests.csproj @@ -8,9 +8,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj b/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj index 81596ee50a..856abb3bba 100644 --- a/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Quartz.Tests/OpenTelemetry.Instrumentation.Quartz.Tests.csproj @@ -12,9 +12,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj b/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj index ff5d8c5322..495a08704c 100644 --- a/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Runtime.Tests/OpenTelemetry.Instrumentation.Runtime.Tests.csproj @@ -8,9 +8,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj index dfa8a0ba02..e6f92d872f 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj @@ -21,9 +21,6 @@ - - - diff --git a/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj b/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj index 32a62abd6c..15fd623005 100644 --- a/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Wcf.Tests/OpenTelemetry.Instrumentation.Wcf.Tests.csproj @@ -10,9 +10,6 @@ - - - @@ -33,4 +30,5 @@ + diff --git a/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj b/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj index f3b6f2bb07..5c4dd8508c 100644 --- a/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj +++ b/test/OpenTelemetry.PersistentStorage.FileSystem.Tests/OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj @@ -6,11 +6,6 @@ $(TargetFrameworks);net462 - - - - - diff --git a/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj index 0bfd267363..269f3a5b8a 100644 --- a/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.AWS.Tests/OpenTelemetry.ResourceDetectors.AWS.Tests.csproj @@ -10,9 +10,6 @@ - - - @@ -35,6 +32,7 @@ + PreserveNewest @@ -46,4 +44,5 @@ PreserveNewest + diff --git a/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj index 034ad49ca2..a908c45e6f 100644 --- a/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.Azure.Tests/OpenTelemetry.ResourceDetectors.Azure.Tests.csproj @@ -6,12 +6,8 @@ $(TargetFrameworks);net462 - - - - - + diff --git a/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj index ff9dc21b7b..6977c6ecbe 100644 --- a/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.Container.Tests/OpenTelemetry.ResourceDetectors.Container.Tests.csproj @@ -8,12 +8,6 @@ enable - - - - - - diff --git a/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj b/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj index 24f730fd7b..29b2484d01 100644 --- a/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj +++ b/test/OpenTelemetry.Sampler.AWS.Tests/OpenTelemetry.Sampler.AWS.Tests.csproj @@ -6,9 +6,6 @@ - - - From 21a9bc3871548651e312814c96583c53f9fa7ef6 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 20 Sep 2023 11:42:07 -0700 Subject: [PATCH 08/15] [repo] Add dedicated CI for Geneva Exporter (#1365) --- .github/codecov.yml | 5 ++ .github/workflows/ci-Exporter.Geneva.yml | 57 +++++++++++++++++++ .github/workflows/ci.yml | 3 +- .../OpenTelemetry.Exporter.Geneva.proj | 28 +++++++++ opentelemetry-dotnet-contrib.sln | 2 + 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci-Exporter.Geneva.yml create mode 100644 build/Projects/OpenTelemetry.Exporter.Geneva.proj diff --git a/.github/codecov.yml b/.github/codecov.yml index bf6b155120..e28e1f2fce 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -35,6 +35,11 @@ flags: paths: - src + unittests-Exporter.Geneva: + carryforward: true + paths: + - src/OpenTelemetry.Exporter.Geneva + unittests-Exporter.OneCollector: carryforward: true paths: diff --git a/.github/workflows/ci-Exporter.Geneva.yml b/.github/workflows/ci-Exporter.Geneva.yml new file mode 100644 index 0000000000..7e99774c4c --- /dev/null +++ b/.github/workflows/ci-Exporter.Geneva.yml @@ -0,0 +1,57 @@ +name: Build OpenTelemetry.Exporter.Geneva + +on: + pull_request: + branches: [ 'main*', 'exporter*' ] + paths: + - '*/OpenTelemetry.Exporter.Geneva*/**' + - 'build/**' + - '!**.md' + +env: + PROJECT: OpenTelemetry.Exporter.Geneva + +jobs: + build-test: + + strategy: + fail-fast: false # ensures the entire test matrix is run, even if one permutation fails + matrix: + os: [ windows-latest, ubuntu-latest ] + version: [ net462, net6.0, net7.0 ] + exclude: + - os: ubuntu-latest + version: net462 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + + - name: dotnet restore build/Projects/${{env.PROJECT}}.proj + run: dotnet restore build/Projects/${{env.PROJECT}}.proj + + - name: dotnet build build/Projects/${{env.PROJECT}}.proj + run: dotnet build build/Projects/${{env.PROJECT}}.proj --configuration Release --no-restore + + - name: dotnet test test/${{env.PROJECT}}.Tests + run: dotnet test test/${{env.PROJECT}}.Tests --collect:"Code Coverage" --results-directory:TestResults --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true + + - name: Install coverage tool + run: dotnet tool install -g dotnet-coverage + + - name: Merging test results + run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage + + - uses: codecov/codecov-action@v3.1.4 + continue-on-error: true # Note: Don't fail for upload failures + env: + OS: ${{ matrix.os }} + TFM: ${{ matrix.version }} + with: + file: TestResults/Cobertura.xml + env_vars: OS,TFM + flags: unittests-Exporter.Geneva + name: Code Coverage for Exporter.Geneva on [${{ matrix.os }}.${{ matrix.version }}] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a67fa19e3c..f0985545b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ on: paths-ignore: - '**.md' - '*/OpenTelemetry.Instrumentation.Process*/**' + - '*/OpenTelemetry.Exporter.Geneva*/**' - '*/OpenTelemetry.Exporter.OneCollector*/**' jobs: @@ -38,7 +39,7 @@ jobs: run: | $projects = Get-ChildItem ` -Path test/*.Tests/*.csproj ` - -Exclude OpenTelemetry.Instrumentation.Process.Tests.csproj, OpenTelemetry.Exporter.OneCollector.Tests.csproj + -Exclude OpenTelemetry.Instrumentation.Process.Tests.csproj, OpenTelemetry.Exporter.Geneva.Tests.csproj, OpenTelemetry.Exporter.OneCollector.Tests.csproj ForEach ($project in $projects) { diff --git a/build/Projects/OpenTelemetry.Exporter.Geneva.proj b/build/Projects/OpenTelemetry.Exporter.Geneva.proj new file mode 100644 index 0000000000..dc1e79aafa --- /dev/null +++ b/build/Projects/OpenTelemetry.Exporter.Geneva.proj @@ -0,0 +1,28 @@ + + + + $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName) + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 18622206c3..da36821074 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -29,6 +29,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ ProjectSection(SolutionItems) = preProject .github\workflows\assign-reviewers.yml = .github\workflows\assign-reviewers.yml .github\workflows\ci-aot.yml = .github\workflows\ci-aot.yml + .github\workflows\ci-Exporter.Geneva.yml = .github\workflows\ci-Exporter.Geneva.yml .github\workflows\ci-Exporter.OneCollector-Integration.yml = .github\workflows\ci-Exporter.OneCollector-Integration.yml .github\workflows\ci-Exporter.OneCollector.yml = .github\workflows\ci-Exporter.OneCollector.yml .github\workflows\ci-Instrumentation.Process.yml = .github\workflows\ci-Instrumentation.Process.yml @@ -304,6 +305,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{9B EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{048509D6-FB49-4B84-832A-90E55520B97B}" ProjectSection(SolutionItems) = preProject + build\Projects\OpenTelemetry.Exporter.Geneva.proj = build\Projects\OpenTelemetry.Exporter.Geneva.proj build\Projects\OpenTelemetry.Exporter.OneCollector.proj = build\Projects\OpenTelemetry.Exporter.OneCollector.proj EndProjectSection EndProject From f1d19398539145fbd2621a86e31a5a2c033f95e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 20 Sep 2023 22:26:48 +0200 Subject: [PATCH 09/15] Fix issue of multiple instances of OpenTelemetry-Instrumentation EventSource being created (#1362) --- build/Common.props | 10 ++-- .../CHANGELOG.md | 3 + .../ElasticsearchClientInstrumentation.cs | 2 +- ...ElasticsearchInstrumentationEventSource.cs | 17 +++++- ...Instrumentation.ElasticsearchClient.csproj | 1 + .../CHANGELOG.md | 4 ++ .../EntityFrameworkInstrumentation.cs | 3 +- ...tityFrameworkInstrumentationEventSource.cs | 2 +- ...Instrumentation.EntityFrameworkCore.csproj | 1 + .../CHANGELOG.md | 3 + .../QuartzInstrumentationEventSource.cs | 15 +++++ ...penTelemetry.Instrumentation.Quartz.csproj | 1 + .../QuartzJobInstrumentation.cs | 3 +- src/Shared/DiagnosticSourceListener.cs | 7 ++- src/Shared/DiagnosticSourceSubscriber.cs | 16 +++--- src/Shared/InstrumentationEventSource.cs | 55 ------------------- 16 files changed, 70 insertions(+), 73 deletions(-) delete mode 100644 src/Shared/InstrumentationEventSource.cs diff --git a/build/Common.props b/build/Common.props index 7ed5728f63..e57d37e80c 100644 --- a/build/Common.props +++ b/build/Common.props @@ -60,10 +60,6 @@ - - - - @@ -71,6 +67,12 @@ + + + + + + diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md index fad5bc76af..d063132527 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Fix issue of multiple instances of OpenTelemetry-Instrumentation EventSource + being created + ([#1362](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1362)) * Updated OpenTelemetry SDK package version to 1.6.0 ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentation.cs b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentation.cs index 42d4241f73..a1269567c5 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentation.cs +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentation.cs @@ -31,7 +31,7 @@ internal class ElasticsearchClientInstrumentation : IDisposable /// Configuration options for Elasticsearch client instrumentation. public ElasticsearchClientInstrumentation(ElasticsearchClientInstrumentationOptions options) { - this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new ElasticsearchRequestPipelineDiagnosticListener(options), null); + this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new ElasticsearchRequestPipelineDiagnosticListener(options), null, ElasticsearchInstrumentationEventSource.Log.UnknownErrorProcessingEvent); this.diagnosticSourceSubscriber.Subscribe(); } diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchInstrumentationEventSource.cs b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchInstrumentationEventSource.cs index ecbc51ad4a..757eb90ce9 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchInstrumentationEventSource.cs +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchInstrumentationEventSource.cs @@ -26,7 +26,7 @@ namespace OpenTelemetry.Instrumentation.ElasticsearchClient.Implementation; [EventSource(Name = "OpenTelemetry-Instrumentation-Elasticsearch")] internal class ElasticsearchInstrumentationEventSource : EventSource { - public static ElasticsearchInstrumentationEventSource Log = new ElasticsearchInstrumentationEventSource(); + public static ElasticsearchInstrumentationEventSource Log = new(); [Event(1, Message = "Payload is NULL in event '{1}' from handler '{0}', span will not be recorded.", Level = EventLevel.Warning)] public void NullPayload(string handlerName, string eventName) @@ -48,4 +48,19 @@ public void EnrichmentException(string exception) { this.WriteEvent(2, exception); } + + [NonEvent] + public void UnknownErrorProcessingEvent(string handlerName, string eventName, Exception ex) + { + if (this.IsEnabled(EventLevel.Error, (EventKeywords)(-1))) + { + this.UnknownErrorProcessingEvent(handlerName, eventName, ex.ToInvariantString()); + } + } + + [Event(3, Message = "Unknown error processing event '{1}' from handler '{0}', Exception: {2}", Level = EventLevel.Error)] + public void UnknownErrorProcessingEvent(string handlerName, string eventName, string ex) + { + this.WriteEvent(3, handlerName, eventName, ex); + } } diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj index 3777bb7516..63005a2e97 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj @@ -8,6 +8,7 @@ Instrumentation.ElasticsearchClient- true true + true disable diff --git a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md index c6b9ff81d9..e2e2bbc727 100644 --- a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md @@ -9,6 +9,10 @@ * Updated OpenTelemetry SDK package version to 1.6.0 ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) +* Fix issue of multiple instances of OpenTelemetry-Instrumentation EventSource + being created + ([#1362](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1362)) + ## 1.0.0-beta.7 Released 2023-Jun-09 diff --git a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/EntityFrameworkInstrumentation.cs b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/EntityFrameworkInstrumentation.cs index 5f2a439188..30181f72b1 100644 --- a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/EntityFrameworkInstrumentation.cs +++ b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/EntityFrameworkInstrumentation.cs @@ -28,7 +28,8 @@ public EntityFrameworkInstrumentation(EntityFrameworkInstrumentationOptions opti this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber( name => new EntityFrameworkDiagnosticListener(name, options), listener => listener.Name == EntityFrameworkDiagnosticListener.DiagnosticSourceName, - null); + null, + EntityFrameworkInstrumentationEventSource.Log.UnknownErrorProcessingEvent); this.diagnosticSourceSubscriber.Subscribe(); } diff --git a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/Implementation/EntityFrameworkInstrumentationEventSource.cs b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/Implementation/EntityFrameworkInstrumentationEventSource.cs index 4736821a16..bb4960791e 100644 --- a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/Implementation/EntityFrameworkInstrumentationEventSource.cs +++ b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/Implementation/EntityFrameworkInstrumentationEventSource.cs @@ -23,7 +23,7 @@ namespace OpenTelemetry.Instrumentation.EntityFrameworkCore.Implementation; [EventSource(Name = "OpenTelemetry-Instrumentation-EntityFrameworkCore")] internal class EntityFrameworkInstrumentationEventSource : EventSource { - public static EntityFrameworkInstrumentationEventSource Log = new EntityFrameworkInstrumentationEventSource(); + public static EntityFrameworkInstrumentationEventSource Log = new(); [NonEvent] public void UnknownErrorProcessingEvent(string handlerName, string eventName, Exception ex) diff --git a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj index 3906fcc898..a15af04bf1 100644 --- a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj +++ b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj @@ -6,6 +6,7 @@ Instrumentation.EntityFrameworkCore- true true + true disable diff --git a/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md index b31ff113c4..4676dee4af 100644 --- a/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Fix issue of multiple instances of OpenTelemetry-Instrumentation EventSource + being created + ([#1362](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1362)) * Update OpenTelemetry.Api to 1.6.0. ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) diff --git a/src/OpenTelemetry.Instrumentation.Quartz/Implementation/QuartzInstrumentationEventSource.cs b/src/OpenTelemetry.Instrumentation.Quartz/Implementation/QuartzInstrumentationEventSource.cs index a0e0d26293..03a88401fd 100644 --- a/src/OpenTelemetry.Instrumentation.Quartz/Implementation/QuartzInstrumentationEventSource.cs +++ b/src/OpenTelemetry.Instrumentation.Quartz/Implementation/QuartzInstrumentationEventSource.cs @@ -54,4 +54,19 @@ public void EnrichmentException(string exception) { this.WriteEvent(3, exception); } + + [NonEvent] + public void UnknownErrorProcessingEvent(string handlerName, string eventName, Exception ex) + { + if (this.IsEnabled(EventLevel.Error, (EventKeywords)(-1))) + { + this.UnknownErrorProcessingEvent(handlerName, eventName, ex.ToInvariantString()); + } + } + + [Event(4, Message = "Unknown error processing event '{1}' from handler '{0}', Exception: {2}", Level = EventLevel.Error)] + public void UnknownErrorProcessingEvent(string handlerName, string eventName, string ex) + { + this.WriteEvent(4, handlerName, eventName, ex); + } } diff --git a/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj b/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj index c794f15c85..49c2b03d7d 100644 --- a/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj +++ b/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj @@ -6,6 +6,7 @@ true netstandard2.0 true + true diff --git a/src/OpenTelemetry.Instrumentation.Quartz/QuartzJobInstrumentation.cs b/src/OpenTelemetry.Instrumentation.Quartz/QuartzJobInstrumentation.cs index 2ab0ca89d6..d33e6692bb 100644 --- a/src/OpenTelemetry.Instrumentation.Quartz/QuartzJobInstrumentation.cs +++ b/src/OpenTelemetry.Instrumentation.Quartz/QuartzJobInstrumentation.cs @@ -34,7 +34,8 @@ public QuartzJobInstrumentation(QuartzInstrumentationOptions options) this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber( name => new QuartzDiagnosticListener(name, options), listener => listener.Name == QuartzDiagnosticListenerName, - null); + null, + QuartzInstrumentationEventSource.Log.UnknownErrorProcessingEvent); this.diagnosticSourceSubscriber.Subscribe(); } diff --git a/src/Shared/DiagnosticSourceListener.cs b/src/Shared/DiagnosticSourceListener.cs index 38a6ee2410..3c16815cc7 100644 --- a/src/Shared/DiagnosticSourceListener.cs +++ b/src/Shared/DiagnosticSourceListener.cs @@ -29,11 +29,14 @@ internal sealed class DiagnosticSourceListener : IObserver logUnknownException; + + public DiagnosticSourceListener(ListenerHandler handler, Action logUnknownException) { Guard.ThrowIfNull(handler); this.handler = handler; + this.logUnknownException = logUnknownException; } public void OnCompleted() @@ -72,7 +75,7 @@ public void OnNext(KeyValuePair value) } catch (Exception ex) { - InstrumentationEventSource.Log.UnknownErrorProcessingEvent(this.handler?.SourceName, value.Key, ex); + this.logUnknownException?.Invoke(this.handler?.SourceName, value.Key, ex); } } } diff --git a/src/Shared/DiagnosticSourceSubscriber.cs b/src/Shared/DiagnosticSourceSubscriber.cs index 5435b90a3f..c0d931652f 100644 --- a/src/Shared/DiagnosticSourceSubscriber.cs +++ b/src/Shared/DiagnosticSourceSubscriber.cs @@ -26,28 +26,29 @@ namespace OpenTelemetry.Instrumentation; -#pragma warning disable CA1812 internal sealed class DiagnosticSourceSubscriber : IDisposable, IObserver -#pragma warning restore CA1812 { + private readonly List listenerSubscriptions; private readonly Func handlerFactory; private readonly Func diagnosticSourceFilter; private readonly Func isEnabledFilter; + private readonly Action logUnknownException; private long disposed; private IDisposable allSourcesSubscription; - private List listenerSubscriptions; public DiagnosticSourceSubscriber( ListenerHandler handler, - Func isEnabledFilter) - : this(_ => handler, value => handler.SourceName == value.Name, isEnabledFilter) + Func isEnabledFilter, + Action logUnknownException) + : this(_ => handler, value => handler.SourceName == value.Name, isEnabledFilter, logUnknownException) { } public DiagnosticSourceSubscriber( Func handlerFactory, Func diagnosticSourceFilter, - Func isEnabledFilter) + Func isEnabledFilter, + Action logUnknownException) { Guard.ThrowIfNull(handlerFactory); @@ -55,6 +56,7 @@ public DiagnosticSourceSubscriber( this.handlerFactory = handlerFactory; this.diagnosticSourceFilter = diagnosticSourceFilter; this.isEnabledFilter = isEnabledFilter; + this.logUnknownException = logUnknownException; } public void Subscribe() @@ -71,7 +73,7 @@ public void OnNext(DiagnosticListener value) this.diagnosticSourceFilter(value)) { var handler = this.handlerFactory(value.Name); - var listener = new DiagnosticSourceListener(handler); + var listener = new DiagnosticSourceListener(handler, this.logUnknownException); var subscription = this.isEnabledFilter == null ? value.Subscribe(listener) : value.Subscribe(listener, this.isEnabledFilter); diff --git a/src/Shared/InstrumentationEventSource.cs b/src/Shared/InstrumentationEventSource.cs deleted file mode 100644 index 4321679472..0000000000 --- a/src/Shared/InstrumentationEventSource.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#nullable disable - -#pragma warning disable IDE0005 // Using directive is unnecessary. -using System; -using System.Diagnostics.Tracing; -using OpenTelemetry.Internal; -#pragma warning restore IDE0005 // Using directive is unnecessary. - -namespace OpenTelemetry.Instrumentation; - -/// -/// EventSource events emitted from the project. -/// -[EventSource(Name = "OpenTelemetry-Instrumentation")] -internal sealed class InstrumentationEventSource : EventSource -{ - public static InstrumentationEventSource Log = new InstrumentationEventSource(); - - [Event(1, Message = "Current Activity is NULL in the '{0}' callback. Activity will not be recorded.", Level = EventLevel.Warning)] - public void NullActivity(string eventName) - { - this.WriteEvent(1, eventName); - } - - [NonEvent] - public void UnknownErrorProcessingEvent(string handlerName, string eventName, Exception ex) - { - if (this.IsEnabled(EventLevel.Error, (EventKeywords)(-1))) - { - this.UnknownErrorProcessingEvent(handlerName, eventName, ex.ToInvariantString()); - } - } - - [Event(2, Message = "Unknown error processing event '{1}' from handler '{0}', Exception: {2}", Level = EventLevel.Error)] - public void UnknownErrorProcessingEvent(string handlerName, string eventName, string ex) - { - this.WriteEvent(2, handlerName, eventName, ex); - } -} From 5cb78d496de5e47b0d3cc4da4142128cb95b8f71 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 22 Sep 2023 10:09:33 -0700 Subject: [PATCH 10/15] [repo] Use reusable workflows for build & package processing (#1368) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Piotr Kiełkowicz --- .github/workflows/Component.BuildTest.yml | 61 +++++++++++++++++++ .github/workflows/Component.Package.yml | 60 ++++++++++++++++++ .github/workflows/ci-Exporter.Geneva.yml | 51 ++-------------- .../workflows/ci-Exporter.OneCollector.yml | 51 ++-------------- .../workflows/ci-Instrumentation.Process.yml | 50 ++------------- .github/workflows/package-Exporter.Geneva.yml | 55 ++--------------- .../package-Exporter.OneCollector.yml | 57 ++--------------- .../package-Instrumentation.Process.yml | 55 ++--------------- ...OpenTelemetry.Instrumentation.Process.proj | 26 ++++++++ opentelemetry-dotnet-contrib.sln | 3 + 10 files changed, 180 insertions(+), 289 deletions(-) create mode 100644 .github/workflows/Component.BuildTest.yml create mode 100644 .github/workflows/Component.Package.yml create mode 100644 build/Projects/OpenTelemetry.Instrumentation.Process.proj diff --git a/.github/workflows/Component.BuildTest.yml b/.github/workflows/Component.BuildTest.yml new file mode 100644 index 0000000000..b257db5d1d --- /dev/null +++ b/.github/workflows/Component.BuildTest.yml @@ -0,0 +1,61 @@ +name: Build Component + +on: + workflow_call: + inputs: + project-name: + required: true + type: string + code-cov-name: + required: true + type: string + code-cov-prefix: + default: 'unittests' + required: false + type: string + +jobs: + build-test: + + strategy: + fail-fast: false # ensures the entire test matrix is run, even if one permutation fails + matrix: + os: [ windows-latest, ubuntu-latest ] + version: [ net462, net6.0, net7.0 ] + exclude: + - os: ubuntu-latest + version: net462 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + + - name: dotnet restore build/Projects/${{ inputs.project-name }}.proj + run: dotnet restore build/Projects/${{ inputs.project-name }}.proj + + - name: dotnet build build/Projects/${{ inputs.project-name }}.proj + run: dotnet build build/Projects/${{ inputs.project-name }}.proj --configuration Release --no-restore + + - name: dotnet test test/${{ inputs.project-name }}.Tests + run: dotnet test test/${{ inputs.project-name }}.Tests --collect:"Code Coverage" --results-directory:TestResults --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true + + - name: Install coverage tool + run: dotnet tool install -g dotnet-coverage + + - name: Merging test results + run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage + + - name: Upload code coverage ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} + uses: codecov/codecov-action@v3.1.4 + continue-on-error: true # Note: Don't fail for upload failures + env: + OS: ${{ matrix.os }} + TFM: ${{ matrix.version }} + with: + file: TestResults/Cobertura.xml + env_vars: OS,TFM + flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} + name: Code Coverage for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}] diff --git a/.github/workflows/Component.Package.yml b/.github/workflows/Component.Package.yml new file mode 100644 index 0000000000..86fbccca33 --- /dev/null +++ b/.github/workflows/Component.Package.yml @@ -0,0 +1,60 @@ +name: Pack Component + +on: + workflow_call: + inputs: + project-name: + required: true + type: string + +jobs: + build-test-pack: + permissions: + contents: write + + strategy: + matrix: + os: [windows-latest] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetching all + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + + - name: dotnet restore build/Projects/${{ inputs.project-name }}.proj + run: dotnet restore build/Projects/${{ inputs.project-name }}.proj + + - name: dotnet build build/Projects/${{ inputs.project-name }}.proj + run: dotnet build build/Projects/${{ inputs.project-name }}.proj --configuration Release --no-restore -p:Deterministic=true + + - name: dotnet test test/${{ inputs.project-name }}.Tests + run: dotnet test test/${{ inputs.project-name }}.Tests --configuration Release --no-restore --no-build + + - name: dotnet pack build/Projects/${{ inputs.project-name }}.proj + run: dotnet pack build/Projects/${{ inputs.project-name }}.proj --configuration Release --no-build --no-restore + + - name: Publish Artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.project-name }}-packages + path: '**/${{ inputs.project-name }}/bin/**/*.*nupkg' + + - name: Publish Nuget + run: | + nuget push **/${{ inputs.project-name }}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} + + - name: Create GitHub Prerelease + if: ${{ (contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc')) }} + run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{ inputs.project-name }}/CHANGELOG.md) for details." --prerelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create GitHub Release + if: ${{ !(contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc')) }} + run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{ inputs.project-name }}/CHANGELOG.md) for details." --latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci-Exporter.Geneva.yml b/.github/workflows/ci-Exporter.Geneva.yml index 7e99774c4c..f847305179 100644 --- a/.github/workflows/ci-Exporter.Geneva.yml +++ b/.github/workflows/ci-Exporter.Geneva.yml @@ -8,50 +8,9 @@ on: - 'build/**' - '!**.md' -env: - PROJECT: OpenTelemetry.Exporter.Geneva - jobs: - build-test: - - strategy: - fail-fast: false # ensures the entire test matrix is run, even if one permutation fails - matrix: - os: [ windows-latest, ubuntu-latest ] - version: [ net462, net6.0, net7.0 ] - exclude: - - os: ubuntu-latest - version: net462 - - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: dotnet restore build/Projects/${{env.PROJECT}}.proj - run: dotnet restore build/Projects/${{env.PROJECT}}.proj - - - name: dotnet build build/Projects/${{env.PROJECT}}.proj - run: dotnet build build/Projects/${{env.PROJECT}}.proj --configuration Release --no-restore - - - name: dotnet test test/${{env.PROJECT}}.Tests - run: dotnet test test/${{env.PROJECT}}.Tests --collect:"Code Coverage" --results-directory:TestResults --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true - - - name: Install coverage tool - run: dotnet tool install -g dotnet-coverage - - - name: Merging test results - run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage - - - uses: codecov/codecov-action@v3.1.4 - continue-on-error: true # Note: Don't fail for upload failures - env: - OS: ${{ matrix.os }} - TFM: ${{ matrix.version }} - with: - file: TestResults/Cobertura.xml - env_vars: OS,TFM - flags: unittests-Exporter.Geneva - name: Code Coverage for Exporter.Geneva on [${{ matrix.os }}.${{ matrix.version }}] + call-build-test: + uses: ./.github/workflows/Component.BuildTest.yml + with: + project-name: OpenTelemetry.Exporter.Geneva + code-cov-name: Exporter.Geneva diff --git a/.github/workflows/ci-Exporter.OneCollector.yml b/.github/workflows/ci-Exporter.OneCollector.yml index 7af1185e2c..d652649d63 100644 --- a/.github/workflows/ci-Exporter.OneCollector.yml +++ b/.github/workflows/ci-Exporter.OneCollector.yml @@ -8,50 +8,9 @@ on: - 'build/**' - '!**.md' -env: - PROJECT: OpenTelemetry.Exporter.OneCollector - jobs: - build-test: - - strategy: - fail-fast: false # ensures the entire test matrix is run, even if one permutation fails - matrix: - os: [ windows-latest, ubuntu-latest ] - version: [ net462, net6.0, net7.0 ] - exclude: - - os: ubuntu-latest - version: net462 - - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: dotnet restore build/Projects/${{env.PROJECT}}.proj - run: dotnet restore build/Projects/${{env.PROJECT}}.proj - - - name: dotnet build build/Projects/${{env.PROJECT}}.proj - run: dotnet build build/Projects/${{env.PROJECT}}.proj --configuration Release --no-restore - - - name: dotnet test test/${{env.PROJECT}}.Tests - run: dotnet test test/${{env.PROJECT}}.Tests --collect:"Code Coverage" --results-directory:TestResults --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true - - - name: Install coverage tool - run: dotnet tool install -g dotnet-coverage - - - name: Merging test results - run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage - - - uses: codecov/codecov-action@v3.1.4 - continue-on-error: true # Note: Don't fail for upload failures - env: - OS: ${{ matrix.os }} - TFM: ${{ matrix.version }} - with: - file: TestResults/Cobertura.xml - env_vars: OS,TFM - flags: unittests-Exporter.OneCollector - name: Code Coverage for Exporter.OneCollector on [${{ matrix.os }}.${{ matrix.version }}] + call-build-test: + uses: ./.github/workflows/Component.BuildTest.yml + with: + project-name: OpenTelemetry.Exporter.OneCollector + code-cov-name: Exporter.OneCollector diff --git a/.github/workflows/ci-Instrumentation.Process.yml b/.github/workflows/ci-Instrumentation.Process.yml index d0db0b9c39..63c394e1aa 100644 --- a/.github/workflows/ci-Instrumentation.Process.yml +++ b/.github/workflows/ci-Instrumentation.Process.yml @@ -8,50 +8,10 @@ on: - 'build/**' - '!**.md' -env: - PROJECT: OpenTelemetry.Instrumentation.Process - jobs: - build-test: - - strategy: - fail-fast: false # ensures the entire test matrix is run, even if one permutation fails - matrix: - os: [ windows-latest, ubuntu-latest ] - version: [ net462, net6.0, net7.0 ] - exclude: - - os: ubuntu-latest - version: net462 - - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: dotnet restore test/${{ env.PROJECT }}.Tests - run: dotnet restore test/${{ env.PROJECT }}.Tests - - - name: dotnet build test/${{ env.PROJECT }}.Tests - run: dotnet build test/${{ env.PROJECT }}.Tests --configuration Release --no-restore - - - name: dotnet test test/${{ env.PROJECT }}.Tests - run: dotnet test test/${{ env.PROJECT }}.Tests --collect:"Code Coverage" --results-directory:"TestResults" --framework ${{ matrix.version }} --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true - - - name: Install coverage tool - run: dotnet tool install -g dotnet-coverage - - - name: Merging test results - run: dotnet-coverage merge -r -f cobertura -o ./TestResults/Cobertura.xml ./TestResults/*.coverage + call-build-test: + uses: ./.github/workflows/Component.BuildTest.yml + with: + project-name: OpenTelemetry.Instrumentation.Process + code-cov-name: Instrumentation.Process - - uses: codecov/codecov-action@v3.1.4 - continue-on-error: true # Note: Don't fail for upload failures - env: - OS: ${{ matrix.os }} - TFM: ${{ matrix.version }} - with: - file: TestResults/Cobertura.xml - env_vars: OS,TFM - flags: unittests-Instrumentation.Process - name: Code Coverage for Instrumentation.Process on [${{ matrix.os }}.${{ matrix.version }}] diff --git a/.github/workflows/package-Exporter.Geneva.yml b/.github/workflows/package-Exporter.Geneva.yml index af95b2db72..48cbe29db8 100644 --- a/.github/workflows/package-Exporter.Geneva.yml +++ b/.github/workflows/package-Exporter.Geneva.yml @@ -12,55 +12,10 @@ on: - 'Exporter.Geneva-*' # trigger when we create a tag with prefix "Exporter.Geneva-" jobs: - build-test-pack: - runs-on: ${{ matrix.os }} + call-build-test-pack: permissions: contents: write - env: - PROJECT: OpenTelemetry.Exporter.Geneva - - strategy: - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: Install dependencies - run: dotnet restore src/${{env.PROJECT}} - - - name: dotnet build ${{env.PROJECT}} - run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true - - - name: dotnet test ${{env.PROJECT}} - run: dotnet test test/${{env.PROJECT}}.Tests - - - name: dotnet pack ${{env.PROJECT}} - run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{env.PROJECT}}-packages - path: '**/${{env.PROJECT}}/bin/**/*.*nupkg' - - - name: Publish Nuget - run: | - nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/Component.Package.yml + with: + project-name: OpenTelemetry.Exporter.Geneva + secrets: inherit diff --git a/.github/workflows/package-Exporter.OneCollector.yml b/.github/workflows/package-Exporter.OneCollector.yml index 216cfe1bbb..c347c44a89 100644 --- a/.github/workflows/package-Exporter.OneCollector.yml +++ b/.github/workflows/package-Exporter.OneCollector.yml @@ -12,57 +12,10 @@ on: - 'Exporter.OneCollector-*' # trigger when we create a tag with prefix "Exporter.OneCollector-" jobs: - build-test-pack: - runs-on: ${{ matrix.os }} + call-build-test-pack: permissions: contents: write - env: - PROJECT: OpenTelemetry.Exporter.OneCollector - - strategy: - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: dotnet restore build/Projects/${{env.PROJECT}}.proj - run: dotnet restore build/Projects/${{env.PROJECT}}.proj - - - name: dotnet build build/Projects/${{env.PROJECT}}.proj - run: dotnet build build/Projects/${{env.PROJECT}}.proj --configuration Release --no-restore -p:Deterministic=true - - - name: dotnet test test/${{env.PROJECT}}.Tests - run: dotnet test test/${{env.PROJECT}}.Tests --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" - env: - OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY: ${{ secrets.OTEL_ONECOLLECTOR_INSTRUMENTATION_KEY }} - - - name: dotnet pack build/Projects/${{env.PROJECT}}.proj - run: dotnet pack build/Projects/${{env.PROJECT}}.proj --configuration Release --no-build --no-restore - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{env.PROJECT}}-packages - path: '**/${{env.PROJECT}}/bin/**/*.*nupkg' - - - name: Publish Nuget - run: | - nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/Component.Package.yml + with: + project-name: OpenTelemetry.Exporter.OneCollector + secrets: inherit diff --git a/.github/workflows/package-Instrumentation.Process.yml b/.github/workflows/package-Instrumentation.Process.yml index 83e444bd4a..413157463f 100644 --- a/.github/workflows/package-Instrumentation.Process.yml +++ b/.github/workflows/package-Instrumentation.Process.yml @@ -12,55 +12,10 @@ on: - 'Instrumentation.Process-*' # trigger when we create a tag with prefix "Instrumentation.Process-" jobs: - build-test-pack: - runs-on: ${{ matrix.os }} + call-build-test-pack: permissions: contents: write - env: - PROJECT: OpenTelemetry.Instrumentation.Process - - strategy: - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: Install dependencies - run: dotnet restore src/${{env.PROJECT}} - - - name: dotnet build ${{env.PROJECT}} - run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true - - - name: dotnet test ${{env.PROJECT}} - run: dotnet test test/${{env.PROJECT}}.Tests - - - name: dotnet pack ${{env.PROJECT}} - run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{env.PROJECT}}-packages - path: '**/${{env.PROJECT}}/bin/**/*.*nupkg' - - - name: Publish Nuget - run: | - nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/Component.Package.yml + with: + project-name: OpenTelemetry.Instrumentation.Process + secrets: inherit diff --git a/build/Projects/OpenTelemetry.Instrumentation.Process.proj b/build/Projects/OpenTelemetry.Instrumentation.Process.proj new file mode 100644 index 0000000000..11f52d18e7 --- /dev/null +++ b/build/Projects/OpenTelemetry.Instrumentation.Process.proj @@ -0,0 +1,26 @@ + + + + $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName) + + + + + + + + + + + + + + + + + + + + + + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index da36821074..de4e8a202c 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -36,7 +36,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\ci-md.yml = .github\workflows\ci-md.yml .github\workflows\ci.yml = .github\workflows\ci.yml .github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml + .github\workflows\Component.Package.yml = .github\workflows\Component.Package.yml .github\workflows\dotnet-core-cov.yml = .github\workflows\dotnet-core-cov.yml + .github\workflows\Component.BuildTest.yml = .github\workflows\Component.BuildTest.yml .github\workflows\dotnet-format-md.yml = .github\workflows\dotnet-format-md.yml .github\workflows\dotnet-format.yml = .github\workflows\dotnet-format.yml .github\workflows\integration-md.yml = .github\workflows\integration-md.yml @@ -307,6 +309,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{04 ProjectSection(SolutionItems) = preProject build\Projects\OpenTelemetry.Exporter.Geneva.proj = build\Projects\OpenTelemetry.Exporter.Geneva.proj build\Projects\OpenTelemetry.Exporter.OneCollector.proj = build\Projects\OpenTelemetry.Exporter.OneCollector.proj + build\Projects\OpenTelemetry.Instrumentation.Process.proj = build\Projects\OpenTelemetry.Instrumentation.Process.proj EndProjectSection EndProject Global From 5782da17af6292be22910705882bd6f5edb10efb Mon Sep 17 00:00:00 2001 From: Julian Dominguez Date: Fri, 22 Sep 2023 14:45:08 -0300 Subject: [PATCH 11/15] Allow overriding the Part B "name" field value in GenevaLogExporter (#1367) Co-authored-by: Cijo Thomas --- .../CHANGELOG.md | 3 + .../MsgPackExporter/MsgPackLogExporter.cs | 23 ++- .../TLDExporter/TldLogExporter.cs | 23 ++- .../GenevaLogExporterTests.cs | 136 ++++++++++++++++++ 4 files changed, 178 insertions(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index 58df50d08c..be3ad3c9f5 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Allow overriding the Part B "name" field value in GenevaLogExporter. + ([#1367](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1367)) + ## 1.6.0 Released 2023-Sep-09 diff --git a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs index 9dcb291b18..6542e00320 100644 --- a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs +++ b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs @@ -259,12 +259,9 @@ internal int SerializeLogRecord(LogRecord logRecord) cursor = MessagePackSerializer.SerializeUInt8(buffer, cursor, GetSeverityNumber(logLevel)); cntFields += 1; - cursor = MessagePackSerializer.SerializeAsciiString(buffer, cursor, "name"); - cursor = MessagePackSerializer.SerializeUnicodeString(buffer, cursor, categoryName); - cntFields += 1; - bool hasEnvProperties = false; bool bodyPopulated = false; + bool namePopulated = false; for (int i = 0; i < listKvp?.Count; i++) { var entry = listKvp[i]; @@ -285,6 +282,17 @@ internal int SerializeLogRecord(LogRecord logRecord) if (entry.Value != null) { // null is not supported. + if (string.Equals(entry.Key, "name", StringComparison.Ordinal)) + { + if (!(entry.Value is string)) + { + // name must be string according to Part B in Common Schema. Skip serializing this field otherwise + continue; + } + + namePopulated = true; + } + cursor = MessagePackSerializer.SerializeUnicodeString(buffer, cursor, entry.Key); cursor = MessagePackSerializer.Serialize(buffer, cursor, entry.Value); cntFields += 1; @@ -297,6 +305,13 @@ internal int SerializeLogRecord(LogRecord logRecord) } } + if (!namePopulated) + { + cursor = MessagePackSerializer.SerializeAsciiString(buffer, cursor, "name"); + cursor = MessagePackSerializer.SerializeUnicodeString(buffer, cursor, categoryName); + cntFields += 1; + } + if (!bodyPopulated && logRecord.FormattedMessage != null) { cursor = MessagePackSerializer.SerializeAsciiString(buffer, cursor, "body"); diff --git a/src/OpenTelemetry.Exporter.Geneva/TLDExporter/TldLogExporter.cs b/src/OpenTelemetry.Exporter.Geneva/TLDExporter/TldLogExporter.cs index 46cc2cefb0..5e01f79c8b 100644 --- a/src/OpenTelemetry.Exporter.Geneva/TLDExporter/TldLogExporter.cs +++ b/src/OpenTelemetry.Exporter.Geneva/TLDExporter/TldLogExporter.cs @@ -301,7 +301,6 @@ internal void SerializeLogRecord(LogRecord logRecord) eb.AddCountedString("severityText", logLevels[(int)logLevel]); eb.AddUInt8("severityNumber", GetSeverityNumber(logLevel)); - eb.AddCountedAnsiString("name", categoryName, Encoding.UTF8); var eventId = logRecord.EventId; if (eventId != default) @@ -312,6 +311,7 @@ internal void SerializeLogRecord(LogRecord logRecord) byte hasEnvProperties = 0; bool bodyPopulated = false; + bool namePopulated = false; byte partCFieldsCountFromState = 0; var kvpArrayForPartCFields = partCFields.Value; @@ -342,8 +342,20 @@ internal void SerializeLogRecord(LogRecord logRecord) if (entry.Value != null) { // null is not supported. - kvpArrayForPartCFields[partCFieldsCountFromState] = new(entry.Key, entry.Value); - partCFieldsCountFromState++; + if (string.Equals(entry.Key, "name", StringComparison.Ordinal)) + { + if (entry.Value is string nameValue) + { + // name must be string according to Part B in Common Schema. Skip serializing this field otherwise + eb.AddCountedAnsiString("name", nameValue, Encoding.UTF8); + namePopulated = true; + } + } + else + { + kvpArrayForPartCFields[partCFieldsCountFromState] = new(entry.Key, entry.Value); + partCFieldsCountFromState++; + } } } else @@ -366,6 +378,11 @@ internal void SerializeLogRecord(LogRecord logRecord) } } + if (!namePopulated) + { + eb.AddCountedAnsiString("name", categoryName, Encoding.UTF8); + } + if (!bodyPopulated && logRecord.FormattedMessage != null) { eb.AddCountedAnsiString("body", logRecord.FormattedMessage, Encoding.UTF8); diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs index e2b5f5d8f8..4c5da2e30f 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs @@ -1132,6 +1132,142 @@ public void SerializationTestForEventName(EventNameExportMode eventNameExportMod } } + [Theory] + [InlineData(false, false, "Custom name")] + [InlineData(false, false, "")] + [InlineData(false, false, null)] + [InlineData(false, false, 12345)] + [InlineData(true, false, "Custom name")] + [InlineData(true, true, "Custom name")] + [InlineData(true, true, 12345)] + [InlineData(true, false, 12345)] + public void SerializationTestForPartBName(bool hasCustomFields, bool hasNameInCustomFields, object customNameValue) + { + // ARRANGE + string path = string.Empty; + Socket server = null; + var logRecordList = new List(); + try + { + var exporterOptions = new GenevaExporterOptions(); + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + exporterOptions.ConnectionString = "EtwSession=OpenTelemetry"; + } + else + { + path = GenerateTempFilePath(); + exporterOptions.ConnectionString = "Endpoint=unix:" + path; + var endpoint = new UnixDomainSocketEndPoint(path); + server = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); + server.Bind(endpoint); + server.Listen(1); + } + + if (hasCustomFields) + { + if (hasNameInCustomFields) + { + exporterOptions.CustomFields = new string[] { "name", "Key1" }; + } + else + { + exporterOptions.CustomFields = new string[] { "Key1" }; + } + } + + using var loggerFactory = LoggerFactory.Create(builder => builder + .AddOpenTelemetry(options => + { + options.AddGenevaLogExporter(options => + { + options.ConnectionString = exporterOptions.ConnectionString; + options.CustomFields = exporterOptions.CustomFields; + }); + options.AddInMemoryExporter(logRecordList); + })); + + // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. + using var exporter = new MsgPackLogExporter(exporterOptions); + + // Emit a LogRecord and grab a copy of the LogRecord from the collection passed to InMemoryExporter + var logger = loggerFactory.CreateLogger(); + + // ACT + // This is treated as structured logging as the state can be converted to IReadOnlyList> + + var state = new List>() + { + new KeyValuePair("Key1", "Value1"), + new KeyValuePair("Key2", "Value2"), + }; + + if (customNameValue != null) + { + state.Add(new KeyValuePair("name", customNameValue)); + } + + logger.Log( + LogLevel.Information, + default, + state, + null, + null); + + // VALIDATE + Assert.Single(logRecordList); + var m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + _ = exporter.SerializeLogRecord(logRecordList[0]); + object fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); + var signal = (fluentdData as object[])[0] as string; + var TimeStampAndMappings = ((fluentdData as object[])[1] as object[])[0]; + var mapping = (TimeStampAndMappings as object[])[1] as Dictionary; + var actualNameValue = mapping["name"]; + + if (!hasCustomFields || hasNameInCustomFields) + { + if (customNameValue is string stringNameValue) + { + Assert.Equal(stringNameValue, actualNameValue); + } + else + { + Assert.Equal(typeof(GenevaLogExporterTests).FullName, actualNameValue); + } + } + else + { + Assert.Equal(typeof(GenevaLogExporterTests).FullName, actualNameValue); + if (customNameValue != null) + { + var envProperties = mapping["env_properties"] as Dictionary; + if (customNameValue is int customNameNumber) + { + Assert.Equal(Convert.ToInt32(envProperties["name"]), customNameNumber); + } + else + { + Assert.Equal((string)envProperties["name"], (string)customNameValue); + } + } + } + + logRecordList.Clear(); + } + finally + { + server?.Dispose(); + try + { + File.Delete(path); + } + catch + { + } + } + } + [Fact] public void SerializationTestForEventId() { From 91152f9101d5031ff1fab649248966a78ba9ffa1 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 22 Sep 2023 12:49:05 -0700 Subject: [PATCH 12/15] [repo] Add dedicated CI for WCF Instrumentation (#1371) --- .github/codecov.yml | 5 ++ .github/workflows/ci-Instrumentation.Wcf.yml | 17 ++++++ .github/workflows/ci.yml | 9 ++- .../workflows/package-Instrumentation.Wcf.yml | 57 ++----------------- .../OpenTelemetry.Instrumentation.Wcf.proj | 26 +++++++++ opentelemetry-dotnet-contrib.sln | 4 +- 6 files changed, 64 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/ci-Instrumentation.Wcf.yml create mode 100644 build/Projects/OpenTelemetry.Instrumentation.Wcf.proj diff --git a/.github/codecov.yml b/.github/codecov.yml index e28e1f2fce..6025fa0bd3 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -50,3 +50,8 @@ flags: paths: - src/OpenTelemetry.Instrumentation.Process + unittests-Instrumentation.Wcf: + carryforward: true + paths: + - src/OpenTelemetry.Instrumentation.Wcf + diff --git a/.github/workflows/ci-Instrumentation.Wcf.yml b/.github/workflows/ci-Instrumentation.Wcf.yml new file mode 100644 index 0000000000..536553886e --- /dev/null +++ b/.github/workflows/ci-Instrumentation.Wcf.yml @@ -0,0 +1,17 @@ +name: Build OpenTelemetry.Instrumentation.Wcf + +on: + pull_request: + branches: [ 'main*', 'instrumentation*' ] + paths: + - '*/OpenTelemetry.Instrumentation.Wcf*/**' + - 'build/**' + - '!**.md' + +jobs: + call-build-test: + uses: ./.github/workflows/Component.BuildTest.yml + with: + project-name: OpenTelemetry.Instrumentation.Wcf + code-cov-name: Instrumentation.Wcf + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0985545b1..b6aeec9df1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,10 @@ on: branches: [ 'main*', 'instrumentation*', 'exporter*', 'extensions*' ] paths-ignore: - '**.md' - - '*/OpenTelemetry.Instrumentation.Process*/**' - '*/OpenTelemetry.Exporter.Geneva*/**' - '*/OpenTelemetry.Exporter.OneCollector*/**' + - '*/OpenTelemetry.Instrumentation.Process*/**' + - '*/OpenTelemetry.Instrumentation.Wcf*/**' jobs: build-test: @@ -39,7 +40,11 @@ jobs: run: | $projects = Get-ChildItem ` -Path test/*.Tests/*.csproj ` - -Exclude OpenTelemetry.Instrumentation.Process.Tests.csproj, OpenTelemetry.Exporter.Geneva.Tests.csproj, OpenTelemetry.Exporter.OneCollector.Tests.csproj + -Exclude ` + OpenTelemetry.Exporter.Geneva.Tests.csproj, + OpenTelemetry.Exporter.OneCollector.Tests.csproj, + OpenTelemetry.Instrumentation.Process.Tests.csproj, + OpenTelemetry.Instrumentation.Wcf.Tests.csproj ForEach ($project in $projects) { diff --git a/.github/workflows/package-Instrumentation.Wcf.yml b/.github/workflows/package-Instrumentation.Wcf.yml index b7856c08c5..9bda5c8fce 100644 --- a/.github/workflows/package-Instrumentation.Wcf.yml +++ b/.github/workflows/package-Instrumentation.Wcf.yml @@ -9,58 +9,13 @@ on: default: 'warning' push: tags: - - 'Instrumentation.Wcf-*' + - 'Instrumentation.Wcf-*' # trigger when we create a tag with prefix "Instrumentation.Wcf-" jobs: - build-test-pack: - runs-on: ${{ matrix.os }} + call-build-test-pack: permissions: contents: write - env: - PROJECT: OpenTelemetry.Instrumentation.Wcf - - strategy: - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: Install dependencies - run: dotnet restore src/${{env.PROJECT}} - - - name: dotnet build ${{env.PROJECT}} - run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true - - - name: dotnet test ${{env.PROJECT}} - run: dotnet test test/${{env.PROJECT}}.Tests - - - name: dotnet pack ${{env.PROJECT}} - run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{env.PROJECT}}-packages - path: '**/${{env.PROJECT}}/bin/**/*.*nupkg' - - - name: Publish Nuget - run: | - nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/Component.Package.yml + with: + project-name: OpenTelemetry.Instrumentation.Wcf + secrets: inherit diff --git a/build/Projects/OpenTelemetry.Instrumentation.Wcf.proj b/build/Projects/OpenTelemetry.Instrumentation.Wcf.proj new file mode 100644 index 0000000000..98e1d0cd03 --- /dev/null +++ b/build/Projects/OpenTelemetry.Instrumentation.Wcf.proj @@ -0,0 +1,26 @@ + + + + $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName) + + + + + + + + + + + + + + + + + + + + + + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index de4e8a202c..f6eccb2168 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -33,12 +33,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\ci-Exporter.OneCollector-Integration.yml = .github\workflows\ci-Exporter.OneCollector-Integration.yml .github\workflows\ci-Exporter.OneCollector.yml = .github\workflows\ci-Exporter.OneCollector.yml .github\workflows\ci-Instrumentation.Process.yml = .github\workflows\ci-Instrumentation.Process.yml + .github\workflows\ci-Instrumentation.Wcf.yml = .github\workflows\ci-Instrumentation.Wcf.yml .github\workflows\ci-md.yml = .github\workflows\ci-md.yml .github\workflows\ci.yml = .github\workflows\ci.yml .github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml + .github\workflows\Component.BuildTest.yml = .github\workflows\Component.BuildTest.yml .github\workflows\Component.Package.yml = .github\workflows\Component.Package.yml .github\workflows\dotnet-core-cov.yml = .github\workflows\dotnet-core-cov.yml - .github\workflows\Component.BuildTest.yml = .github\workflows\Component.BuildTest.yml .github\workflows\dotnet-format-md.yml = .github\workflows\dotnet-format-md.yml .github\workflows\dotnet-format.yml = .github\workflows\dotnet-format.yml .github\workflows\integration-md.yml = .github\workflows\integration-md.yml @@ -310,6 +311,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{04 build\Projects\OpenTelemetry.Exporter.Geneva.proj = build\Projects\OpenTelemetry.Exporter.Geneva.proj build\Projects\OpenTelemetry.Exporter.OneCollector.proj = build\Projects\OpenTelemetry.Exporter.OneCollector.proj build\Projects\OpenTelemetry.Instrumentation.Process.proj = build\Projects\OpenTelemetry.Instrumentation.Process.proj + build\Projects\OpenTelemetry.Instrumentation.Wcf.proj = build\Projects\OpenTelemetry.Instrumentation.Wcf.proj EndProjectSection EndProject Global From 85ee94ca4a55099b1ac8a0552bcec15e01e12729 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 22 Sep 2023 12:57:29 -0700 Subject: [PATCH 13/15] [geneva] CHANGELOG update for GenevaExporter 1.7.0-alpha.1 release (#1372) --- src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index be3ad3c9f5..22fc9fc349 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Sep-22 + * Allow overriding the Part B "name" field value in GenevaLogExporter. ([#1367](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1367)) From 5a34738c47e847c8cad8af2027209abf0de4d72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 25 Sep 2023 06:46:24 +0200 Subject: [PATCH 14/15] Fix AWSEBSResourceDetector on Linux (#1350) --- .../AWSEBSResourceDetector.cs | 6 +++--- src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.ResourceDetectors.AWS/AWSEBSResourceDetector.cs b/src/OpenTelemetry.ResourceDetectors.AWS/AWSEBSResourceDetector.cs index 00d53eb3fe..4307fae7d4 100644 --- a/src/OpenTelemetry.ResourceDetectors.AWS/AWSEBSResourceDetector.cs +++ b/src/OpenTelemetry.ResourceDetectors.AWS/AWSEBSResourceDetector.cs @@ -16,7 +16,7 @@ using System; using System.Collections.Generic; -#if NETSTANDARD +#if NET6_0_OR_GREATER using System.Runtime.InteropServices; #endif using OpenTelemetry.ResourceDetectors.AWS.Models; @@ -30,7 +30,7 @@ namespace OpenTelemetry.ResourceDetectors.AWS; public class AWSEBSResourceDetector : IResourceDetector { private const string AWSEBSMetadataWindowsFilePath = "C:\\Program Files\\Amazon\\XRay\\environment.conf"; -#if NETSTANDARD +#if NET6_0_OR_GREATER private const string AWSEBSMetadataLinuxFilePath = "/var/elasticbeanstalk/xray/environment.conf"; #endif @@ -43,7 +43,7 @@ public Resource Detect() try { string? filePath; -#if NETSTANDARD +#if NET6_0_OR_GREATER if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { filePath = AWSEBSMetadataWindowsFilePath; diff --git a/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md index 737f247228..6a94208117 100644 --- a/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md +++ b/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md @@ -4,6 +4,8 @@ * Update OpenTelemetry SDK version to `1.6.0`. ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) +* Fix AWS EBS Resource Detector working on linux. + ([#1350](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1350)) ## 1.3.0-beta.1 From f6e73590c132c713941b9224b5d273155ed9e8d8 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Mon, 25 Sep 2023 00:47:48 -0700 Subject: [PATCH 15/15] [repo] Add dedicated CI for Owin Instrumentation (#1373) --- .github/codecov.yml | 5 ++ .github/workflows/Component.BuildTest.yml | 12 +++- .github/workflows/ci-Exporter.Geneva.yml | 1 + .../ci-Exporter.OneCollector-Integration.yml | 1 + .../workflows/ci-Exporter.OneCollector.yml | 1 + .github/workflows/ci-Instrumentation.Owin.yml | 20 +++++++ .../workflows/ci-Instrumentation.Process.yml | 1 + .github/workflows/ci-Instrumentation.Wcf.yml | 1 + .github/workflows/ci.yml | 2 + .../package-Instrumentation.Owin.yml | 57 ++----------------- .../OpenTelemetry.Instrumentation.Owin.proj | 26 +++++++++ opentelemetry-dotnet-contrib.sln | 2 + 12 files changed, 76 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/ci-Instrumentation.Owin.yml create mode 100644 build/Projects/OpenTelemetry.Instrumentation.Owin.proj diff --git a/.github/codecov.yml b/.github/codecov.yml index 6025fa0bd3..c613d3e4eb 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -45,6 +45,11 @@ flags: paths: - src/OpenTelemetry.Exporter.OneCollector + unittests-Instrumentation.Owin: + carryforward: true + paths: + - src/OpenTelemetry.Instrumentation.Owin + unittests-Instrumentation.Process: carryforward: true paths: diff --git a/.github/workflows/Component.BuildTest.yml b/.github/workflows/Component.BuildTest.yml index b257db5d1d..1166b216bc 100644 --- a/.github/workflows/Component.BuildTest.yml +++ b/.github/workflows/Component.BuildTest.yml @@ -13,6 +13,14 @@ on: default: 'unittests' required: false type: string + os-list: + default: '[ "windows-latest", "ubuntu-latest" ]' + required: false + type: string + tfm-list: + default: '[ "net462", "net6.0", "net7.0" ]' + required: false + type: string jobs: build-test: @@ -20,8 +28,8 @@ jobs: strategy: fail-fast: false # ensures the entire test matrix is run, even if one permutation fails matrix: - os: [ windows-latest, ubuntu-latest ] - version: [ net462, net6.0, net7.0 ] + os: ${{ fromJSON(inputs.os-list) }} + version: ${{ fromJSON(inputs.tfm-list) }} exclude: - os: ubuntu-latest version: net462 diff --git a/.github/workflows/ci-Exporter.Geneva.yml b/.github/workflows/ci-Exporter.Geneva.yml index f847305179..70193059e1 100644 --- a/.github/workflows/ci-Exporter.Geneva.yml +++ b/.github/workflows/ci-Exporter.Geneva.yml @@ -5,6 +5,7 @@ on: branches: [ 'main*', 'exporter*' ] paths: - '*/OpenTelemetry.Exporter.Geneva*/**' + - 'src/Shared/**' - 'build/**' - '!**.md' diff --git a/.github/workflows/ci-Exporter.OneCollector-Integration.yml b/.github/workflows/ci-Exporter.OneCollector-Integration.yml index fe720463a2..616e7e1096 100644 --- a/.github/workflows/ci-Exporter.OneCollector-Integration.yml +++ b/.github/workflows/ci-Exporter.OneCollector-Integration.yml @@ -8,6 +8,7 @@ on: branches: [ 'main*', 'exporter*' ] paths: - '*/OpenTelemetry.Exporter.OneCollector*/**' + - 'src/Shared/**' - 'build/**' - '!**.md' diff --git a/.github/workflows/ci-Exporter.OneCollector.yml b/.github/workflows/ci-Exporter.OneCollector.yml index d652649d63..76a40905ff 100644 --- a/.github/workflows/ci-Exporter.OneCollector.yml +++ b/.github/workflows/ci-Exporter.OneCollector.yml @@ -5,6 +5,7 @@ on: branches: [ 'main*', 'exporter*' ] paths: - '*/OpenTelemetry.Exporter.OneCollector*/**' + - 'src/Shared/**' - 'build/**' - '!**.md' diff --git a/.github/workflows/ci-Instrumentation.Owin.yml b/.github/workflows/ci-Instrumentation.Owin.yml new file mode 100644 index 0000000000..225f917df9 --- /dev/null +++ b/.github/workflows/ci-Instrumentation.Owin.yml @@ -0,0 +1,20 @@ +name: Build OpenTelemetry.Instrumentation.Owin + +on: + pull_request: + branches: [ 'main*', 'instrumentation*' ] + paths: + - '*/OpenTelemetry.Instrumentation.Owin*/**' + - 'src/Shared/**' + - 'build/**' + - '!**.md' + +jobs: + call-build-test: + uses: ./.github/workflows/Component.BuildTest.yml + with: + project-name: OpenTelemetry.Instrumentation.Owin + code-cov-name: Instrumentation.Owin + os-list: '[ "windows-latest" ]' + tfm-list: '[ "net462" ]' + diff --git a/.github/workflows/ci-Instrumentation.Process.yml b/.github/workflows/ci-Instrumentation.Process.yml index 63c394e1aa..677ef47fb3 100644 --- a/.github/workflows/ci-Instrumentation.Process.yml +++ b/.github/workflows/ci-Instrumentation.Process.yml @@ -5,6 +5,7 @@ on: branches: [ 'main*', 'instrumentation*' ] paths: - '*/OpenTelemetry.Instrumentation.Process*/**' + - 'src/Shared/**' - 'build/**' - '!**.md' diff --git a/.github/workflows/ci-Instrumentation.Wcf.yml b/.github/workflows/ci-Instrumentation.Wcf.yml index 536553886e..a0738b856e 100644 --- a/.github/workflows/ci-Instrumentation.Wcf.yml +++ b/.github/workflows/ci-Instrumentation.Wcf.yml @@ -5,6 +5,7 @@ on: branches: [ 'main*', 'instrumentation*' ] paths: - '*/OpenTelemetry.Instrumentation.Wcf*/**' + - 'src/Shared/**' - 'build/**' - '!**.md' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6aeec9df1..2975f4ff9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: - '**.md' - '*/OpenTelemetry.Exporter.Geneva*/**' - '*/OpenTelemetry.Exporter.OneCollector*/**' + - '*/OpenTelemetry.Instrumentation.Owin*/**' - '*/OpenTelemetry.Instrumentation.Process*/**' - '*/OpenTelemetry.Instrumentation.Wcf*/**' @@ -43,6 +44,7 @@ jobs: -Exclude ` OpenTelemetry.Exporter.Geneva.Tests.csproj, OpenTelemetry.Exporter.OneCollector.Tests.csproj, + OpenTelemetry.Instrumentation.Owin.Tests.csproj, OpenTelemetry.Instrumentation.Process.Tests.csproj, OpenTelemetry.Instrumentation.Wcf.Tests.csproj diff --git a/.github/workflows/package-Instrumentation.Owin.yml b/.github/workflows/package-Instrumentation.Owin.yml index 57a27988b5..a8b30e1f21 100644 --- a/.github/workflows/package-Instrumentation.Owin.yml +++ b/.github/workflows/package-Instrumentation.Owin.yml @@ -9,58 +9,13 @@ on: default: 'warning' push: tags: - - 'Instrumentation.Owin-*' + - 'Instrumentation.Owin-*' # trigger when we create a tag with prefix "Instrumentation.Owin-" jobs: - build-test-pack: - runs-on: ${{ matrix.os }} + call-build-test-pack: permissions: contents: write - env: - PROJECT: OpenTelemetry.Instrumentation.Owin - - strategy: - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: Install dependencies - run: dotnet restore src/${{env.PROJECT}} - - - name: dotnet build ${{env.PROJECT}} - run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true - - - name: dotnet test ${{env.PROJECT}} - run: dotnet test test/${{env.PROJECT}}.Tests - - - name: dotnet pack ${{env.PROJECT}} - run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build - - - name: Publish Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{env.PROJECT}}-packages - path: '**/${{env.PROJECT}}/bin/**/*.*nupkg' - - - name: Publish Nuget - run: | - nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/Component.Package.yml + with: + project-name: OpenTelemetry.Instrumentation.Owin + secrets: inherit diff --git a/build/Projects/OpenTelemetry.Instrumentation.Owin.proj b/build/Projects/OpenTelemetry.Instrumentation.Owin.proj new file mode 100644 index 0000000000..94116c5810 --- /dev/null +++ b/build/Projects/OpenTelemetry.Instrumentation.Owin.proj @@ -0,0 +1,26 @@ + + + + $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName) + + + + + + + + + + + + + + + + + + + + + + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index f6eccb2168..9784de114d 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\ci-Exporter.Geneva.yml = .github\workflows\ci-Exporter.Geneva.yml .github\workflows\ci-Exporter.OneCollector-Integration.yml = .github\workflows\ci-Exporter.OneCollector-Integration.yml .github\workflows\ci-Exporter.OneCollector.yml = .github\workflows\ci-Exporter.OneCollector.yml + .github\workflows\ci-Instrumentation.Owin.yml = .github\workflows\ci-Instrumentation.Owin.yml .github\workflows\ci-Instrumentation.Process.yml = .github\workflows\ci-Instrumentation.Process.yml .github\workflows\ci-Instrumentation.Wcf.yml = .github\workflows\ci-Instrumentation.Wcf.yml .github\workflows\ci-md.yml = .github\workflows\ci-md.yml @@ -310,6 +311,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{04 ProjectSection(SolutionItems) = preProject build\Projects\OpenTelemetry.Exporter.Geneva.proj = build\Projects\OpenTelemetry.Exporter.Geneva.proj build\Projects\OpenTelemetry.Exporter.OneCollector.proj = build\Projects\OpenTelemetry.Exporter.OneCollector.proj + build\Projects\OpenTelemetry.Instrumentation.Owin.proj = build\Projects\OpenTelemetry.Instrumentation.Owin.proj build\Projects\OpenTelemetry.Instrumentation.Process.proj = build\Projects\OpenTelemetry.Instrumentation.Process.proj build\Projects\OpenTelemetry.Instrumentation.Wcf.proj = build\Projects\OpenTelemetry.Instrumentation.Wcf.proj EndProjectSection