@gitpod/ide-metrics-api-grpcweb 0.0.1-sefftinge-add-phone-verification-11339.34 → 0.0.1-sje-no-log-envvars.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,120 @@
1
+ // package: ide_metrics_api
2
+ // file: idemetrics.proto
3
+
4
+ import * as idemetrics_pb from "./idemetrics_pb";
5
+ import {grpc} from "@improbable-eng/grpc-web";
6
+
7
+ type MetricsServiceAddCounter = {
8
+ readonly methodName: string;
9
+ readonly service: typeof MetricsService;
10
+ readonly requestStream: false;
11
+ readonly responseStream: false;
12
+ readonly requestType: typeof idemetrics_pb.AddCounterRequest;
13
+ readonly responseType: typeof idemetrics_pb.AddCounterResponse;
14
+ };
15
+
16
+ type MetricsServiceObserveHistogram = {
17
+ readonly methodName: string;
18
+ readonly service: typeof MetricsService;
19
+ readonly requestStream: false;
20
+ readonly responseStream: false;
21
+ readonly requestType: typeof idemetrics_pb.ObserveHistogramRequest;
22
+ readonly responseType: typeof idemetrics_pb.ObserveHistogramResponse;
23
+ };
24
+
25
+ type MetricsServiceAddHistogram = {
26
+ readonly methodName: string;
27
+ readonly service: typeof MetricsService;
28
+ readonly requestStream: false;
29
+ readonly responseStream: false;
30
+ readonly requestType: typeof idemetrics_pb.AddHistogramRequest;
31
+ readonly responseType: typeof idemetrics_pb.AddHistogramResponse;
32
+ };
33
+
34
+ type MetricsServicereportError = {
35
+ readonly methodName: string;
36
+ readonly service: typeof MetricsService;
37
+ readonly requestStream: false;
38
+ readonly responseStream: false;
39
+ readonly requestType: typeof idemetrics_pb.ReportErrorRequest;
40
+ readonly responseType: typeof idemetrics_pb.ReportErrorResponse;
41
+ };
42
+
43
+ export class MetricsService {
44
+ static readonly serviceName: string;
45
+ static readonly AddCounter: MetricsServiceAddCounter;
46
+ static readonly ObserveHistogram: MetricsServiceObserveHistogram;
47
+ static readonly AddHistogram: MetricsServiceAddHistogram;
48
+ static readonly reportError: MetricsServicereportError;
49
+ }
50
+
51
+ export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
52
+ export type Status = { details: string, code: number; metadata: grpc.Metadata }
53
+
54
+ interface UnaryResponse {
55
+ cancel(): void;
56
+ }
57
+ interface ResponseStream<T> {
58
+ cancel(): void;
59
+ on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
60
+ on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
61
+ on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
62
+ }
63
+ interface RequestStream<T> {
64
+ write(message: T): RequestStream<T>;
65
+ end(): void;
66
+ cancel(): void;
67
+ on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
68
+ on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
69
+ }
70
+ interface BidirectionalStream<ReqT, ResT> {
71
+ write(message: ReqT): BidirectionalStream<ReqT, ResT>;
72
+ end(): void;
73
+ cancel(): void;
74
+ on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
75
+ on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
76
+ on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
77
+ }
78
+
79
+ export class MetricsServiceClient {
80
+ readonly serviceHost: string;
81
+
82
+ constructor(serviceHost: string, options?: grpc.RpcOptions);
83
+ addCounter(
84
+ requestMessage: idemetrics_pb.AddCounterRequest,
85
+ metadata: grpc.Metadata,
86
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.AddCounterResponse|null) => void
87
+ ): UnaryResponse;
88
+ addCounter(
89
+ requestMessage: idemetrics_pb.AddCounterRequest,
90
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.AddCounterResponse|null) => void
91
+ ): UnaryResponse;
92
+ observeHistogram(
93
+ requestMessage: idemetrics_pb.ObserveHistogramRequest,
94
+ metadata: grpc.Metadata,
95
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.ObserveHistogramResponse|null) => void
96
+ ): UnaryResponse;
97
+ observeHistogram(
98
+ requestMessage: idemetrics_pb.ObserveHistogramRequest,
99
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.ObserveHistogramResponse|null) => void
100
+ ): UnaryResponse;
101
+ addHistogram(
102
+ requestMessage: idemetrics_pb.AddHistogramRequest,
103
+ metadata: grpc.Metadata,
104
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.AddHistogramResponse|null) => void
105
+ ): UnaryResponse;
106
+ addHistogram(
107
+ requestMessage: idemetrics_pb.AddHistogramRequest,
108
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.AddHistogramResponse|null) => void
109
+ ): UnaryResponse;
110
+ reportError(
111
+ requestMessage: idemetrics_pb.ReportErrorRequest,
112
+ metadata: grpc.Metadata,
113
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.ReportErrorResponse|null) => void
114
+ ): UnaryResponse;
115
+ reportError(
116
+ requestMessage: idemetrics_pb.ReportErrorRequest,
117
+ callback: (error: ServiceError|null, responseMessage: idemetrics_pb.ReportErrorResponse|null) => void
118
+ ): UnaryResponse;
119
+ }
120
+
@@ -0,0 +1,181 @@
1
+ // package: ide_metrics_api
2
+ // file: idemetrics.proto
3
+
4
+ var idemetrics_pb = require("./idemetrics_pb");
5
+ var grpc = require("@improbable-eng/grpc-web").grpc;
6
+
7
+ var MetricsService = (function () {
8
+ function MetricsService() {}
9
+ MetricsService.serviceName = "ide_metrics_api.MetricsService";
10
+ return MetricsService;
11
+ }());
12
+
13
+ MetricsService.AddCounter = {
14
+ methodName: "AddCounter",
15
+ service: MetricsService,
16
+ requestStream: false,
17
+ responseStream: false,
18
+ requestType: idemetrics_pb.AddCounterRequest,
19
+ responseType: idemetrics_pb.AddCounterResponse
20
+ };
21
+
22
+ MetricsService.ObserveHistogram = {
23
+ methodName: "ObserveHistogram",
24
+ service: MetricsService,
25
+ requestStream: false,
26
+ responseStream: false,
27
+ requestType: idemetrics_pb.ObserveHistogramRequest,
28
+ responseType: idemetrics_pb.ObserveHistogramResponse
29
+ };
30
+
31
+ MetricsService.AddHistogram = {
32
+ methodName: "AddHistogram",
33
+ service: MetricsService,
34
+ requestStream: false,
35
+ responseStream: false,
36
+ requestType: idemetrics_pb.AddHistogramRequest,
37
+ responseType: idemetrics_pb.AddHistogramResponse
38
+ };
39
+
40
+ MetricsService.reportError = {
41
+ methodName: "reportError",
42
+ service: MetricsService,
43
+ requestStream: false,
44
+ responseStream: false,
45
+ requestType: idemetrics_pb.ReportErrorRequest,
46
+ responseType: idemetrics_pb.ReportErrorResponse
47
+ };
48
+
49
+ exports.MetricsService = MetricsService;
50
+
51
+ function MetricsServiceClient(serviceHost, options) {
52
+ this.serviceHost = serviceHost;
53
+ this.options = options || {};
54
+ }
55
+
56
+ MetricsServiceClient.prototype.addCounter = function addCounter(requestMessage, metadata, callback) {
57
+ if (arguments.length === 2) {
58
+ callback = arguments[1];
59
+ }
60
+ var client = grpc.unary(MetricsService.AddCounter, {
61
+ request: requestMessage,
62
+ host: this.serviceHost,
63
+ metadata: metadata,
64
+ transport: this.options.transport,
65
+ debug: this.options.debug,
66
+ onEnd: function (response) {
67
+ if (callback) {
68
+ if (response.status !== grpc.Code.OK) {
69
+ var err = new Error(response.statusMessage);
70
+ err.code = response.status;
71
+ err.metadata = response.trailers;
72
+ callback(err, null);
73
+ } else {
74
+ callback(null, response.message);
75
+ }
76
+ }
77
+ }
78
+ });
79
+ return {
80
+ cancel: function () {
81
+ callback = null;
82
+ client.close();
83
+ }
84
+ };
85
+ };
86
+
87
+ MetricsServiceClient.prototype.observeHistogram = function observeHistogram(requestMessage, metadata, callback) {
88
+ if (arguments.length === 2) {
89
+ callback = arguments[1];
90
+ }
91
+ var client = grpc.unary(MetricsService.ObserveHistogram, {
92
+ request: requestMessage,
93
+ host: this.serviceHost,
94
+ metadata: metadata,
95
+ transport: this.options.transport,
96
+ debug: this.options.debug,
97
+ onEnd: function (response) {
98
+ if (callback) {
99
+ if (response.status !== grpc.Code.OK) {
100
+ var err = new Error(response.statusMessage);
101
+ err.code = response.status;
102
+ err.metadata = response.trailers;
103
+ callback(err, null);
104
+ } else {
105
+ callback(null, response.message);
106
+ }
107
+ }
108
+ }
109
+ });
110
+ return {
111
+ cancel: function () {
112
+ callback = null;
113
+ client.close();
114
+ }
115
+ };
116
+ };
117
+
118
+ MetricsServiceClient.prototype.addHistogram = function addHistogram(requestMessage, metadata, callback) {
119
+ if (arguments.length === 2) {
120
+ callback = arguments[1];
121
+ }
122
+ var client = grpc.unary(MetricsService.AddHistogram, {
123
+ request: requestMessage,
124
+ host: this.serviceHost,
125
+ metadata: metadata,
126
+ transport: this.options.transport,
127
+ debug: this.options.debug,
128
+ onEnd: function (response) {
129
+ if (callback) {
130
+ if (response.status !== grpc.Code.OK) {
131
+ var err = new Error(response.statusMessage);
132
+ err.code = response.status;
133
+ err.metadata = response.trailers;
134
+ callback(err, null);
135
+ } else {
136
+ callback(null, response.message);
137
+ }
138
+ }
139
+ }
140
+ });
141
+ return {
142
+ cancel: function () {
143
+ callback = null;
144
+ client.close();
145
+ }
146
+ };
147
+ };
148
+
149
+ MetricsServiceClient.prototype.reportError = function reportError(requestMessage, metadata, callback) {
150
+ if (arguments.length === 2) {
151
+ callback = arguments[1];
152
+ }
153
+ var client = grpc.unary(MetricsService.reportError, {
154
+ request: requestMessage,
155
+ host: this.serviceHost,
156
+ metadata: metadata,
157
+ transport: this.options.transport,
158
+ debug: this.options.debug,
159
+ onEnd: function (response) {
160
+ if (callback) {
161
+ if (response.status !== grpc.Code.OK) {
162
+ var err = new Error(response.statusMessage);
163
+ err.code = response.status;
164
+ err.metadata = response.trailers;
165
+ callback(err, null);
166
+ } else {
167
+ callback(null, response.message);
168
+ }
169
+ }
170
+ }
171
+ });
172
+ return {
173
+ cancel: function () {
174
+ callback = null;
175
+ client.close();
176
+ }
177
+ };
178
+ };
179
+
180
+ exports.MetricsServiceClient = MetricsServiceClient;
181
+
package/lib/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+ export * from "../lib/idemetrics_pb";
7
+ export * from "../lib/idemetrics_pb_service";
8
+ import { MetricsServiceClient } from "../lib/idemetrics_pb_service";
9
+ export interface IDEMetric {
10
+ kind: "counter" | "histogram";
11
+ name: string;
12
+ labels: Record<string, string>;
13
+ value?: number;
14
+ }
15
+ export declare function sendMetrics(client: MetricsServiceClient, metrics: IDEMetric[]): Promise<PromiseSettledResult<void>[]>;