diff --git a/README.md b/README.md index 38cccaf..9c90996 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ By default, the exporter: - `--enable-otlp`: Enable OTLP export (default: false) - `--otlp-endpoint`: OTLP endpoint (default: https://otel.hyperliquid.validao.xyz) - `--otlp-insecure`: Use insecure connection for OTLP (default: false) -- `--identity`: Node identity (required when OTLP is enabled) +- `--alias`: Node alias (required when OTLP is enabled) - `--chain`: Chain type ('mainnet' or 'testnet', required when OTLP is enabled) ### Node Configuration diff --git a/cmd/hl-exporter/main.go b/cmd/hl-exporter/main.go index 2f45e78..0961532 100644 --- a/cmd/hl-exporter/main.go +++ b/cmd/hl-exporter/main.go @@ -27,7 +27,7 @@ func main() { fmt.Println(" --otlp-endpoint OTLP endpoint (default: otel.hyperliquid.validao.xyz)") fmt.Println(" --node-home Node home directory (overrides env var)") fmt.Println(" --node-binary Node binary path (overrides env var)") - fmt.Println(" --identity Node identity (required when OTLP is enabled)") + fmt.Println(" --alias Node alias (required when OTLP is enabled)") fmt.Println(" --chain Chain type (required when OTLP is enabled: 'mainnet' or 'testnet')") fmt.Println(" --otlp-insecure Use insecure connection for OTLP (default: false)") os.Exit(1) @@ -41,7 +41,7 @@ func main() { otlpEndpoint := startCmd.String("otlp-endpoint", "otel.hyperliquid.validao.xyz", "OTLP endpoint (default: otel.hyperliquid.validao.xyz)") nodeHome := startCmd.String("node-home", "", "Node home directory (overrides env var)") nodeBinary := startCmd.String("node-binary", "", "Node binary path (overrides env var)") - identity := startCmd.String("identity", "", "Node identity (required when OTLP is enabled)") + alias := startCmd.String("alias", "", "Node alias (required when OTLP is enabled)") chain := startCmd.String("chain", "", "Chain type (required when OTLP is enabled: 'mainnet' or 'testnet')") otlpInsecure := startCmd.Bool("otlp-insecure", false, "Use insecure connection for OTLP (default: false)") @@ -66,8 +66,8 @@ func main() { cfg := config.LoadConfig(flags) if *enableOTLP { - if *identity == "" { - logger.Error("--identity flag is required when OTLP is enabled. This can be whatever you choose and is just an identifier for your node.") + if *alias == "" { + logger.Error("--alias flag is required when OTLP is enabled. This can be whatever you choose and is just an identifier for your node.") os.Exit(1) } if *chain != "mainnet" && *chain != "testnet" { @@ -82,7 +82,7 @@ func main() { EnableOTLP: *enableOTLP, OTLPEndpoint: *otlpEndpoint, OTLPInsecure: *otlpInsecure, - Identity: *identity, + Alias: *alias, Chain: *chain, } diff --git a/internal/metrics/config.go b/internal/metrics/config.go index e86c4df..edd3b03 100644 --- a/internal/metrics/config.go +++ b/internal/metrics/config.go @@ -5,6 +5,6 @@ type MetricsConfig struct { EnableOTLP bool OTLPEndpoint string OTLPInsecure bool - Identity string + Alias string Chain string } diff --git a/internal/metrics/getters.go b/internal/metrics/getters.go index d3fc30d..f4103b9 100644 --- a/internal/metrics/getters.go +++ b/internal/metrics/getters.go @@ -3,5 +3,5 @@ package metrics func IsValidator() bool { metricsMutex.Lock() defer metricsMutex.Unlock() - return nodeIdentity.IsValidator + return nodeAlias.IsValidator } diff --git a/internal/metrics/identity.go b/internal/metrics/identity.go index 3aa2871..82b7433 100644 --- a/internal/metrics/identity.go +++ b/internal/metrics/identity.go @@ -21,7 +21,7 @@ func getPublicIP() (string, error) { return string(ip), nil } -func InitializeNodeIdentity(cfg MetricsConfig) error { +func InitializeNodeAlias(cfg MetricsConfig) error { ip, err := getPublicIP() if err != nil { return fmt.Errorf("failed to get public IP: %w", err) @@ -30,9 +30,9 @@ func InitializeNodeIdentity(cfg MetricsConfig) error { metricsMutex.Lock() defer metricsMutex.Unlock() - nodeIdentity = NodeIdentity{ + nodeAlias = NodeAlias{ ServerIP: ip, - Identity: cfg.Identity, + Alias: cfg.Alias, Chain: cfg.Chain, } diff --git a/internal/metrics/init.go b/internal/metrics/init.go index 18ad8c9..ebeede9 100644 --- a/internal/metrics/init.go +++ b/internal/metrics/init.go @@ -17,8 +17,8 @@ import ( // InitMetrics initializes the metrics system with the given configuration func InitMetrics(ctx context.Context, cfg MetricsConfig) error { - if err := InitializeNodeIdentity(cfg); err != nil { - return fmt.Errorf("failed to initialize node identity: %w", err) + if err := InitializeNodeAlias(cfg); err != nil { + return fmt.Errorf("failed to initialize node alias: %w", err) } if err := InitProvider(ctx, cfg); err != nil { @@ -57,14 +57,14 @@ func sanitizeEndpoint(endpoint string) string { func InitProvider(ctx context.Context, cfg MetricsConfig) error { metricsMutex.RLock() - serverIP := nodeIdentity.ServerIP - isValidator := nodeIdentity.IsValidator - validatorAddress := nodeIdentity.ValidatorAddress + serverIP := nodeAlias.ServerIP + isValidator := nodeAlias.IsValidator + validatorAddress := nodeAlias.ValidatorAddress metricsMutex.RUnlock() res := resource.NewWithAttributes( semconv.SchemaURL, - attribute.String("instance", cfg.Identity), + attribute.String("instance", cfg.Alias), attribute.String("job", fmt.Sprintf("hyperliquid-exporter/%s", cfg.Chain)), attribute.String("server_ip", serverIP), attribute.Bool("is_validator", isValidator), diff --git a/internal/metrics/setters.go b/internal/metrics/setters.go index 208351c..7043e76 100644 --- a/internal/metrics/setters.go +++ b/internal/metrics/setters.go @@ -166,13 +166,13 @@ func IncrementEVMTransactionsCounter() { func SetIsValidator(isValidator bool) { metricsMutex.Lock() defer metricsMutex.Unlock() - nodeIdentity.IsValidator = isValidator + nodeAlias.IsValidator = isValidator } func SetValidatorAddress(address string) { metricsMutex.Lock() defer metricsMutex.Unlock() - nodeIdentity.ValidatorAddress = address + nodeAlias.ValidatorAddress = address } func SetActiveStake(stake float64) { diff --git a/internal/metrics/types.go b/internal/metrics/types.go index 02807ce..55316ac 100644 --- a/internal/metrics/types.go +++ b/internal/metrics/types.go @@ -12,10 +12,10 @@ type labeledValue struct { labels []attribute.KeyValue } -type NodeIdentity struct { +type NodeAlias struct { ValidatorAddress string ServerIP string - Identity string + Alias string IsValidator bool Chain string } @@ -26,7 +26,7 @@ var ( labeledValues = make(map[api.Observable]map[string]labeledValue) metricsMutex sync.RWMutex callbacks []api.Registration - nodeIdentity NodeIdentity + nodeAlias NodeAlias ) // TODO CommonLabels holds the common labels to be added to all metrics