Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thugrock7 committed Jul 11, 2024
1 parent 9bdbfcc commit beb9f7f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"go.opentelemetry.io/otel/metric"
)

const meterName = "hypertrace.goagent.metrics"
const meterName = "goagent.hypertrace.org/metrics"

type systemMetrics struct {
memory float64
Expand All @@ -41,7 +41,7 @@ func InitializeSystemMetrics() {
meter := meterProvider.Meter(meterName)
err := setUpMetricRecorder(meter)
if err != nil {
fmt.Println("error initialising metrics, failed to setup metric recorder")
log.Printf("error initialising metrics, failed to setup metric recorder: %v\n", err)

Check warning on line 44 in instrumentation/opentelemetry/internal/metrics/system_metrics.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/opentelemetry/internal/metrics/system_metrics.go#L44

Added line #L44 was not covered by tests
}
}

Expand Down Expand Up @@ -74,6 +74,7 @@ func parseProcStatFile(bytesArr []byte, procFilepath string) (*processStats, err
rss: parseFloat(infos[23]),
}, nil
}

func parseFloat(val string) float64 {
floatVal, _ := strconv.ParseFloat(val, 64)
return floatVal
Expand All @@ -93,11 +94,11 @@ func setUpMetricRecorder(meter metric.Meter) error {
if meter == nil {
return fmt.Errorf("error while setting up metric recorder: meter is nil")

Check warning on line 95 in instrumentation/opentelemetry/internal/metrics/system_metrics.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/opentelemetry/internal/metrics/system_metrics.go#L95

Added line #L95 was not covered by tests
}
cpuSeconds, err := meter.Float64ObservableCounter("cpu.seconds.total", metric.WithDescription("Metric to monitor total CPU seconds"))
cpuSeconds, err := meter.Float64ObservableCounter("hypertrace.agent.cpu.seconds.total", metric.WithDescription("Metric to monitor total CPU seconds"))
if err != nil {
return fmt.Errorf("error while setting up cpu seconds metric counter: %v", err)

Check warning on line 99 in instrumentation/opentelemetry/internal/metrics/system_metrics.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/opentelemetry/internal/metrics/system_metrics.go#L99

Added line #L99 was not covered by tests
}
memory, err := meter.Float64ObservableGauge("memory", metric.WithDescription("Metric to monitor memory usage"))
memory, err := meter.Float64ObservableGauge("hypertrace.agent.memory", metric.WithDescription("Metric to monitor memory usage"))
if err != nil {
return fmt.Errorf("error while setting up memory metric counter: %v", err)

Check warning on line 103 in instrumentation/opentelemetry/internal/metrics/system_metrics.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/opentelemetry/internal/metrics/system_metrics.go#L103

Added line #L103 was not covered by tests
}
Expand Down

0 comments on commit beb9f7f

Please sign in to comment.