Skip to content

Commit

Permalink
chore: rename alias
Browse files Browse the repository at this point in the history
  • Loading branch information
murakamikaze committed Nov 9, 2024
1 parent 7db2a60 commit c072a0d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cmd/hl-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)")

Expand All @@ -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" {
Expand All @@ -82,7 +82,7 @@ func main() {
EnableOTLP: *enableOTLP,
OTLPEndpoint: *otlpEndpoint,
OTLPInsecure: *otlpInsecure,
Identity: *identity,
Alias: *alias,
Chain: *chain,
}

Expand Down
2 changes: 1 addition & 1 deletion internal/metrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ type MetricsConfig struct {
EnableOTLP bool
OTLPEndpoint string
OTLPInsecure bool
Identity string
Alias string
Chain string
}
2 changes: 1 addition & 1 deletion internal/metrics/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package metrics
func IsValidator() bool {
metricsMutex.Lock()
defer metricsMutex.Unlock()
return nodeIdentity.IsValidator
return nodeAlias.IsValidator
}
6 changes: 3 additions & 3 deletions internal/metrics/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
}

Expand Down
12 changes: 6 additions & 6 deletions internal/metrics/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions internal/metrics/setters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions internal/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit c072a0d

Please sign in to comment.