Skip to content

Commit b732c46

Browse files
committed
make fmt
Signed-off-by: SuperQ <[email protected]>
1 parent da88d74 commit b732c46

File tree

6 files changed

+87
-85
lines changed

6 files changed

+87
-85
lines changed

internal/vendored/go-tools/telemetry/export/ocagent/wire/metrics.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ type PointInt64Value struct {
7171
// OpenCensus service can correctly determine the underlying value type.
7272
// This custom MarshalJSON exists because,
7373
// by default *Point is JSON marshalled as:
74-
// {"value": {"int64Value": 1}}
74+
//
75+
// {"value": {"int64Value": 1}}
76+
//
7577
// but it should be marshalled as:
76-
// {"int64Value": 1}
78+
//
79+
// {"int64Value": 1}
7780
func (p *Point) MarshalJSON() ([]byte, error) {
7881
if p == nil {
7982
return []byte("null"), nil
@@ -158,9 +161,12 @@ type bucketOptionsExplicitAlias BucketOptionsExplicit
158161
// OpenCensus service can correctly determine the underlying value type.
159162
// This custom MarshalJSON exists because,
160163
// by default BucketOptionsExplicit is JSON marshalled as:
161-
// {"bounds":[1,2,3]}
164+
//
165+
// {"bounds":[1,2,3]}
166+
//
162167
// but it should be marshalled as:
163-
// {"explicit":{"bounds":[1,2,3]}}
168+
//
169+
// {"explicit":{"bounds":[1,2,3]}}
164170
func (be *BucketOptionsExplicit) MarshalJSON() ([]byte, error) {
165171
return json.Marshal(&struct {
166172
Explicit *bucketOptionsExplicitAlias `json:"explicit,omitempty"`

langserver/cache/diagnostics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (d *DocumentHandle) warnQuotedYaml(start token.Pos, end token.Pos) error {
8787

8888
// addDiagnostic adds a protocol.Diagnostic to the diagnostics of a Document.
8989
//
90-
//If the context is expired the diagnostic is discarded.
90+
// If the context is expired the diagnostic is discarded.
9191
func (d *DocumentHandle) addDiagnostic(diagnostic *protocol.Diagnostic) error {
9292
d.doc.mu.Lock()
9393
defer d.doc.mu.Unlock()

langserver/cache/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
// limitations under the License.
1313

1414
// Package cache is the component of the PromQL language server that is
15-
//responsible for the caching the content and parse results of documents opened in the language client.
15+
// responsible for the caching the content and parse results of documents opened in the language client.
1616
package cache

langserver/hover.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
_ "github.com/prometheus-community/promql-langserver/langserver/documentation/functions_statik"
3434
)
3535

36-
//nolint: gochecknoglobals
36+
// nolint: gochecknoglobals
3737
var functionDocumentationFS = initializeFunctionDocumentation()
3838

3939
func initializeFunctionDocumentation() http.FileSystem {

rest/doc.go

+70-74
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Package rest provides a REST API to access the features of the PromQL language s
1515
1616
The returned datastructures are taken from the Language Server Protocol Specification (https://microsoft.github.io/language-server-protocol/specifications/specification-current/)
1717
18-
1918
Supported endpoints:
2019
2120
/diagnostics
@@ -25,89 +24,86 @@ Supported endpoints:
2524
2625
All endpoints are only available through the HTTP method POST. For each request, you have to provide the following JSON:
2726
28-
{
29-
"expr": "a PromQL expression" # Mandatory for all available endpoints
30-
"limit": 45 # Optional. It will be used only for the endpoints /diagnostics and /completion. It's the maximum number of results returned.
31-
"positionLine": 0 # Mandatory for the endpoints /signatureHelp, /hover and /completion. The line (0 based) for which the metadata is queried.
32-
"positionChar": 2 # Mandatory for the endpoints /signatureHelp, /hover and /completion. The column (0 based) for which the metadata is queried. Characters are counted as UTF-16 code points.
33-
}
34-
27+
{
28+
"expr": "a PromQL expression" # Mandatory for all available endpoints
29+
"limit": 45 # Optional. It will be used only for the endpoints /diagnostics and /completion. It's the maximum number of results returned.
30+
"positionLine": 0 # Mandatory for the endpoints /signatureHelp, /hover and /completion. The line (0 based) for which the metadata is queried.
31+
"positionChar": 2 # Mandatory for the endpoints /signatureHelp, /hover and /completion. The column (0 based) for which the metadata is queried. Characters are counted as UTF-16 code points.
32+
}
3533
3634
Examples:
3735
38-
$ curl -XPOST 'localhost:8080/diagnostics' -H "Content-Type: application/json" --data '{"expr": "some_metric()", "limit":100}'|jq
39-
[
40-
{
41-
"range": {
42-
"start": {
43-
"line": 0,
44-
"character": 0
45-
},
46-
"end": {
47-
"line": 0,
48-
"character": 11
49-
}
50-
},
51-
"severity": 1,
52-
"source": "promql-lsp",
53-
"message": "unknown function with name \"some_metric\""
54-
}
55-
]
56-
57-
58-
$ curl -XPOST 'localhost:8080/completion' -H "Content-Type: application/json" --data '{"expr": "sum(go)", "limit":2, "positionLine":0, "positionChar":6}'|jq
59-
[
60-
{
61-
"label": "go_gc_duration_seconds",
62-
"kind": 12,
63-
"sortText": "__3__go_gc_duration_seconds",
64-
"textEdit": {
65-
"range": {
66-
"start": {
67-
"line": 0,
68-
"character": 4
69-
},
70-
"end": {
71-
"line": 0,
72-
"character": 6
73-
}
74-
},
75-
"newText": "go_gc_duration_seconds"
76-
}
77-
},
78-
{
79-
"label": "go_gc_duration_seconds_count",
80-
"kind": 12,
81-
"sortText": "__3__go_gc_duration_seconds_count",
82-
"textEdit": {
83-
"range": {
84-
"start": {
85-
"line": 0,
86-
"character": 4
87-
},
88-
"end": {
89-
"line": 0,
90-
"character": 6
91-
}
92-
},
93-
"newText": "go_gc_duration_seconds_count"
94-
}
95-
}
96-
]
97-
36+
$ curl -XPOST 'localhost:8080/diagnostics' -H "Content-Type: application/json" --data '{"expr": "some_metric()", "limit":100}'|jq
37+
[
38+
{
39+
"range": {
40+
"start": {
41+
"line": 0,
42+
"character": 0
43+
},
44+
"end": {
45+
"line": 0,
46+
"character": 11
47+
}
48+
},
49+
"severity": 1,
50+
"source": "promql-lsp",
51+
"message": "unknown function with name \"some_metric\""
52+
}
53+
]
54+
55+
56+
$ curl -XPOST 'localhost:8080/completion' -H "Content-Type: application/json" --data '{"expr": "sum(go)", "limit":2, "positionLine":0, "positionChar":6}'|jq
57+
[
58+
{
59+
"label": "go_gc_duration_seconds",
60+
"kind": 12,
61+
"sortText": "__3__go_gc_duration_seconds",
62+
"textEdit": {
63+
"range": {
64+
"start": {
65+
"line": 0,
66+
"character": 4
67+
},
68+
"end": {
69+
"line": 0,
70+
"character": 6
71+
}
72+
},
73+
"newText": "go_gc_duration_seconds"
74+
}
75+
},
76+
{
77+
"label": "go_gc_duration_seconds_count",
78+
"kind": 12,
79+
"sortText": "__3__go_gc_duration_seconds_count",
80+
"textEdit": {
81+
"range": {
82+
"start": {
83+
"line": 0,
84+
"character": 4
85+
},
86+
"end": {
87+
"line": 0,
88+
"character": 6
89+
}
90+
},
91+
"newText": "go_gc_duration_seconds_count"
92+
}
93+
}
94+
]
9895
9996
Try out the API:
10097
10198
Use the PromQL language server with a configuration file like this:
10299
103-
rest_api_port: 8080
104-
prometheus_url: http://localhost:9090
100+
rest_api_port: 8080
101+
prometheus_url: http://localhost:9090
105102
106103
Run it with:
107104
108-
$ promql-langserver --config-file config.yaml
109-
REST API: Listening on port 8080
110-
Prometheus: http://localhost:9090
111-
105+
$ promql-langserver --config-file config.yaml
106+
REST API: Listening on port 8080
107+
Prometheus: http://localhost:9090
112108
*/
113109
package rest

rest/middleware.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ func getRequestDataAndID(ctx context.Context) (protocol.DocumentURI, *lspData, e
7474
type middlewareFunc func(http.HandlerFunc) http.HandlerFunc
7575

7676
// manageDocumentMiddleware is an HTTP middleware that will:
77-
// * generate and inject a requestID
78-
// * unmarshal the body and inject it in the request context
79-
// * open the document used to analyze
80-
// * assure that the document used to analyze will be closed properly at the end of the HTTP request.
77+
// - generate and inject a requestID
78+
// - unmarshal the body and inject it in the request context
79+
// - open the document used to analyze
80+
// - assure that the document used to analyze will be closed properly at the end of the HTTP request.
8181
func manageDocumentMiddleware(langServer langserver.HeadlessServer) middlewareFunc {
8282
return func(next http.HandlerFunc) http.HandlerFunc {
8383
return func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)