diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/OpenTelemetryListener.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/OpenTelemetryListener.cs index e8e53b6ff1..fa05f5eeec 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/OpenTelemetryListener.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/OpenTelemetryListener.cs @@ -136,10 +136,10 @@ private void RecordAttributes(string name, IEnumerable"); + OpenTelemetryListener.AssertData(name, tags); + foreach (KeyValuePair tag in tags) { - this.ValidateData(name, tag); - builder .Append("") .Append(tag.Key) @@ -149,7 +149,43 @@ private void RecordAttributes(string name, IEnumerable tag) + private static void AssertData(string name, IEnumerable> tags) + { + IList allowedAttributes = new List + { + "db.system", + "db.name", + "db.operation", + "net.peer.name", + "db.cosmosdb.client_id", + "db.cosmosdb.hashed_machine_id", + "db.cosmosdb.user_agent", + "db.cosmosdb.connection_mode", + "db.cosmosdb.operation_type", + "db.cosmosdb.container", + "db.cosmosdb.request_content_length_bytes", + "db.cosmosdb.response_content_length_bytes", + "db.cosmosdb.status_code", + "db.cosmosdb.sub_status_code", + "db.cosmosdb.request_charge", + "db.cosmosdb.regions_contacted", + "db.cosmosdb.retry_count", + "db.cosmosdb.item_count", + "db.cosmosdb.request_diagnostics", + "exception.type", + "exception.message", + "exception.stacktrace" + }; + + foreach (KeyValuePair tag in tags) + { + Assert.IsTrue(allowedAttributes.Contains(tag.Key), $"{tag.Key} is not allowed for {name}"); + + OpenTelemetryListener.AssertDatabaseAndContainerName(name, tag); + } + } + + private static void AssertDatabaseAndContainerName(string name, KeyValuePair tag) { IList exceptionsForContainerAttribute = new List {