Skip to content

Commit

Permalink
Code golf: use AttributeKey.apply function
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Nov 15, 2024
1 parent 1cfe68a commit 64bb760
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions modules/elastic/src/main/scala/ESClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 64bb760

Please sign in to comment.