From 64bb760278ac8672130b29c1c67249223a792442 Mon Sep 17 00:00:00 2001 From: Thanh Le Date: Fri, 15 Nov 2024 20:46:01 +0100 Subject: [PATCH] Code golf: use AttributeKey.apply function --- modules/elastic/src/main/scala/ESClient.scala | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/elastic/src/main/scala/ESClient.scala b/modules/elastic/src/main/scala/ESClient.scala index c8ad650..ce8209d 100644 --- a/modules/elastic/src/main/scala/ESClient.scala +++ b/modules/elastic/src/main/scala/ESClient.scala @@ -45,9 +45,9 @@ object ESClient: case Resource.ExitCase.Succeeded => static case Resource.ExitCase.Errored(e) => - static.added(Attribute(errorType, e.getClass.getName)) + static.added(errorType(e.getClass.getName)) case Resource.ExitCase.Canceled => - static.added(Attribute(errorType, "canceled")) + static.added(errorType("canceled")) def apply(uri: String)(using meter: Meter[IO]): Resource[IO, ESClient[IO]] = Resource @@ -86,8 +86,8 @@ object ESClient: TimeUnit.MILLISECONDS, withErrorType( baseAttributes - .added(Attribute(dbOperationName, "search")) - .added(Attribute(dbCollectionName, q.index(query).value)) + .added(dbOperationName("search")) + .added(dbCollectionName(q.index(query).value)) ) ) .surround: @@ -102,8 +102,8 @@ object ESClient: TimeUnit.MILLISECONDS, withErrorType( baseAttributes - .added(Attribute(dbOperationName, "count")) - .added(Attribute(dbCollectionName, q.index(query).value)) + .added(dbOperationName("count")) + .added(dbCollectionName(q.index(query).value)) ) ) .surround: @@ -118,8 +118,8 @@ object ESClient: TimeUnit.MILLISECONDS, withErrorType( baseAttributes - .added(Attribute(dbOperationName, "store")) - .added(Attribute(dbCollectionName, index.value)) + .added(dbOperationName("store")) + .added(dbCollectionName(index.value)) ) ) .surround: @@ -135,9 +135,9 @@ object ESClient: TimeUnit.MILLISECONDS, withErrorType( baseAttributes - .added(Attribute(dbOperationName, "store-bulk")) - .added(Attribute(dbCollectionName, index.value)) - .added(Attribute(dbBatchSize, objs.size)) + .added(dbOperationName("store-bulk")) + .added(dbCollectionName(index.value)) + .added(dbBatchSize(objs.size)) ) ) .surround: @@ -152,8 +152,8 @@ object ESClient: TimeUnit.MILLISECONDS, withErrorType( baseAttributes - .added(Attribute(dbOperationName, "delete-one")) - .added(Attribute(dbCollectionName, index.value)) + .added(dbOperationName("delete-one")) + .added(dbCollectionName(index.value)) ) ) .surround: @@ -167,9 +167,9 @@ object ESClient: TimeUnit.MILLISECONDS, withErrorType( baseAttributes - .added(Attribute(dbOperationName, "delete-bulk")) - .added(Attribute(dbCollectionName, index.value)) - .added(Attribute(dbBatchSize, ids.size)) + .added(dbOperationName("delete-bulk")) + .added(dbCollectionName(index.value)) + .added(dbBatchSize(ids.size)) ) ) .surround: