feat: api documentation and nits

This commit is contained in:
shivanshu 2024-10-04 01:44:52 +05:30
parent d380894c35
commit 98cbdf570f
No known key found for this signature in database
GPG Key ID: 0F9ACBC3AA12DC71
2 changed files with 276 additions and 65 deletions

View File

@ -2600,7 +2600,7 @@ func (aH *APIHandler) onboardConsumers(
return return
} }
chq, err := mq.BuildClickHouseQuery(messagingQueue, mq.KafkaQueue, "onboard_producers") chq, err := mq.BuildClickHouseQuery(messagingQueue, mq.KafkaQueue, "onboard_consumers")
if err != nil { if err != nil {
zap.L().Error(err.Error()) zap.L().Error(err.Error())
@ -2650,7 +2650,7 @@ func (aH *APIHandler) onboardConsumers(
attribute = "kind" attribute = "kind"
if intValue != 0 { if intValue != 0 {
status = "0" status = "0"
message = "check if your producer spans has kind=4 as attribute" message = "check if your consumer spans has kind=5 as attribute"
} else { } else {
status = "1" status = "1"
} }
@ -2721,6 +2721,10 @@ func (aH *APIHandler) onboardConsumers(
} }
} }
sort.Slice(entries, func(i, j int) bool {
return entries[i].Attribute < entries[j].Attribute
})
aH.Respond(w, entries) aH.Respond(w, entries)
} }
@ -2801,6 +2805,10 @@ func (aH *APIHandler) onboardKafka(
} }
} }
sort.Slice(entries, func(i, j int) bool {
return entries[i].Attribute < entries[j].Attribute
})
aH.Respond(w, entries) aH.Respond(w, entries)
} }

View File

@ -230,89 +230,292 @@ Response in query range `table` format
### Onboarding APIs ### Onboarding APIs
``` ```
/api/v1/messaging-queues/kafka/consumer-lag/onboarding-producers /api/v1/messaging-queues/kafka/onboarding/producers
``` ```
```json
{
"start": 1727620544260611424,
"end": 1727620556401481428
}
``` ```
```json
// everything is present
{ {
"status": "success", "status": "success",
"data": { "data": [
"resultType": "",
"result": [
{ {
"queryName": "onboard_producers", "attribute": "kind",
"series": [ "error_message": "",
"status": "1"
},
{ {
"labels": {}, "attribute": "messaging.destination.name",
"labelsArray": [ "error_message": "",
"status": "1"
},
{ {
"result": "All attributes are present and meet the conditions" "attribute": "messaging.destination.partition.id",
} "error_message": "messaging.destination.partition.id attribute is not present in your spans",
], "status": "0"
"values": [] },
{
"attribute": "messaging.system",
"error_message": "",
"status": "1"
},
{
"attribute": "telemetry ingestion",
"error_message": "",
"status": "1"
} }
] ]
} }
]
}
}
```
// partial attributes are present
```
/api/v1/messaging-queues/kafka/consumer-lag/onboarding-consumers
```
```
{ {
"status": "success", "status": "success",
"data": { "data": [
"resultType": "",
"result": [
{ {
"queryName": "onboard_consumers", "attribute": "kind",
"series": [ "error_message": "",
"status": "1"
},
{ {
"labels": {}, "attribute": "messaging.destination.name",
"labelsArray": [ "error_message": "messaging.destination.name attribute is not present in your spans",
"status": "0"
},
{ {
"result": "All attributes are present and meet the conditions" "attribute": "messaging.destination.partition.id",
} "error_message": "",
], "status": "1"
"values": [] },
{
"attribute": "messaging.system",
"error_message": "",
"status": "1"
},
{
"attribute": "telemetry ingestion",
"error_message": "",
"status": "1"
} }
] ]
} }
]
}
}
```
``` // no data available
127.0.0.1:8080/api/v1/messaging-queues/kafka/consumer-lag/onboarding-kafka
```
```
{ {
"status": "success", "status": "success",
"data": { "data": [
"resultType": "",
"result": [
{ {
"queryName": "onboard_consumers", "attribute": "telemetry ingestion",
"series": [ "error_message": "No data available in the given time range",
{ "status": "0"
"labels": {}, }
"labelsArray": [ ]
{ }
"result": "Neither metric (kafka_consumer_fetch_latency_avg nor kafka_consumer_group_lag) is present in the given time range." ```
}
],
"values": [] ```
/api/v1/messaging-queues/kafka/onboarding/consumers
```
```json
// everything is present
{
"status": "success",
"data": [
{
"attribute": "kind",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.client_id",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.destination.name",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.destination.partition.id",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.kafka.consumer.group",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.message.body.size",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.system",
"error_message": "",
"status": "1"
},
{
"attribute": "service.instance.id",
"error_message": "",
"status": "1"
},
{
"attribute": "service_name",
"error_message": "",
"status": "1"
},
{
"attribute": "telemetry ingestion",
"error_message": "",
"status": "1"
}
]
}
// partial attributes are present
{
"status": "success",
"data": [
{
"attribute": "kind",
"error_message": "check if your consumer spans has kind=5 as attribute",
"status": "0"
},
{
"attribute": "messaging.client_id",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.destination.name",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.destination.partition.id",
"error_message": "",
"status": "1"
},
{
"attribute": "messaging.kafka.consumer.group",
"error_message": "messaging.kafka.consumer.group attribute is not present in your spans",
"status": "0"
},
{
"attribute": "messaging.message.body.size",
"error_message": "messaging.message.body.size attribute is not present in your spans",
"status": "0"
},
{
"attribute": "messaging.system",
"error_message": "",
"status": "1"
},
{
"attribute": "service.instance.id",
"error_message": "",
"status": "1"
},
{
"attribute": "service_name",
"error_message": "",
"status": "1"
},
{
"attribute": "telemetry ingestion",
"error_message": "",
"status": "1"
}
]
}
// no data available
{
"status": "success",
"data": [
{
"attribute": "telemetry ingestion",
"error_message": "No data available in the given time range",
"status": "0"
}
]
}
```
```
/api/v1/messaging-queues/kafka/onboarding/kafka
```
```json
{
"start": 1728485200000000000,
"end": 1728749800000000000
}
```
```json
// everything is present
{
"status": "success",
"data": [
{
"attribute": "telemetry ingestion",
"error_message": "",
"status": "1"
},
{
"attribute": "kafka_consumer_fetch_latency_avg",
"error_message": "Metric kafka_consumer_fetch_latency_avg is not present in the given time range.",
"status": "0"
},
{
"attribute": "kafka_consumer_group_lag",
"error_message": "Metric kafka_consumer_group_lag is not present in the given time range.",
"status": "0"
}
]
}
// partial attributes are present
{
"status": "success",
"data": [
{
"attribute": "telemetry ingestion",
"error_message": "",
"status": "1"
},
{
"attribute": "kafka_consumer_fetch_latency_avg",
"error_message": "",
"status": "1"
},
{
"attribute": "kafka_consumer_group_lag",
"error_message": "",
"status": "1"
}
]
}
// no data available
{
"status": "success",
"data": [
{
"attribute": "telemetry ingestion",
"error_message": "No data available in the given time range",
"status": "0"
} }
] ]
} }
]
}
}
``` ```