Skip to content

Commit 5806dc8

Browse files
committed
fix: get live logs, meters, traces with wildcard service
1 parent e7534e1 commit 5806dc8

File tree

3 files changed

+151
-18
lines changed

3 files changed

+151
-18
lines changed

src/main/kotlin/spp/protocol/platform/general/Service.kt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ data class Service(
9393
if (name.contains("|")) {
9494
val parts = name.split("|")
9595
return withName(parts[0])
96-
.withEnvironment(parts[1])
97-
.withCommitId(parts[2])
96+
.withEnvironment(if (parts[1] != "null") parts[1] else null)
97+
.withCommitId(if (parts[2] != "null") parts[2] else null)
9898
}
9999
return copy(name = name)
100100
}
@@ -106,14 +106,28 @@ data class Service(
106106
val parts = definition.name.split("|")
107107
return copy(
108108
name = parts[0],
109-
environment = parts[1],
110-
commitId = parts[2],
109+
environment = if (parts[1] != "null") parts[1] else null,
110+
commitId = if (parts[2] != "null") parts[2] else null,
111111
normal = definition.isReal
112112
)
113113
}
114114
return copy(name = definition.name, normal = definition.isReal)
115115
}
116116

117+
override fun toString(): String {
118+
return buildString {
119+
append("Service(")
120+
append("name=$name")
121+
if (group != "") append(", group=$group")
122+
if (shortName != null) append(", shortName=$shortName")
123+
if (layers.isNotEmpty()) append(", layers=$layers")
124+
if (!normal) append(", normal=$normal")
125+
if (environment != null) append(", environment=$environment")
126+
if (commitId != null) append(", commitId=$commitId")
127+
append(")")
128+
}
129+
}
130+
117131
companion object {
118132

119133
@JvmStatic
@@ -127,8 +141,8 @@ data class Service(
127141
if (name.contains("|")) {
128142
val parts = name.split("|")
129143
return fromName(parts[0])
130-
.withEnvironment(parts[1])
131-
.withCommitId(parts[2])
144+
.withEnvironment(if (parts[1] != "null") parts[1] else null)
145+
.withCommitId(if (parts[2] != "null") parts[2] else null)
132146
}
133147
return Service(name = name)
134148
}

src/main/kotlin/spp/protocol/service/LiveManagementService.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,17 @@ interface LiveManagementService {
117117
fun getMetrics(includeUnused: Boolean): Future<JsonObject>
118118
fun getSelf(): Future<SelfInfo>
119119

120+
fun getActiveServices(serviceName: String): Future<List<Service>>
121+
120122
@GenIgnore
121123
fun getServices(): Future<List<Service>> {
122124
return getServices(null)
123125
}
124126

125127
fun getServices(layer: String?): Future<List<Service>>
126-
fun getInstances(serviceId: String): Future<List<ServiceInstance>>
127-
fun getEndpoints(serviceId: String, limit: Int?): Future<List<ServiceEndpoint>>
128-
fun searchEndpoints(serviceId: String, keyword: String, limit: Int?): Future<List<ServiceEndpoint>>
128+
fun getInstances(service: Service): Future<List<ServiceInstance>>
129+
fun getEndpoints(service: Service, limit: Int?): Future<List<ServiceEndpoint>>
130+
fun searchEndpoints(service: Service, keyword: String, limit: Int?): Future<List<ServiceEndpoint>>
129131
fun sortMetrics(
130132
name: String,
131133
parentService: String?,

src/main/resources/graphql/schema.json

Lines changed: 126 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@
16851685
"deprecationReason": null
16861686
},
16871687
{
1688-
"name": "tags",
1688+
"name": "meterTags",
16891689
"description": null,
16901690
"args": [],
16911691
"type": {
@@ -1705,7 +1705,7 @@
17051705
"deprecationReason": null
17061706
},
17071707
{
1708-
"name": "partitions",
1708+
"name": "meterPartitions",
17091709
"description": null,
17101710
"args": [],
17111711
"type": {
@@ -1924,6 +1924,42 @@
19241924
},
19251925
"defaultValue": null
19261926
},
1927+
{
1928+
"name": "meterTags",
1929+
"description": null,
1930+
"type": {
1931+
"kind": "LIST",
1932+
"name": null,
1933+
"ofType": {
1934+
"kind": "NON_NULL",
1935+
"name": null,
1936+
"ofType": {
1937+
"kind": "INPUT_OBJECT",
1938+
"name": "MeterTagInput",
1939+
"ofType": null
1940+
}
1941+
}
1942+
},
1943+
"defaultValue": null
1944+
},
1945+
{
1946+
"name": "meterPartitions",
1947+
"description": null,
1948+
"type": {
1949+
"kind": "LIST",
1950+
"name": null,
1951+
"ofType": {
1952+
"kind": "NON_NULL",
1953+
"name": null,
1954+
"ofType": {
1955+
"kind": "INPUT_OBJECT",
1956+
"name": "MeterPartitionInput",
1957+
"ofType": null
1958+
}
1959+
}
1960+
},
1961+
"defaultValue": null
1962+
},
19271963
{
19281964
"name": "location",
19291965
"description": null,
@@ -3197,6 +3233,67 @@
31973233
"enumValues": null,
31983234
"possibleTypes": null
31993235
},
3236+
{
3237+
"kind": "INPUT_OBJECT",
3238+
"name": "MeterPartitionInput",
3239+
"description": null,
3240+
"fields": null,
3241+
"inputFields": [
3242+
{
3243+
"name": "keys",
3244+
"description": null,
3245+
"type": {
3246+
"kind": "NON_NULL",
3247+
"name": null,
3248+
"ofType": {
3249+
"kind": "LIST",
3250+
"name": null,
3251+
"ofType": {
3252+
"kind": "NON_NULL",
3253+
"name": null,
3254+
"ofType": {
3255+
"kind": "SCALAR",
3256+
"name": "String",
3257+
"ofType": null
3258+
}
3259+
}
3260+
}
3261+
},
3262+
"defaultValue": null
3263+
},
3264+
{
3265+
"name": "valueType",
3266+
"description": null,
3267+
"type": {
3268+
"kind": "NON_NULL",
3269+
"name": null,
3270+
"ofType": {
3271+
"kind": "ENUM",
3272+
"name": "MeterValueType",
3273+
"ofType": null
3274+
}
3275+
},
3276+
"defaultValue": null
3277+
},
3278+
{
3279+
"name": "value",
3280+
"description": null,
3281+
"type": {
3282+
"kind": "NON_NULL",
3283+
"name": null,
3284+
"ofType": {
3285+
"kind": "SCALAR",
3286+
"name": "String",
3287+
"ofType": null
3288+
}
3289+
},
3290+
"defaultValue": null
3291+
}
3292+
],
3293+
"interfaces": null,
3294+
"enumValues": null,
3295+
"possibleTypes": null
3296+
},
32003297
{
32013298
"kind": "OBJECT",
32023299
"name": "MeterTag",
@@ -6790,13 +6887,9 @@
67906887
"description": null,
67916888
"args": [],
67926889
"type": {
6793-
"kind": "NON_NULL",
6794-
"name": null,
6795-
"ofType": {
6796-
"kind": "SCALAR",
6797-
"name": "String",
6798-
"ofType": null
6799-
}
6890+
"kind": "SCALAR",
6891+
"name": "String",
6892+
"ofType": null
68006893
},
68016894
"isDeprecated": false,
68026895
"deprecationReason": null
@@ -6840,6 +6933,30 @@
68406933
},
68416934
"isDeprecated": false,
68426935
"deprecationReason": null
6936+
},
6937+
{
6938+
"name": "environment",
6939+
"description": null,
6940+
"args": [],
6941+
"type": {
6942+
"kind": "SCALAR",
6943+
"name": "String",
6944+
"ofType": null
6945+
},
6946+
"isDeprecated": false,
6947+
"deprecationReason": null
6948+
},
6949+
{
6950+
"name": "commitId",
6951+
"description": null,
6952+
"args": [],
6953+
"type": {
6954+
"kind": "SCALAR",
6955+
"name": "String",
6956+
"ofType": null
6957+
},
6958+
"isDeprecated": false,
6959+
"deprecationReason": null
68436960
}
68446961
],
68456962
"inputFields": null,

0 commit comments

Comments
 (0)