@miradorlabs/parallax-web 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -84
- package/dist/index.d.ts +9 -14
- package/dist/index.esm.js +116 -132
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +162 -150
- package/dist/index.umd.js.map +1 -1
- package/index.ts +16 -0
- package/package.json +2 -1
- package/src/parallax/index.ts +28 -53
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @miradorlabs/parallax-web
|
|
|
13
13
|
### Basic Setup
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import { ParallaxClient } from '@miradorlabs/parallax-web';
|
|
16
|
+
import { ParallaxClient, CreateTraceRequest } from '@miradorlabs/parallax-web';
|
|
17
17
|
|
|
18
18
|
// Initialize the client with your API key
|
|
19
19
|
const client = new ParallaxClient('your-api-key');
|
|
@@ -25,133 +25,160 @@ const client = new ParallaxClient('your-api-key', 'https://your-gateway.example.
|
|
|
25
25
|
### Creating a Trace
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
import { CreateTraceRequest } from '@miradorlabs/parallax-web';
|
|
29
|
+
|
|
30
|
+
const request = new CreateTraceRequest();
|
|
31
|
+
request.setName('My Application Trace');
|
|
32
|
+
|
|
33
|
+
// Set attributes using the map
|
|
34
|
+
const attributesMap = request.getAttributesMap();
|
|
35
|
+
attributesMap.set('project.id', 'my-project');
|
|
36
|
+
attributesMap.set('environment', 'production');
|
|
37
|
+
|
|
38
|
+
request.setTagsList(['web', 'user-action']);
|
|
39
|
+
|
|
40
|
+
const traceResponse = await client.createTrace(request);
|
|
41
|
+
const traceId = traceResponse.getTraceId();
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
### Starting a Span
|
|
41
45
|
|
|
42
46
|
```typescript
|
|
43
|
-
|
|
44
|
-
name: 'User Login',
|
|
45
|
-
traceId: traceId,
|
|
46
|
-
attributes: {
|
|
47
|
-
'user.id': 'user-123',
|
|
48
|
-
'action': 'login',
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const spanId = spanResponse.spanId;
|
|
53
|
-
```
|
|
47
|
+
import { StartSpanRequest } from '@miradorlabs/parallax-web';
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
const request = new StartSpanRequest();
|
|
50
|
+
request.setName('User Login');
|
|
51
|
+
request.setTraceId(traceId);
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
});
|
|
53
|
+
// Set attributes using the map
|
|
54
|
+
const attributesMap = request.getAttributesMap();
|
|
55
|
+
attributesMap.set('user.id', 'user-123');
|
|
56
|
+
attributesMap.set('action', 'login');
|
|
57
|
+
|
|
58
|
+
const spanResponse = await client.startSpan(request);
|
|
59
|
+
const spanId = spanResponse.getSpanId();
|
|
66
60
|
```
|
|
67
61
|
|
|
68
62
|
### Adding Span Events
|
|
69
63
|
|
|
70
64
|
```typescript
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
import { AddSpanEventRequest } from '@miradorlabs/parallax-web';
|
|
66
|
+
|
|
67
|
+
const request = new AddSpanEventRequest();
|
|
68
|
+
request.setTraceId(traceId);
|
|
69
|
+
request.setSpanId(spanId);
|
|
70
|
+
request.setEventName('User Authenticated');
|
|
71
|
+
|
|
72
|
+
const attributesMap = request.getAttributesMap();
|
|
73
|
+
attributesMap.set('auth.method', 'oauth');
|
|
74
|
+
attributesMap.set('auth.provider', 'google');
|
|
75
|
+
|
|
76
|
+
await client.addSpanEvent(request);
|
|
80
77
|
```
|
|
81
78
|
|
|
82
79
|
### Adding Span Errors
|
|
83
80
|
|
|
84
81
|
```typescript
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
import { AddSpanErrorRequest } from '@miradorlabs/parallax-web';
|
|
83
|
+
|
|
84
|
+
const request = new AddSpanErrorRequest();
|
|
85
|
+
request.setTraceId(traceId);
|
|
86
|
+
request.setSpanId(spanId);
|
|
87
|
+
request.setErrorType('ValidationError');
|
|
88
|
+
request.setMessage('Invalid email format');
|
|
89
|
+
request.setStackTrace(error.stack);
|
|
90
|
+
|
|
91
|
+
const attributesMap = request.getAttributesMap();
|
|
92
|
+
attributesMap.set('error.field', 'email');
|
|
93
|
+
|
|
94
|
+
await client.addSpanError(request);
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
### Adding Span Hints (Blockchain Transactions)
|
|
98
98
|
|
|
99
99
|
```typescript
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
import { AddSpanHintRequest } from '@miradorlabs/parallax-web';
|
|
101
|
+
|
|
102
|
+
const chainTx = new AddSpanHintRequest.ChainTransaction();
|
|
103
|
+
chainTx.setTxHash('0x1234567890abcdef');
|
|
104
|
+
chainTx.setChainId(1); // Ethereum mainnet
|
|
105
|
+
|
|
106
|
+
const request = new AddSpanHintRequest();
|
|
107
|
+
request.setTraceId(traceId);
|
|
108
|
+
request.setParentSpanId(spanId);
|
|
109
|
+
request.setChainTransaction(chainTx);
|
|
110
|
+
|
|
111
|
+
await client.addSpanHint(request);
|
|
108
112
|
```
|
|
109
113
|
|
|
110
114
|
### Finishing a Span
|
|
111
115
|
|
|
112
116
|
```typescript
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
import { FinishSpanRequest } from '@miradorlabs/parallax-web';
|
|
118
|
+
|
|
119
|
+
const spanStatus = new FinishSpanRequest.SpanStatus();
|
|
120
|
+
spanStatus.setCode(FinishSpanRequest.SpanStatus.StatusCode.STATUS_CODE_OK);
|
|
121
|
+
|
|
122
|
+
const request = new FinishSpanRequest();
|
|
123
|
+
request.setTraceId(traceId);
|
|
124
|
+
request.setSpanId(spanId);
|
|
125
|
+
request.setStatus(spanStatus);
|
|
126
|
+
|
|
127
|
+
await client.finishSpan(request);
|
|
117
128
|
```
|
|
118
129
|
|
|
119
130
|
## Complete Example
|
|
120
131
|
|
|
121
132
|
```typescript
|
|
122
|
-
import {
|
|
133
|
+
import {
|
|
134
|
+
ParallaxClient,
|
|
135
|
+
CreateTraceRequest,
|
|
136
|
+
StartSpanRequest,
|
|
137
|
+
AddSpanEventRequest,
|
|
138
|
+
FinishSpanRequest,
|
|
139
|
+
} from '@miradorlabs/parallax-web';
|
|
123
140
|
|
|
124
141
|
async function trackUserAction() {
|
|
125
142
|
const client = new ParallaxClient('your-api-key');
|
|
126
143
|
|
|
127
144
|
try {
|
|
128
145
|
// Create trace
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
const createTraceReq = new CreateTraceRequest();
|
|
147
|
+
createTraceReq.setName('User Purchase Flow');
|
|
148
|
+
createTraceReq.getAttributesMap().set('user.id', 'user-123');
|
|
149
|
+
createTraceReq.setTagsList(['purchase', 'web']);
|
|
150
|
+
|
|
151
|
+
const traceResponse = await client.createTrace(createTraceReq);
|
|
152
|
+
const traceId = traceResponse.getTraceId();
|
|
134
153
|
|
|
135
154
|
// Start span
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
155
|
+
const startSpanReq = new StartSpanRequest();
|
|
156
|
+
startSpanReq.setName('Checkout Process');
|
|
157
|
+
startSpanReq.setTraceId(traceId);
|
|
158
|
+
startSpanReq.getAttributesMap().set('cart.items', '3');
|
|
159
|
+
|
|
160
|
+
const spanResponse = await client.startSpan(startSpanReq);
|
|
161
|
+
const spanId = spanResponse.getSpanId();
|
|
141
162
|
|
|
142
163
|
// Add event
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
164
|
+
const addEventReq = new AddSpanEventRequest();
|
|
165
|
+
addEventReq.setTraceId(traceId);
|
|
166
|
+
addEventReq.setSpanId(spanId);
|
|
167
|
+
addEventReq.setEventName('Payment Initiated');
|
|
168
|
+
addEventReq.getAttributesMap().set('payment.method', 'card');
|
|
169
|
+
|
|
170
|
+
await client.addSpanEvent(addEventReq);
|
|
149
171
|
|
|
150
172
|
// Finish span
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
173
|
+
const finishSpanReq = new FinishSpanRequest();
|
|
174
|
+
finishSpanReq.setTraceId(traceId);
|
|
175
|
+
finishSpanReq.setSpanId(spanId);
|
|
176
|
+
|
|
177
|
+
const spanStatus = new FinishSpanRequest.SpanStatus();
|
|
178
|
+
spanStatus.setCode(FinishSpanRequest.SpanStatus.StatusCode.STATUS_CODE_OK);
|
|
179
|
+
finishSpanReq.setStatus(spanStatus);
|
|
180
|
+
|
|
181
|
+
await client.finishSpan(finishSpanReq);
|
|
155
182
|
} catch (error) {
|
|
156
183
|
console.error('Tracing error:', error);
|
|
157
184
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { CreateTraceRequest, CreateTraceResponse, StartSpanRequest, StartSpanResponse, FinishSpanRequest, FinishSpanResponse, AddSpanEventRequest, AddSpanEventResponse, AddSpanErrorRequest, AddSpanErrorResponse, AddSpanHintRequest, AddSpanHintResponse } from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb';
|
|
2
|
+
export { AddSpanErrorRequest, AddSpanErrorResponse, AddSpanEventRequest, AddSpanEventResponse, AddSpanHintRequest, AddSpanHintResponse, CreateTraceRequest, CreateTraceResponse, FinishSpanRequest, FinishSpanResponse, StartSpanRequest, StartSpanResponse } from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
declare class ParallaxClient {
|
|
6
6
|
apiKey?: string | undefined;
|
|
7
7
|
apiUrl: string;
|
|
8
|
-
private
|
|
8
|
+
private client;
|
|
9
9
|
constructor(apiKey?: string | undefined, apiUrl?: string);
|
|
10
10
|
/**
|
|
11
11
|
* Create a new trace
|
|
12
12
|
* @param params Parameters to create a new trace
|
|
13
13
|
* @returns Response from the create trace operation
|
|
14
14
|
*/
|
|
15
|
-
createTrace(params: CreateTraceRequest): Promise<
|
|
15
|
+
createTrace(params: CreateTraceRequest): Promise<CreateTraceResponse>;
|
|
16
16
|
/**
|
|
17
17
|
* Start a new span within a trace
|
|
18
18
|
* @param params Parameters to start a new span
|
|
19
19
|
*/
|
|
20
|
-
startSpan(params: StartSpanRequest): Promise<
|
|
20
|
+
startSpan(params: StartSpanRequest): Promise<StartSpanResponse>;
|
|
21
21
|
/**
|
|
22
22
|
* Finish a span within a trace
|
|
23
23
|
* @param params Parameters to finish a span
|
|
24
24
|
*/
|
|
25
|
-
finishSpan(params: FinishSpanRequest): Promise<
|
|
26
|
-
/**
|
|
27
|
-
* Add attributes to a span
|
|
28
|
-
* @param params Parameters to add attributes to a span
|
|
29
|
-
*/
|
|
30
|
-
addSpanAttributes(params: AddSpanAttributesRequest): Promise<any>;
|
|
25
|
+
finishSpan(params: FinishSpanRequest): Promise<FinishSpanResponse>;
|
|
31
26
|
/**
|
|
32
27
|
* Add an event to a span
|
|
33
28
|
* @param params Parameters to add an event to a span
|
|
34
29
|
*/
|
|
35
|
-
addSpanEvent(params: AddSpanEventRequest): Promise<
|
|
30
|
+
addSpanEvent(params: AddSpanEventRequest): Promise<AddSpanEventResponse>;
|
|
36
31
|
/**
|
|
37
32
|
* Add an error to a span
|
|
38
33
|
* @param params Parameters to add an error to a span
|
|
39
34
|
*/
|
|
40
|
-
addSpanError(params: AddSpanErrorRequest): Promise<
|
|
35
|
+
addSpanError(params: AddSpanErrorRequest): Promise<AddSpanErrorResponse>;
|
|
41
36
|
/**
|
|
42
37
|
* Add a hint to a span
|
|
43
38
|
* @param params Parameters to add a hint to a span
|
|
44
39
|
*/
|
|
45
|
-
addSpanHint(params: AddSpanHintRequest): Promise<
|
|
40
|
+
addSpanHint(params: AddSpanHintRequest): Promise<AddSpanHintResponse>;
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
interface Metadata {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,120 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ParallaxGatewayServiceClient } from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/Parallax_gatewayServiceClientPb';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
export { AddSpanErrorRequest, AddSpanErrorResponse, AddSpanEventRequest, AddSpanEventResponse, AddSpanHintRequest, AddSpanHintResponse, CreateTraceRequest, CreateTraceResponse, FinishSpanRequest, FinishSpanResponse, StartSpanRequest, StartSpanResponse } from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb';
|
|
4
|
+
|
|
5
|
+
const GRPC_GATEWAY_API_URL = "https://gateway-parallax-dev.platform.svc.cluster.local:50053";
|
|
6
|
+
const debugIssue = (trace, error) => {
|
|
7
|
+
// Handle our own debugging / logging here
|
|
8
|
+
console.error(`[ParallaxClient][${trace}] Error:`, error);
|
|
9
|
+
};
|
|
10
|
+
class ParallaxClient {
|
|
11
|
+
constructor(apiKey, apiUrl) {
|
|
12
|
+
Object.defineProperty(this, "apiKey", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: apiKey
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "apiUrl", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: GRPC_GATEWAY_API_URL
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "client", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
if (apiUrl) {
|
|
31
|
+
this.apiUrl = apiUrl;
|
|
32
|
+
}
|
|
33
|
+
// Create credentials object with API key if provided
|
|
34
|
+
const credentials = apiKey ? { 'x-api-key': apiKey } : undefined;
|
|
35
|
+
// Initialize the gRPC-Web client
|
|
36
|
+
this.client = new ParallaxGatewayServiceClient(this.apiUrl, credentials);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a new trace
|
|
40
|
+
* @param params Parameters to create a new trace
|
|
41
|
+
* @returns Response from the create trace operation
|
|
42
|
+
*/
|
|
43
|
+
async createTrace(params) {
|
|
44
|
+
try {
|
|
45
|
+
return await this.client.createTrace(params, null);
|
|
46
|
+
}
|
|
47
|
+
catch (_error) {
|
|
48
|
+
debugIssue("createTrace", new Error('Error creating trace'));
|
|
49
|
+
throw _error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Start a new span within a trace
|
|
54
|
+
* @param params Parameters to start a new span
|
|
55
|
+
*/
|
|
56
|
+
async startSpan(params) {
|
|
57
|
+
try {
|
|
58
|
+
return await this.client.startSpan(params, null);
|
|
59
|
+
}
|
|
60
|
+
catch (_error) {
|
|
61
|
+
debugIssue("startSpan", new Error('Error starting span'));
|
|
62
|
+
throw _error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Finish a span within a trace
|
|
67
|
+
* @param params Parameters to finish a span
|
|
68
|
+
*/
|
|
69
|
+
async finishSpan(params) {
|
|
70
|
+
try {
|
|
71
|
+
return await this.client.finishSpan(params, null);
|
|
72
|
+
}
|
|
73
|
+
catch (_error) {
|
|
74
|
+
debugIssue("finishSpan", new Error('Error finishing span'));
|
|
75
|
+
throw _error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Add an event to a span
|
|
80
|
+
* @param params Parameters to add an event to a span
|
|
81
|
+
*/
|
|
82
|
+
async addSpanEvent(params) {
|
|
83
|
+
try {
|
|
84
|
+
return await this.client.addSpanEvent(params, null);
|
|
85
|
+
}
|
|
86
|
+
catch (_error) {
|
|
87
|
+
debugIssue("addSpanEvent", new Error('Error adding span event'));
|
|
88
|
+
throw _error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Add an error to a span
|
|
93
|
+
* @param params Parameters to add an error to a span
|
|
94
|
+
*/
|
|
95
|
+
async addSpanError(params) {
|
|
96
|
+
try {
|
|
97
|
+
return await this.client.addSpanError(params, null);
|
|
98
|
+
}
|
|
99
|
+
catch (_error) {
|
|
100
|
+
debugIssue("addSpanError", new Error('Error adding span error'));
|
|
101
|
+
throw _error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Add a hint to a span
|
|
106
|
+
* @param params Parameters to add a hint to a span
|
|
107
|
+
*/
|
|
108
|
+
async addSpanHint(params) {
|
|
109
|
+
try {
|
|
110
|
+
return await this.client.addSpanHint(params, null);
|
|
111
|
+
}
|
|
112
|
+
catch (_error) {
|
|
113
|
+
debugIssue("addSpanHint", new Error('Error adding span hint'));
|
|
114
|
+
throw _error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
3
118
|
|
|
4
119
|
class GrpcWebRpc {
|
|
5
120
|
constructor(url, apiKey) {
|
|
@@ -108,136 +223,5 @@ class GrpcWebRpc {
|
|
|
108
223
|
}
|
|
109
224
|
}
|
|
110
225
|
|
|
111
|
-
const GRPC_GATEWAY_API_URL = "https://gateway-parallax-dev.platform.svc.cluster.local:50053";
|
|
112
|
-
const debugIssue = (trace, error) => {
|
|
113
|
-
// Handle our own debugging / logging here
|
|
114
|
-
console.error(`[ParallaxClient][${trace}] Error:`, error);
|
|
115
|
-
};
|
|
116
|
-
class ParallaxClient {
|
|
117
|
-
constructor(apiKey, apiUrl) {
|
|
118
|
-
Object.defineProperty(this, "apiKey", {
|
|
119
|
-
enumerable: true,
|
|
120
|
-
configurable: true,
|
|
121
|
-
writable: true,
|
|
122
|
-
value: apiKey
|
|
123
|
-
});
|
|
124
|
-
Object.defineProperty(this, "apiUrl", {
|
|
125
|
-
enumerable: true,
|
|
126
|
-
configurable: true,
|
|
127
|
-
writable: true,
|
|
128
|
-
value: GRPC_GATEWAY_API_URL
|
|
129
|
-
});
|
|
130
|
-
Object.defineProperty(this, "apiGatewayRpc", {
|
|
131
|
-
enumerable: true,
|
|
132
|
-
configurable: true,
|
|
133
|
-
writable: true,
|
|
134
|
-
value: void 0
|
|
135
|
-
});
|
|
136
|
-
if (apiUrl) {
|
|
137
|
-
this.apiUrl = apiUrl;
|
|
138
|
-
}
|
|
139
|
-
this.apiGatewayRpc = new GrpcWebRpc(this.apiUrl, apiKey);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Create a new trace
|
|
143
|
-
* @param params Parameters to create a new trace
|
|
144
|
-
* @returns Response from the create trace operation
|
|
145
|
-
*/
|
|
146
|
-
async createTrace(params) {
|
|
147
|
-
try {
|
|
148
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
149
|
-
return await apiGatewayClient.CreateTrace(params);
|
|
150
|
-
}
|
|
151
|
-
catch (_error) {
|
|
152
|
-
debugIssue("createTrace", new Error('Error creating trace'));
|
|
153
|
-
throw _error;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Start a new span within a trace
|
|
158
|
-
* @param params Parameters to start a new span
|
|
159
|
-
*/
|
|
160
|
-
async startSpan(params) {
|
|
161
|
-
try {
|
|
162
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
163
|
-
return await apiGatewayClient.StartSpan(params);
|
|
164
|
-
}
|
|
165
|
-
catch (_error) {
|
|
166
|
-
debugIssue("startSpan", new Error('Error starting span'));
|
|
167
|
-
throw _error;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Finish a span within a trace
|
|
172
|
-
* @param params Parameters to finish a span
|
|
173
|
-
*/
|
|
174
|
-
async finishSpan(params) {
|
|
175
|
-
try {
|
|
176
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
177
|
-
return await apiGatewayClient.FinishSpan(params);
|
|
178
|
-
}
|
|
179
|
-
catch (_error) {
|
|
180
|
-
debugIssue("finishSpan", new Error('Error finishing span'));
|
|
181
|
-
throw _error;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Add attributes to a span
|
|
186
|
-
* @param params Parameters to add attributes to a span
|
|
187
|
-
*/
|
|
188
|
-
async addSpanAttributes(params) {
|
|
189
|
-
try {
|
|
190
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
191
|
-
return await apiGatewayClient.AddSpanAttributes(params);
|
|
192
|
-
}
|
|
193
|
-
catch (_error) {
|
|
194
|
-
debugIssue("addSpanAttributes", new Error('Error adding span attributes'));
|
|
195
|
-
throw _error;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Add an event to a span
|
|
200
|
-
* @param params Parameters to add an event to a span
|
|
201
|
-
*/
|
|
202
|
-
async addSpanEvent(params) {
|
|
203
|
-
try {
|
|
204
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
205
|
-
return await apiGatewayClient.AddSpanEvent(params);
|
|
206
|
-
}
|
|
207
|
-
catch (_error) {
|
|
208
|
-
debugIssue("addSpanEvent", new Error('Error adding span event'));
|
|
209
|
-
throw _error;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Add an error to a span
|
|
214
|
-
* @param params Parameters to add an error to a span
|
|
215
|
-
*/
|
|
216
|
-
async addSpanError(params) {
|
|
217
|
-
try {
|
|
218
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
219
|
-
return await apiGatewayClient.AddSpanError(params);
|
|
220
|
-
}
|
|
221
|
-
catch (_error) {
|
|
222
|
-
debugIssue("addSpanError", new Error('Error adding span error'));
|
|
223
|
-
throw _error;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Add a hint to a span
|
|
228
|
-
* @param params Parameters to add a hint to a span
|
|
229
|
-
*/
|
|
230
|
-
async addSpanHint(params) {
|
|
231
|
-
try {
|
|
232
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
233
|
-
return await apiGatewayClient.AddSpanHint(params);
|
|
234
|
-
}
|
|
235
|
-
catch (_error) {
|
|
236
|
-
debugIssue("addSpanHint", new Error('Error adding span hint'));
|
|
237
|
-
throw _error;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
226
|
export { GrpcWebRpc, ParallaxClient };
|
|
243
227
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/parallax/index.ts","../../src/grpc/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;AAiBA,MAAM,oBAAoB,GAAG,+DAA+D;AAE5F,MAAM,UAAU,GAAG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
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mirador-gateway-parallax-web/proto/gateway/parallax/v1/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ParallaxWeb = {}, global.
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mirador-gateway-parallax-web/proto/gateway/parallax/v1/Parallax_gatewayServiceClientPb'), require('rxjs'), require('mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/Parallax_gatewayServiceClientPb', 'rxjs', 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ParallaxWeb = {}, global.Parallax_gatewayServiceClientPb, global.rxjs, global.parallax_gateway_pb));
|
|
5
|
+
})(this, (function (exports, Parallax_gatewayServiceClientPb, rxjs, parallax_gateway_pb) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
const GRPC_GATEWAY_API_URL = "https://gateway-parallax-dev.platform.svc.cluster.local:50053";
|
|
8
|
+
const debugIssue = (trace, error) => {
|
|
9
|
+
// Handle our own debugging / logging here
|
|
10
|
+
console.error(`[ParallaxClient][${trace}] Error:`, error);
|
|
11
|
+
};
|
|
12
|
+
class ParallaxClient {
|
|
13
|
+
constructor(apiKey, apiUrl) {
|
|
14
|
+
Object.defineProperty(this, "apiKey", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: apiKey
|
|
18
19
|
});
|
|
20
|
+
Object.defineProperty(this, "apiUrl", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: GRPC_GATEWAY_API_URL
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "client", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
if (apiUrl) {
|
|
33
|
+
this.apiUrl = apiUrl;
|
|
34
|
+
}
|
|
35
|
+
// Create credentials object with API key if provided
|
|
36
|
+
const credentials = apiKey ? { 'x-api-key': apiKey } : undefined;
|
|
37
|
+
// Initialize the gRPC-Web client
|
|
38
|
+
this.client = new Parallax_gatewayServiceClientPb.ParallaxGatewayServiceClient(this.apiUrl, credentials);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a new trace
|
|
42
|
+
* @param params Parameters to create a new trace
|
|
43
|
+
* @returns Response from the create trace operation
|
|
44
|
+
*/
|
|
45
|
+
async createTrace(params) {
|
|
46
|
+
try {
|
|
47
|
+
return await this.client.createTrace(params, null);
|
|
48
|
+
}
|
|
49
|
+
catch (_error) {
|
|
50
|
+
debugIssue("createTrace", new Error('Error creating trace'));
|
|
51
|
+
throw _error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Start a new span within a trace
|
|
56
|
+
* @param params Parameters to start a new span
|
|
57
|
+
*/
|
|
58
|
+
async startSpan(params) {
|
|
59
|
+
try {
|
|
60
|
+
return await this.client.startSpan(params, null);
|
|
61
|
+
}
|
|
62
|
+
catch (_error) {
|
|
63
|
+
debugIssue("startSpan", new Error('Error starting span'));
|
|
64
|
+
throw _error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Finish a span within a trace
|
|
69
|
+
* @param params Parameters to finish a span
|
|
70
|
+
*/
|
|
71
|
+
async finishSpan(params) {
|
|
72
|
+
try {
|
|
73
|
+
return await this.client.finishSpan(params, null);
|
|
74
|
+
}
|
|
75
|
+
catch (_error) {
|
|
76
|
+
debugIssue("finishSpan", new Error('Error finishing span'));
|
|
77
|
+
throw _error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add an event to a span
|
|
82
|
+
* @param params Parameters to add an event to a span
|
|
83
|
+
*/
|
|
84
|
+
async addSpanEvent(params) {
|
|
85
|
+
try {
|
|
86
|
+
return await this.client.addSpanEvent(params, null);
|
|
87
|
+
}
|
|
88
|
+
catch (_error) {
|
|
89
|
+
debugIssue("addSpanEvent", new Error('Error adding span event'));
|
|
90
|
+
throw _error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Add an error to a span
|
|
95
|
+
* @param params Parameters to add an error to a span
|
|
96
|
+
*/
|
|
97
|
+
async addSpanError(params) {
|
|
98
|
+
try {
|
|
99
|
+
return await this.client.addSpanError(params, null);
|
|
100
|
+
}
|
|
101
|
+
catch (_error) {
|
|
102
|
+
debugIssue("addSpanError", new Error('Error adding span error'));
|
|
103
|
+
throw _error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Add a hint to a span
|
|
108
|
+
* @param params Parameters to add a hint to a span
|
|
109
|
+
*/
|
|
110
|
+
async addSpanHint(params) {
|
|
111
|
+
try {
|
|
112
|
+
return await this.client.addSpanHint(params, null);
|
|
113
|
+
}
|
|
114
|
+
catch (_error) {
|
|
115
|
+
debugIssue("addSpanHint", new Error('Error adding span hint'));
|
|
116
|
+
throw _error;
|
|
117
|
+
}
|
|
19
118
|
}
|
|
20
|
-
n.default = e;
|
|
21
|
-
return Object.freeze(n);
|
|
22
119
|
}
|
|
23
120
|
|
|
24
|
-
var apiGateway__namespace = /*#__PURE__*/_interopNamespaceDefault(apiGateway);
|
|
25
|
-
|
|
26
121
|
class GrpcWebRpc {
|
|
27
122
|
constructor(url, apiKey) {
|
|
28
123
|
Object.defineProperty(this, "url", {
|
|
@@ -130,137 +225,54 @@
|
|
|
130
225
|
}
|
|
131
226
|
}
|
|
132
227
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*/
|
|
182
|
-
async startSpan(params) {
|
|
183
|
-
try {
|
|
184
|
-
const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
185
|
-
return await apiGatewayClient.StartSpan(params);
|
|
186
|
-
}
|
|
187
|
-
catch (_error) {
|
|
188
|
-
debugIssue("startSpan", new Error('Error starting span'));
|
|
189
|
-
throw _error;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Finish a span within a trace
|
|
194
|
-
* @param params Parameters to finish a span
|
|
195
|
-
*/
|
|
196
|
-
async finishSpan(params) {
|
|
197
|
-
try {
|
|
198
|
-
const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
199
|
-
return await apiGatewayClient.FinishSpan(params);
|
|
200
|
-
}
|
|
201
|
-
catch (_error) {
|
|
202
|
-
debugIssue("finishSpan", new Error('Error finishing span'));
|
|
203
|
-
throw _error;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Add attributes to a span
|
|
208
|
-
* @param params Parameters to add attributes to a span
|
|
209
|
-
*/
|
|
210
|
-
async addSpanAttributes(params) {
|
|
211
|
-
try {
|
|
212
|
-
const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
213
|
-
return await apiGatewayClient.AddSpanAttributes(params);
|
|
214
|
-
}
|
|
215
|
-
catch (_error) {
|
|
216
|
-
debugIssue("addSpanAttributes", new Error('Error adding span attributes'));
|
|
217
|
-
throw _error;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Add an event to a span
|
|
222
|
-
* @param params Parameters to add an event to a span
|
|
223
|
-
*/
|
|
224
|
-
async addSpanEvent(params) {
|
|
225
|
-
try {
|
|
226
|
-
const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
227
|
-
return await apiGatewayClient.AddSpanEvent(params);
|
|
228
|
-
}
|
|
229
|
-
catch (_error) {
|
|
230
|
-
debugIssue("addSpanEvent", new Error('Error adding span event'));
|
|
231
|
-
throw _error;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Add an error to a span
|
|
236
|
-
* @param params Parameters to add an error to a span
|
|
237
|
-
*/
|
|
238
|
-
async addSpanError(params) {
|
|
239
|
-
try {
|
|
240
|
-
const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
241
|
-
return await apiGatewayClient.AddSpanError(params);
|
|
242
|
-
}
|
|
243
|
-
catch (_error) {
|
|
244
|
-
debugIssue("addSpanError", new Error('Error adding span error'));
|
|
245
|
-
throw _error;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Add a hint to a span
|
|
250
|
-
* @param params Parameters to add a hint to a span
|
|
251
|
-
*/
|
|
252
|
-
async addSpanHint(params) {
|
|
253
|
-
try {
|
|
254
|
-
const apiGatewayClient = new apiGateway__namespace.ParallaxGatewayServiceClientImpl(this.apiGatewayRpc);
|
|
255
|
-
return await apiGatewayClient.AddSpanHint(params);
|
|
256
|
-
}
|
|
257
|
-
catch (_error) {
|
|
258
|
-
debugIssue("addSpanHint", new Error('Error adding span hint'));
|
|
259
|
-
throw _error;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
228
|
+
Object.defineProperty(exports, "AddSpanErrorRequest", {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function () { return parallax_gateway_pb.AddSpanErrorRequest; }
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(exports, "AddSpanErrorResponse", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function () { return parallax_gateway_pb.AddSpanErrorResponse; }
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, "AddSpanEventRequest", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function () { return parallax_gateway_pb.AddSpanEventRequest; }
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(exports, "AddSpanEventResponse", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function () { return parallax_gateway_pb.AddSpanEventResponse; }
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(exports, "AddSpanHintRequest", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function () { return parallax_gateway_pb.AddSpanHintRequest; }
|
|
247
|
+
});
|
|
248
|
+
Object.defineProperty(exports, "AddSpanHintResponse", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
get: function () { return parallax_gateway_pb.AddSpanHintResponse; }
|
|
251
|
+
});
|
|
252
|
+
Object.defineProperty(exports, "CreateTraceRequest", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function () { return parallax_gateway_pb.CreateTraceRequest; }
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(exports, "CreateTraceResponse", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function () { return parallax_gateway_pb.CreateTraceResponse; }
|
|
259
|
+
});
|
|
260
|
+
Object.defineProperty(exports, "FinishSpanRequest", {
|
|
261
|
+
enumerable: true,
|
|
262
|
+
get: function () { return parallax_gateway_pb.FinishSpanRequest; }
|
|
263
|
+
});
|
|
264
|
+
Object.defineProperty(exports, "FinishSpanResponse", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get: function () { return parallax_gateway_pb.FinishSpanResponse; }
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(exports, "StartSpanRequest", {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
get: function () { return parallax_gateway_pb.StartSpanRequest; }
|
|
271
|
+
});
|
|
272
|
+
Object.defineProperty(exports, "StartSpanResponse", {
|
|
273
|
+
enumerable: true,
|
|
274
|
+
get: function () { return parallax_gateway_pb.StartSpanResponse; }
|
|
275
|
+
});
|
|
264
276
|
exports.GrpcWebRpc = GrpcWebRpc;
|
|
265
277
|
exports.ParallaxClient = ParallaxClient;
|
|
266
278
|
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../src/parallax/index.ts","../../src/grpc/index.ts"],"sourcesContent":[null,null],"names":["ParallaxGatewayServiceClient","Observable"],"mappings":";;;;;;IAiBA,MAAM,oBAAoB,GAAG,+DAA+D;IAE5F,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,KAAY,KAAI;;QAEjD,OAAO,CAAC,KAAK,CAAC,CAAA,iBAAA,EAAoB,KAAK,CAAA,QAAA,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|
2
2
|
export { GrpcWebRpc } from './src/grpc';
|
|
3
|
+
|
|
4
|
+
// Re-export proto types for convenience
|
|
5
|
+
export {
|
|
6
|
+
CreateTraceRequest,
|
|
7
|
+
CreateTraceResponse,
|
|
8
|
+
StartSpanRequest,
|
|
9
|
+
StartSpanResponse,
|
|
10
|
+
FinishSpanRequest,
|
|
11
|
+
FinishSpanResponse,
|
|
12
|
+
AddSpanEventRequest,
|
|
13
|
+
AddSpanEventResponse,
|
|
14
|
+
AddSpanErrorRequest,
|
|
15
|
+
AddSpanErrorResponse,
|
|
16
|
+
AddSpanHintRequest,
|
|
17
|
+
AddSpanHintResponse,
|
|
18
|
+
} from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miradorlabs/parallax-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Parallax Web Client Side SDK ",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"google-protobuf": "^4.0.1",
|
|
48
|
+
"grpc-web": "^2.0.2",
|
|
48
49
|
"mirador-gateway-parallax-web": "https://storage.googleapis.com/mirador-shd-packages/gateway/parallax/grpc-web/mirador-gateway-parallax-grpc-web-1.0.9.tgz",
|
|
49
50
|
"rxjs": "^7.8.2"
|
|
50
51
|
},
|
package/src/parallax/index.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
// Parallax SDK Web Client
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
3
|
CreateTraceRequest,
|
|
4
|
+
CreateTraceResponse,
|
|
4
5
|
StartSpanRequest,
|
|
6
|
+
StartSpanResponse,
|
|
5
7
|
FinishSpanRequest,
|
|
8
|
+
FinishSpanResponse,
|
|
6
9
|
AddSpanEventRequest,
|
|
10
|
+
AddSpanEventResponse,
|
|
7
11
|
AddSpanErrorRequest,
|
|
12
|
+
AddSpanErrorResponse,
|
|
8
13
|
AddSpanHintRequest,
|
|
9
|
-
|
|
10
|
-
} from "mirador-gateway-parallax-web/proto/gateway/parallax/v1/
|
|
11
|
-
import
|
|
12
|
-
import { GrpcWebRpc } from "../grpc";
|
|
14
|
+
AddSpanHintResponse,
|
|
15
|
+
} from "mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb";
|
|
16
|
+
import { ParallaxGatewayServiceClient } from "mirador-gateway-parallax-web/proto/gateway/parallax/v1/Parallax_gatewayServiceClientPb";
|
|
13
17
|
|
|
14
18
|
const GRPC_GATEWAY_API_URL = "https://gateway-parallax-dev.platform.svc.cluster.local:50053";
|
|
15
19
|
|
|
@@ -20,13 +24,18 @@ const debugIssue = (trace: string, error: Error) => {
|
|
|
20
24
|
|
|
21
25
|
class ParallaxClient {
|
|
22
26
|
public apiUrl: string = GRPC_GATEWAY_API_URL;
|
|
23
|
-
private
|
|
27
|
+
private client: ParallaxGatewayServiceClient;
|
|
24
28
|
|
|
25
29
|
constructor(public apiKey?: string, apiUrl?: string) {
|
|
26
30
|
if (apiUrl) {
|
|
27
31
|
this.apiUrl = apiUrl;
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
|
|
34
|
+
// Create credentials object with API key if provided
|
|
35
|
+
const credentials = apiKey ? { 'x-api-key': apiKey } : undefined;
|
|
36
|
+
|
|
37
|
+
// Initialize the gRPC-Web client
|
|
38
|
+
this.client = new ParallaxGatewayServiceClient(this.apiUrl, credentials);
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
/**
|
|
@@ -34,12 +43,9 @@ class ParallaxClient {
|
|
|
34
43
|
* @param params Parameters to create a new trace
|
|
35
44
|
* @returns Response from the create trace operation
|
|
36
45
|
*/
|
|
37
|
-
async createTrace(params: CreateTraceRequest): Promise<
|
|
46
|
+
async createTrace(params: CreateTraceRequest): Promise<CreateTraceResponse> {
|
|
38
47
|
try {
|
|
39
|
-
|
|
40
|
-
this.apiGatewayRpc
|
|
41
|
-
);
|
|
42
|
-
return await apiGatewayClient.CreateTrace(params);
|
|
48
|
+
return await this.client.createTrace(params, null);
|
|
43
49
|
} catch (_error) {
|
|
44
50
|
debugIssue("createTrace", new Error('Error creating trace'));
|
|
45
51
|
throw _error;
|
|
@@ -50,12 +56,9 @@ class ParallaxClient {
|
|
|
50
56
|
* Start a new span within a trace
|
|
51
57
|
* @param params Parameters to start a new span
|
|
52
58
|
*/
|
|
53
|
-
async startSpan(params: StartSpanRequest) {
|
|
59
|
+
async startSpan(params: StartSpanRequest): Promise<StartSpanResponse> {
|
|
54
60
|
try {
|
|
55
|
-
|
|
56
|
-
this.apiGatewayRpc
|
|
57
|
-
);
|
|
58
|
-
return await apiGatewayClient.StartSpan(params);
|
|
61
|
+
return await this.client.startSpan(params, null);
|
|
59
62
|
} catch (_error) {
|
|
60
63
|
debugIssue("startSpan", new Error('Error starting span'));
|
|
61
64
|
throw _error;
|
|
@@ -66,44 +69,22 @@ class ParallaxClient {
|
|
|
66
69
|
* Finish a span within a trace
|
|
67
70
|
* @param params Parameters to finish a span
|
|
68
71
|
*/
|
|
69
|
-
async finishSpan(params: FinishSpanRequest) {
|
|
72
|
+
async finishSpan(params: FinishSpanRequest): Promise<FinishSpanResponse> {
|
|
70
73
|
try {
|
|
71
|
-
|
|
72
|
-
this.apiGatewayRpc
|
|
73
|
-
);
|
|
74
|
-
return await apiGatewayClient.FinishSpan(params);
|
|
74
|
+
return await this.client.finishSpan(params, null);
|
|
75
75
|
} catch (_error) {
|
|
76
76
|
debugIssue("finishSpan", new Error('Error finishing span'));
|
|
77
77
|
throw _error;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
/**
|
|
82
|
-
* Add attributes to a span
|
|
83
|
-
* @param params Parameters to add attributes to a span
|
|
84
|
-
*/
|
|
85
|
-
async addSpanAttributes(params: AddSpanAttributesRequest) {
|
|
86
|
-
try {
|
|
87
|
-
const apiGatewayClient = new apiGateway.ParallaxGatewayServiceClientImpl(
|
|
88
|
-
this.apiGatewayRpc
|
|
89
|
-
);
|
|
90
|
-
return await apiGatewayClient.AddSpanAttributes(params);
|
|
91
|
-
} catch (_error) {
|
|
92
|
-
debugIssue("addSpanAttributes", new Error('Error adding span attributes'));
|
|
93
|
-
throw _error;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
81
|
/**
|
|
98
82
|
* Add an event to a span
|
|
99
83
|
* @param params Parameters to add an event to a span
|
|
100
84
|
*/
|
|
101
|
-
async addSpanEvent(params: AddSpanEventRequest) {
|
|
85
|
+
async addSpanEvent(params: AddSpanEventRequest): Promise<AddSpanEventResponse> {
|
|
102
86
|
try {
|
|
103
|
-
|
|
104
|
-
this.apiGatewayRpc
|
|
105
|
-
);
|
|
106
|
-
return await apiGatewayClient.AddSpanEvent(params);
|
|
87
|
+
return await this.client.addSpanEvent(params, null);
|
|
107
88
|
} catch (_error) {
|
|
108
89
|
debugIssue("addSpanEvent", new Error('Error adding span event'));
|
|
109
90
|
throw _error;
|
|
@@ -114,12 +95,9 @@ class ParallaxClient {
|
|
|
114
95
|
* Add an error to a span
|
|
115
96
|
* @param params Parameters to add an error to a span
|
|
116
97
|
*/
|
|
117
|
-
async addSpanError(params: AddSpanErrorRequest) {
|
|
98
|
+
async addSpanError(params: AddSpanErrorRequest): Promise<AddSpanErrorResponse> {
|
|
118
99
|
try {
|
|
119
|
-
|
|
120
|
-
this.apiGatewayRpc
|
|
121
|
-
);
|
|
122
|
-
return await apiGatewayClient.AddSpanError(params);
|
|
100
|
+
return await this.client.addSpanError(params, null);
|
|
123
101
|
} catch (_error) {
|
|
124
102
|
debugIssue("addSpanError", new Error('Error adding span error'));
|
|
125
103
|
throw _error;
|
|
@@ -130,12 +108,9 @@ class ParallaxClient {
|
|
|
130
108
|
* Add a hint to a span
|
|
131
109
|
* @param params Parameters to add a hint to a span
|
|
132
110
|
*/
|
|
133
|
-
async addSpanHint(params: AddSpanHintRequest) {
|
|
111
|
+
async addSpanHint(params: AddSpanHintRequest): Promise<AddSpanHintResponse> {
|
|
134
112
|
try {
|
|
135
|
-
|
|
136
|
-
this.apiGatewayRpc
|
|
137
|
-
);
|
|
138
|
-
return await apiGatewayClient.AddSpanHint(params);
|
|
113
|
+
return await this.client.addSpanHint(params, null);
|
|
139
114
|
} catch (_error) {
|
|
140
115
|
debugIssue("addSpanHint", new Error('Error adding span hint'));
|
|
141
116
|
throw _error;
|