Skip to content

Commit

Permalink
Merge pull request #45 from Lukinhasssss/feature/custom-metrics
Browse files Browse the repository at this point in the history
Feature/custom metrics
  • Loading branch information
Lukinhasssss authored Jan 28, 2024
2 parents 0567a10 + d7dda53 commit f143e12
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.lukinhasssss.admin.catalogo.infrastructure.utils.metrics

import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.Timer
import org.springframework.stereotype.Component
import java.util.concurrent.TimeUnit
import kotlin.system.measureTimeMillis

@Component
class Metric(private val meterRegistry: MeterRegistry) {

fun <T> measureExecutionTime(processName: String, block: () -> T): T {
val timer: Timer = meterRegistry.timer("metric_name")

val result: T

val duration = measureTimeMillis {
result = block()
}

timer.record(duration, TimeUnit.MILLISECONDS)

println(processName)

return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ exporters:
endpoint: jaeger-admin-do-catalogo:14250
tls:
insecure: true
logging:
logLevel: info

service:
pipelines:
traces:
receivers: [otlp]
exporters: [jaeger, logging]
metrics:
receivers: [otlp]
exporters: [logging]
exporters: [jaeger]
extensions: [health_check]

0 comments on commit f143e12

Please sign in to comment.