@gitpod/ide-metrics-api-grpcweb 0.0.1-pd-ide-metrics-http.6 → 0.0.1-pd-sf-error-report.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,141 @@
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.reportError = {
32
+ methodName: "reportError",
33
+ service: MetricsService,
34
+ requestStream: false,
35
+ responseStream: false,
36
+ requestType: idemetrics_pb.ReportErrorRequest,
37
+ responseType: idemetrics_pb.ReportErrorResponse
38
+ };
39
+
40
+ exports.MetricsService = MetricsService;
41
+
42
+ function MetricsServiceClient(serviceHost, options) {
43
+ this.serviceHost = serviceHost;
44
+ this.options = options || {};
45
+ }
46
+
47
+ MetricsServiceClient.prototype.addCounter = function addCounter(requestMessage, metadata, callback) {
48
+ if (arguments.length === 2) {
49
+ callback = arguments[1];
50
+ }
51
+ var client = grpc.unary(MetricsService.AddCounter, {
52
+ request: requestMessage,
53
+ host: this.serviceHost,
54
+ metadata: metadata,
55
+ transport: this.options.transport,
56
+ debug: this.options.debug,
57
+ onEnd: function (response) {
58
+ if (callback) {
59
+ if (response.status !== grpc.Code.OK) {
60
+ var err = new Error(response.statusMessage);
61
+ err.code = response.status;
62
+ err.metadata = response.trailers;
63
+ callback(err, null);
64
+ } else {
65
+ callback(null, response.message);
66
+ }
67
+ }
68
+ }
69
+ });
70
+ return {
71
+ cancel: function () {
72
+ callback = null;
73
+ client.close();
74
+ }
75
+ };
76
+ };
77
+
78
+ MetricsServiceClient.prototype.observeHistogram = function observeHistogram(requestMessage, metadata, callback) {
79
+ if (arguments.length === 2) {
80
+ callback = arguments[1];
81
+ }
82
+ var client = grpc.unary(MetricsService.ObserveHistogram, {
83
+ request: requestMessage,
84
+ host: this.serviceHost,
85
+ metadata: metadata,
86
+ transport: this.options.transport,
87
+ debug: this.options.debug,
88
+ onEnd: function (response) {
89
+ if (callback) {
90
+ if (response.status !== grpc.Code.OK) {
91
+ var err = new Error(response.statusMessage);
92
+ err.code = response.status;
93
+ err.metadata = response.trailers;
94
+ callback(err, null);
95
+ } else {
96
+ callback(null, response.message);
97
+ }
98
+ }
99
+ }
100
+ });
101
+ return {
102
+ cancel: function () {
103
+ callback = null;
104
+ client.close();
105
+ }
106
+ };
107
+ };
108
+
109
+ MetricsServiceClient.prototype.reportError = function reportError(requestMessage, metadata, callback) {
110
+ if (arguments.length === 2) {
111
+ callback = arguments[1];
112
+ }
113
+ var client = grpc.unary(MetricsService.reportError, {
114
+ request: requestMessage,
115
+ host: this.serviceHost,
116
+ metadata: metadata,
117
+ transport: this.options.transport,
118
+ debug: this.options.debug,
119
+ onEnd: function (response) {
120
+ if (callback) {
121
+ if (response.status !== grpc.Code.OK) {
122
+ var err = new Error(response.statusMessage);
123
+ err.code = response.status;
124
+ err.metadata = response.trailers;
125
+ callback(err, null);
126
+ } else {
127
+ callback(null, response.message);
128
+ }
129
+ }
130
+ }
131
+ });
132
+ return {
133
+ cancel: function () {
134
+ callback = null;
135
+ client.close();
136
+ }
137
+ };
138
+ };
139
+
140
+ exports.MetricsServiceClient = MetricsServiceClient;
141
+
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>[]>;