mirror of
https://github.com/mudler/LocalAI.git
synced 2024-06-07 19:40:48 +00:00
ab7b4d5ee9
Refactors api folder to core, creates firm split between backend code and api frontend.
30 lines
846 B
Go
30 lines
846 B
Go
package services
|
|
|
|
import (
|
|
"github.com/go-skynet/LocalAI/pkg/schema"
|
|
"go.opentelemetry.io/otel/exporters/prometheus"
|
|
api "go.opentelemetry.io/otel/metric"
|
|
"go.opentelemetry.io/otel/sdk/metric"
|
|
)
|
|
|
|
// setupOTelSDK bootstraps the OpenTelemetry pipeline.
|
|
// If it does not return an error, make sure to call shutdown for proper cleanup.
|
|
func SetupMetrics() (*schema.LocalAIMetrics, error) {
|
|
exporter, err := prometheus.New()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
provider := metric.NewMeterProvider(metric.WithReader(exporter))
|
|
meter := provider.Meter("github.com/go-skynet/LocalAI")
|
|
|
|
apiTimeMetric, err := meter.Float64Histogram("api_call", api.WithDescription("api calls"))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &schema.LocalAIMetrics{
|
|
Meter: meter,
|
|
ApiTimeMetric: apiTimeMetric,
|
|
}, nil
|
|
}
|