diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryConstants.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryConstants.cs index 0362fc8bcf..5add1e4997 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryConstants.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryConstants.cs @@ -34,8 +34,6 @@ public static class Operations public const string CreateContainerIfNotExists = "create_container_if_not_exists"; public const string DeleteContainer = "delete_container"; public const string DeleteContainerStream = "delete_container_stream"; - /* public const string QueryContainers = "query_containers"; - public const string ReadAllContainers = "read_all_containers";*/ public const string ReadContainer = "read_container"; public const string ReadContainerStream = "read_container_stream"; public const string ReplaceContainer = "replace_container"; @@ -49,10 +47,8 @@ public static class Operations public const string CreateDatabaseIfNotExists = "create_database_if_not_exists"; public const string DeleteDatabase = "delete_database"; public const string DeleteDatabaseStream = "delete_database_stream"; - //public const string QueryDatabases = "query_databases"; public const string ReadDatabase = "read_database"; public const string ReadDatabaseStream = "read_database_stream"; - //public const string ReadAllDatabases = "read_all_databases"; // Item Operations public const string CreateItem = "create_item"; @@ -64,8 +60,6 @@ public static class Operations public const string PatchItemStream = "patch_item_stream"; public const string QueryItems = "query_items"; public const string TypedQueryItems = "typed_query_items"; - /* public const string ReadAllItems = "read_all_items"; - public const string ReadAllItemsOfLogicalPartition = "read_all_items_of_logical_partition";*/ public const string ReadManyItems = "read_many_items"; public const string ReadManyItemsStream = "read_many_items_stream"; public const string ReadItem = "read_item"; @@ -78,8 +72,6 @@ public static class Operations // Permission operations public const string CreatePermission = "create_permission"; public const string DeletePermission = "delete_permission"; - /* public const string QueryPermissions = "query_permissions"; - public const string ReadAllPermissions = "read_all_permissions";*/ public const string ReadPermission = "read_permission"; public const string ReplacePermission = "replace_permission"; public const string UpsertPermission = "upsert_permission"; @@ -89,8 +81,6 @@ public static class Operations public const string DeleteStoreProcedure = "delete_stored_procedure"; public const string ExecuteStoredProcedure = "execute_stored_procedure"; public const string ExecuteStoredProcedureStream = "execute_stored_procedure_stream"; -/* public const string QueryStoredProcedures = "query_stored_procedures"; - public const string ReadAllStoredProcedures = "read_all_stored_procedures";*/ public const string ReadStoredProcedure = "read_stored_procedure"; public const string ReplaceStoredProcedure = "replace_stored_procedure"; @@ -103,16 +93,12 @@ public static class Operations // Trigger operations public const string CreateTrigger = "create_trigger"; public const string DeleteTrigger = "delete_trigger"; -/* public const string QueryTriggers = "query_triggers"; - public const string ReadAllTriggers = "read_all_triggers";*/ public const string ReadTrigger = "read_trigger"; public const string ReplaceTrigger = "replace_trigger"; // User operations public const string CreateUser = "create_user"; public const string DeleteUser = "delete_user"; - /*public const string QueryUsers = "query_users"; - public const string ReadAllUsers = "read_all_users";*/ public const string ReadUser = "read_user"; public const string ReplaceUser = "replace_user"; public const string UpsertUser = "upsert_user"; @@ -121,17 +107,13 @@ public static class Operations public const string CreateUserDefinedFunction = "create_user_defined_function"; public const string DeleteUserDefinedFunctions = "delete_user_defined_function"; public const string ReplaceUserDefinedFunctions = "replace_user_defined_function"; - // public const string QueryUserDefinedFunctions = "query_user_defined_functions"; public const string ReadAllUserDefinedFunctions = "read_all_user_defined_functions"; public const string ReadUserDefinedFunction = "read_user_defined_function"; // Encryption Key operations public const string CreateClientEncryptionKey = "create_client_encryption_key"; - /* public const string QueryEncryptionKeys = "query_encryption_keys"; - public const string ReadAllEncryptionKeys = "read_all_encryption_keys";*/ public const string ReadClientEncryptionKey = "read_client_encryption_key"; public const string ReplaceClientEncryptionKey = "replace_client_encryption_key"; - } } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderTests.cs index 669c6bd194..a610e75b7f 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderTests.cs @@ -14,6 +14,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.CFP.AllVersionsAndDeletes using Microsoft.Azure.Cosmos.ChangeFeed.Utils; using Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed; using Microsoft.Azure.Cosmos.Services.Management.Tests; + using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -188,7 +189,7 @@ public async Task WhenADocumentIsCreatedThenUpdatedThenDeletedTestsAsync() Assert.IsNotNull(context.Headers); Assert.IsNotNull(context.Headers.Session); Assert.IsTrue(context.Headers.RequestCharge > 0); - Assert.IsTrue(context.Diagnostics.ToString().Contains("Change Feed Processor Read Next Async")); + Assert.IsTrue(context.Diagnostics.ToString().Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)); Assert.AreEqual(expected: 3, actual: docs.Count); ChangeFeedItem createChange = docs.ElementAt(0); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderWithCustomSerializerTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderWithCustomSerializerTests.cs index a6780e4409..4f68205673 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderWithCustomSerializerTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderWithCustomSerializerTests.cs @@ -16,6 +16,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.CFP.AllVersionsAndDeletes using Microsoft.Azure.Cosmos.ChangeFeed.Utils; using Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed; using Microsoft.Azure.Cosmos.Services.Management.Tests; + using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -539,7 +540,7 @@ public async Task WhenADocumentIsCreatedThenUpdatedThenDeletedTestsAsync(bool pr Assert.IsNotNull(context.Headers); Assert.IsNotNull(context.Headers.Session); Assert.IsTrue(context.Headers.RequestCharge > 0); - Assert.IsTrue(context.Diagnostics.ToString().Contains("Change Feed Processor Read Next Async")); + Assert.IsTrue(context.Diagnostics.ToString().Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)); Assert.AreEqual(expected: 3, actual: docs.Count); ChangeFeedItem createChange = docs.ElementAt(0); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicStreamTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicStreamTests.cs index f63ef4dbda..b187a4a4a2 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicStreamTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicStreamTests.cs @@ -11,6 +11,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Scripts; + using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -319,7 +320,7 @@ private void ValidateContext(ChangeFeedProcessorContext changeFeedProcessorConte Assert.IsNotNull(changeFeedProcessorContext.Headers.Session); Assert.IsTrue(changeFeedProcessorContext.Headers.RequestCharge > 0); string diagnosticsAsString = changeFeedProcessorContext.Diagnostics.ToString(); - Assert.IsTrue(diagnosticsAsString.Contains("Change Feed Processor Read Next Async")); + Assert.IsTrue(diagnosticsAsString.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)); } } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicTests.cs index 02d2faac54..ccb17311b3 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicTests.cs @@ -10,6 +10,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Scripts; + using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; @@ -377,7 +378,7 @@ private async Task ValidateContextAsync(ChangeFeedProcessorContext changeFeedPro Assert.IsNotNull(changeFeedProcessorContext.Headers.Session); Assert.IsTrue(changeFeedProcessorContext.Headers.RequestCharge > 0); string diagnosticsAsString = changeFeedProcessorContext.Diagnostics.ToString(); - Assert.IsTrue(diagnosticsAsString.Contains("Change Feed Processor Read Next Async")); + Assert.IsTrue(diagnosticsAsString.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)); await this.ValidateFeedRangeAsync(changeFeedProcessorContext.FeedRange); } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosDatabaseTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosDatabaseTests.cs index ba6d33d55e..7452554a9d 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosDatabaseTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosDatabaseTests.cs @@ -13,6 +13,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Core.Trace; using Microsoft.Azure.Cosmos.Resource.CosmosExceptions; + using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -217,7 +218,7 @@ public async Task CreateIfNotExists() Assert.IsNotNull(createExistingResponse.Diagnostics); string diagnostics = createExistingResponse.Diagnostics.ToString(); Assert.IsFalse(string.IsNullOrEmpty(diagnostics)); - Assert.IsTrue(diagnostics.Contains("CreateDatabaseIfNotExistsAsync")); + Assert.IsTrue(diagnostics.Contains(OpenTelemetryConstants.Operations.CreateDatabaseIfNotExists)); bool conflictReturned = false; requestHandlerHelper.CallBackOnResponse = (request, response) => diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosNullReferenceExceptionTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosNullReferenceExceptionTests.cs index b91b43fd64..6550805ba4 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosNullReferenceExceptionTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosNullReferenceExceptionTests.cs @@ -8,6 +8,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Diagnostics; + using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; using Microsoft.Azure.Documents; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -57,7 +58,7 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync() catch(NullReferenceException nre) { Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType()); - Assert.IsTrue(nre.Message.Contains("CreateItemAsync")); + Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.CreateItem)); string cosmosToString = nre.ToString(); Assert.IsFalse(cosmosToString.Contains("Microsoft.Azure.Cosmos.CosmosNullReferenceException"), $"The internal wrapper exception should not be exposed to users. {cosmosToString}"); Assert.IsTrue(cosmosToString.Contains(errorMessage)); @@ -73,11 +74,11 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync() catch (NullReferenceException nre) { Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType()); - Assert.IsTrue(nre.Message.Contains("Typed FeedIterator ReadNextAsync")); + Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.TypedQueryItems)); string cosmosToString = nre.ToString(); Assert.IsFalse(cosmosToString.Contains("Microsoft.Azure.Cosmos.CosmosNullReferenceException"), $"The internal wrapper exception should not be exposed to users. {cosmosToString}"); Assert.IsTrue(cosmosToString.Contains(errorMessage)); - Assert.IsTrue(cosmosToString.Contains("Typed FeedIterator ReadNextAsync")); + Assert.IsTrue(cosmosToString.Contains(OpenTelemetryConstants.Operations.TypedQueryItems)); } } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCoreTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCoreTests.cs index 08baba746b..1d98dc81b1 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCoreTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCoreTests.cs @@ -10,6 +10,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Tests using System.Threading.Tasks; using Microsoft.Azure.Cosmos.ChangeFeed.LeaseManagement; using Microsoft.Azure.Cosmos.Telemetry; + using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; using Microsoft.Azure.Cosmos.Tests; using Microsoft.Azure.Cosmos.Tracing; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -40,7 +41,7 @@ public async Task EtagPassesContinuation() Mock containerMock = new Mock(); Mock mockContext = new Mock(); mockContext.Setup(x => x.OperationHelperAsync( - It.Is(str => str.Contains("Change Feed Processor")), + It.Is(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)), It.IsAny(), It.IsAny(), It.IsAny(), @@ -120,7 +121,7 @@ public async Task NextReadHasUpdatedContinuation() Mock containerMock = new Mock(); Mock mockContext = new Mock(); mockContext.Setup(x => x.OperationHelperAsync( - It.Is(str => str.Contains("Change Feed Processor")), + It.Is(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)), It.IsAny(), It.IsAny(), It.IsAny(), @@ -190,7 +191,7 @@ public async Task ShouldSetFeedRangePartitionKeyRange() Mock containerMock = new Mock(); Mock mockContext = new Mock(); mockContext.Setup(x => x.OperationHelperAsync( - It.Is(str => str.Contains("Change Feed Processor")), + It.Is(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)), It.IsAny(), It.IsAny(), It.IsAny(), @@ -272,7 +273,7 @@ public async Task ShouldUseFeedRangeEpk() Mock containerMock = new Mock(); Mock mockContext = new Mock(); mockContext.Setup(x => x.OperationHelperAsync( - It.Is(str => str.Contains("Change Feed Processor")), + It.Is(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)), It.IsAny(), It.IsAny(), It.IsAny(),