Feat: configure audit fields and metrics for onix adapter and add local configuration for onix adapterZ
This commit is contained in:
@@ -30,24 +30,52 @@ var (
|
||||
|
||||
// Attribute keys shared across instruments.
|
||||
var (
|
||||
AttrModule = attribute.Key("module")
|
||||
AttrSubsystem = attribute.Key("subsystem")
|
||||
AttrName = attribute.Key("name")
|
||||
AttrStep = attribute.Key("step")
|
||||
AttrRole = attribute.Key("role")
|
||||
AttrAction = attribute.Key("action")
|
||||
AttrHTTPMethod = attribute.Key("http_method")
|
||||
AttrHTTPStatus = attribute.Key("http_status_code")
|
||||
AttrStatus = attribute.Key("status")
|
||||
AttrErrorType = attribute.Key("error_type")
|
||||
AttrPluginID = attribute.Key("plugin_id")
|
||||
AttrPluginType = attribute.Key("plugin_type")
|
||||
AttrOperation = attribute.Key("operation")
|
||||
AttrRouteType = attribute.Key("route_type")
|
||||
AttrTargetType = attribute.Key("target_type")
|
||||
AttrSchemaVersion = attribute.Key("schema_version")
|
||||
AttrModule = attribute.Key("module")
|
||||
AttrCaller = attribute.Key("caller") // who is calling bab/bpp with there name
|
||||
AttrStep = attribute.Key("step")
|
||||
AttrRole = attribute.Key("role")
|
||||
AttrAction = attribute.Key("action") // action is context.action
|
||||
AttrHTTPStatus = attribute.Key("http_status_code") // status code is 2xx/3xx/4xx/5xx
|
||||
AttrStatus = attribute.Key("status")
|
||||
AttrErrorType = attribute.Key("error_type")
|
||||
AttrPluginID = attribute.Key("plugin_id") // id for the plugine
|
||||
AttrPluginType = attribute.Key("plugin_type") // type for the plugine
|
||||
AttrOperation = attribute.Key("operation")
|
||||
AttrRouteType = attribute.Key("route_type") // publish/ uri
|
||||
AttrTargetType = attribute.Key("target_type")
|
||||
AttrSchemaVersion = attribute.Key("schema_version")
|
||||
AttrMetricUUID = attribute.Key("metric_uuid")
|
||||
AttrMetricCode = attribute.Key("metric.code")
|
||||
AttrMetricCategory = attribute.Key("metric.category")
|
||||
AttrMetricGranularity = attribute.Key("metric.granularity")
|
||||
AttrMetricFrequency = attribute.Key("metric.frequency")
|
||||
AttrObservedTimeUnixNano = attribute.Key("observedTimeUnixNano")
|
||||
AttrMatricLabels = attribute.Key("metric.labels")
|
||||
)
|
||||
|
||||
var (
|
||||
networkMetricsCfgMu sync.RWMutex
|
||||
networkMetricsGranularity = "10mim" // default
|
||||
networkMetricsFrequency = "10mim" // default
|
||||
)
|
||||
|
||||
func SetNetworkMetricsConfig(granularity, frequency string) {
|
||||
networkMetricsCfgMu.Lock()
|
||||
defer networkMetricsCfgMu.Unlock()
|
||||
if granularity != "" {
|
||||
networkMetricsGranularity = granularity
|
||||
}
|
||||
if frequency != "" {
|
||||
networkMetricsFrequency = frequency
|
||||
}
|
||||
}
|
||||
|
||||
func GetNetworkMetricsConfig() (granularity, frequency string) {
|
||||
networkMetricsCfgMu.RLock()
|
||||
defer networkMetricsCfgMu.RUnlock()
|
||||
return networkMetricsGranularity, networkMetricsFrequency
|
||||
}
|
||||
|
||||
// GetMetrics lazily initializes instruments and returns a cached reference.
|
||||
func GetMetrics(ctx context.Context) (*Metrics, error) {
|
||||
metricsOnce.Do(func() {
|
||||
@@ -58,8 +86,8 @@ func GetMetrics(ctx context.Context) (*Metrics, error) {
|
||||
|
||||
func newMetrics() (*Metrics, error) {
|
||||
meter := otel.GetMeterProvider().Meter(
|
||||
"github.com/beckn-one/beckn-onix/telemetry",
|
||||
metric.WithInstrumentationVersion("1.0.0"),
|
||||
ScopeName,
|
||||
metric.WithInstrumentationVersion(ScopeVersion),
|
||||
)
|
||||
|
||||
m := &Metrics{}
|
||||
|
||||
Reference in New Issue
Block a user