From 1ca539f95ce2424249490e9a8f73d19161efc1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 7 Feb 2024 16:24:19 +0100 Subject: [PATCH 1/2] Drop unused settings --- .../ConfigurationKeys.cs | 10 ---------- .../PluginSettings.cs | 6 ------ 2 files changed, 16 deletions(-) diff --git a/src/Splunk.OpenTelemetry.AutoInstrumentation/ConfigurationKeys.cs b/src/Splunk.OpenTelemetry.AutoInstrumentation/ConfigurationKeys.cs index 3ae1c1ad..bba00604 100644 --- a/src/Splunk.OpenTelemetry.AutoInstrumentation/ConfigurationKeys.cs +++ b/src/Splunk.OpenTelemetry.AutoInstrumentation/ConfigurationKeys.cs @@ -67,15 +67,5 @@ public static class OpenTelemetry /// Configuration key for OTLP endpoint. /// public const string OtlpEndpoint = "OTEL_EXPORTER_OTLP_ENDPOINT"; - - /// - /// Configuration key for service name. - /// - public const string ServiceName = "OTEL_SERVICE_NAME"; - - /// - /// Configuration key for resource attributes. - /// - public const string ResourceAttributes = "OTEL_RESOURCE_ATTRIBUTES"; } } diff --git a/src/Splunk.OpenTelemetry.AutoInstrumentation/PluginSettings.cs b/src/Splunk.OpenTelemetry.AutoInstrumentation/PluginSettings.cs index 8a394b49..f093103a 100644 --- a/src/Splunk.OpenTelemetry.AutoInstrumentation/PluginSettings.cs +++ b/src/Splunk.OpenTelemetry.AutoInstrumentation/PluginSettings.cs @@ -34,11 +34,9 @@ internal PluginSettings(IConfigurationSource source) Realm = source.GetString(ConfigurationKeys.Splunk.Realm) ?? Constants.None; AccessToken = source.GetString(ConfigurationKeys.Splunk.AccessToken); - ServiceName = source.GetString(ConfigurationKeys.OpenTelemetry.ServiceName); TraceResponseHeaderEnabled = source.GetBool(ConfigurationKeys.Splunk.TraceResponseHeaderEnabled) ?? true; var otlpEndpoint = source.GetString(ConfigurationKeys.OpenTelemetry.OtlpEndpoint); IsOtlpEndpointSet = !string.IsNullOrEmpty(otlpEndpoint); - ResourceAttributes = source.GetString(ConfigurationKeys.OpenTelemetry.ResourceAttributes).ToNameValueCollection(); #if NET6_0_OR_GREATER CpuProfilerEnabled = source.GetBool(ConfigurationKeys.Splunk.AlwaysOnProfiler.CpuProfilerEnabled) ?? false; @@ -54,14 +52,10 @@ internal PluginSettings(IConfigurationSource source) public string? AccessToken { get; } - public string? ServiceName { get; } - public bool TraceResponseHeaderEnabled { get; } public bool IsOtlpEndpointSet { get; } - public IReadOnlyCollection> ResourceAttributes { get; } - #if NET6_0_OR_GREATER public bool CpuProfilerEnabled { get; } From 218e10fa91d7440b35344e75ee6d65f74e567cb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 7 Feb 2024 16:29:42 +0100 Subject: [PATCH 2/2] Drop unused helper classes --- .../Configuration/ConfigurationExtensions.cs | 42 ------------------- .../ConfigurationExtensionsTests.cs | 37 ---------------- 2 files changed, 79 deletions(-) delete mode 100644 src/Splunk.OpenTelemetry.AutoInstrumentation/Configuration/ConfigurationExtensions.cs delete mode 100644 test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ConfigurationExtensionsTests.cs diff --git a/src/Splunk.OpenTelemetry.AutoInstrumentation/Configuration/ConfigurationExtensions.cs b/src/Splunk.OpenTelemetry.AutoInstrumentation/Configuration/ConfigurationExtensions.cs deleted file mode 100644 index 74fc956b..00000000 --- a/src/Splunk.OpenTelemetry.AutoInstrumentation/Configuration/ConfigurationExtensions.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright Splunk Inc. -// -// 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. -// - -namespace Splunk.OpenTelemetry.AutoInstrumentation.Configuration -{ - internal static class ConfigurationExtensions - { - public static IReadOnlyCollection> ToNameValueCollection(this string? configurationValue) - { - if (configurationValue == null) - { - return Array.Empty>(); - } - - var collection = new List>(); - - foreach (var attribute in configurationValue.Split(',')) - { - var parts = attribute.Split('='); - var key = parts[0].Trim(); - var value = parts[1].Trim(); - - collection.Add(new(key, value)); - } - - return collection; - } - } -} diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ConfigurationExtensionsTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ConfigurationExtensionsTests.cs deleted file mode 100644 index 4e64872c..00000000 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ConfigurationExtensionsTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright Splunk Inc. -// -// 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 FluentAssertions.Execution; -using Splunk.OpenTelemetry.AutoInstrumentation.Configuration; - -namespace Splunk.OpenTelemetry.AutoInstrumentation.Tests -{ - public class ConfigurationExtensionsTests - { - [Fact] - public void ToNameValueCollection() - { - var setting = "item.value=1, service.name=test"; - var collection = setting.ToNameValueCollection(); - - using (new AssertionScope()) - { - collection.Should().Contain(new KeyValuePair("item.value", "1")); - collection.Should().Contain(new KeyValuePair("service.name", "test")); - } - } - } -}