@@ -26,24 +26,66 @@ after:
2626
2727` ` ` go
2828type SubstrateGateway interface {
29- CreateNode(node substrate.Node) (uint32, error)
30- CreateTwin(relay string, pk []byte) (uint32, error)
31- EnsureAccount(activationURL string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error)
32- GetContract(id uint64) (substrate.Contract, SubstrateError)
33- GetContractIDByNameRegistration(name string) (uint64, SubstrateError)
34- GetFarm(id uint32) (substrate.Farm, error)
35- GetNode(id uint32) (substrate.Node, error)
36- GetNodeByTwinID(twin uint32) (uint32, SubstrateError)
37- GetNodeContracts(node uint32) ([]types.U64, error)
38- GetNodeRentContract(node uint32) (uint64, SubstrateError)
39- GetNodes(farmID uint32) ([]uint32, error)
40- GetPowerTarget(nodeID uint32) (power substrate.NodePower, err error)
41- GetTwin(id uint32) (substrate.Twin, error)
42- GetTwinByPubKey(pk []byte) (uint32, SubstrateError)
43- Report(consumptions []substrate.NruConsumption) (types.Hash, error)
44- SetContractConsumption(resources ...substrate.ContractResources) error
45- SetNodePowerState(up bool) (hash types.Hash, err error)
46- UpdateNode(node substrate.Node) (uint32, error)
47- UpdateNodeUptimeV2(uptime uint64, timestampHint uint64) (hash types.Hash, err error)
29+ UpdateSubstrateGatewayConnection(ctx context.Context, manager substrate.Manager) (err error)
30+ CreateNode(ctx context.Context, node substrate.Node) (uint32, error)
31+ CreateTwin(ctx context.Context, relay string, pk []byte) (uint32, error)
32+ EnsureAccount(ctx context.Context, activationURL []string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error)
33+ GetContract(ctx context.Context, id uint64) (substrate.Contract, SubstrateError)
34+ GetContractIDByNameRegistration(ctx context.Context, name string) (uint64, SubstrateError)
35+ GetFarm(ctx context.Context, id uint32) (substrate.Farm, error)
36+ GetNode(ctx context.Context, id uint32) (substrate.Node, error)
37+ GetNodeByTwinID(ctx context.Context, twin uint32) (uint32, SubstrateError)
38+ GetNodeContracts(ctx context.Context, node uint32) ([]types.U64, error)
39+ GetNodeRentContract(ctx context.Context, node uint32) (uint64, SubstrateError)
40+ GetNodes(ctx context.Context, farmID uint32) ([]uint32, error)
41+ GetPowerTarget(ctx context.Context, nodeID uint32) (power substrate.NodePower, err error)
42+ GetTwin(ctx context.Context, id uint32) (substrate.Twin, error)
43+ GetTwinByPubKey(ctx context.Context, pk []byte) (uint32, SubstrateError)
44+ Report(ctx context.Context, consumptions []substrate.NruConsumption) (types.Hash, error)
45+ SetContractConsumption(ctx context.Context, resources ...substrate.ContractResources) error
46+ SetNodePowerState(ctx context.Context, up bool) (hash types.Hash, err error)
47+ UpdateNode(ctx context.Context, node substrate.Node) (uint32, error)
48+ UpdateNodeUptimeV2(ctx context.Context, uptime uint64, timestampHint uint64) (hash types.Hash, err error)
49+ GetTime(ctx context.Context) (time.Time, error)
50+ GetZosVersion(ctx context.Context) (string, error)
4851}
4952```
53+
54+ ## Distributed Tracing
55+
56+ API Gateway implements distributed tracing to track requests across ZOS modules. Each request is assigned a unique trace ID that flows through the entire system.
57+
58+ ### How It Works
59+
60+ 1 . ** Context Propagation** : All interface methods accept ` context.Context ` as the first parameter
61+ 2 . ** Trace ID Generation** : A unique trace ID (format: ` trace-{uuid} ` ) is generated or extracted from the context
62+ 3 . ** Automatic Logging** : All operations log the trace ID, enabling request correlation across modules
63+
64+ ### Log Output
65+
66+ All logs include the ` trace_id ` field:
67+
68+ ``` json
69+ {"level" :" debug" ,"trace_id" :" trace-abc123" ,"method" :" CreateNode" ,"twin_id" :1234 ,"message" :" method called" }
70+ {"level" :" debug" ,"trace_id" :" trace-abc123" ,"message" :" CreateNode failed, retrying" }
71+ {"level" :" debug" ,"trace_id" :" trace-abc123" ,"message" :" CreateNode completed successfully" }
72+ ```
73+
74+ ### Searching Logs
75+
76+ To trace a complete request journey:
77+
78+ ``` bash
79+ # Find all logs for a specific trace ID
80+ zinit log | grep " trace-abc123"
81+
82+ # Or use journalctl
83+ journalctl -u api-gateway | grep " trace-abc123"
84+ ```
85+
86+ ### Benefits
87+
88+ - ** Request Tracking** : Follow a provision request from arrival through flist mounting, disk preparation, and completion
89+ - ** Cross-Module Correlation** : Same trace ID flows through api-gateway → provision → flist → storage modules
90+ - ** Debugging** : Quickly identify which requests are causing issues
91+ - ** Performance Analysis** : Track request duration across the entire system
0 commit comments