@enkaku/client 0.18.0 → 0.18.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/lib/client.js CHANGED
@@ -1,8 +1,9 @@
1
+ import { createTracer, EnkakuAttributeKeys, EnkakuSpanNames } from '@enkaku/otel';
1
2
  import { createUnsignedToken, isSigningIdentity } from '@kokuin/token';
2
3
  import { Disposer, defer } from '@sozai/async';
3
4
  import { EventEmitter } from '@sozai/event';
4
5
  import { getLogger } from '@sozai/log';
5
- import { AttributeKeys, createTracer, injectTraceContext as otelInjectTraceContext, SpanNames, SpanStatusCode, setSpanOnContext, withActiveContext, withSpan } from '@sozai/otel';
6
+ import { AttributeKeys, injectTraceContext as otelInjectTraceContext, SpanStatusCode, setSpanOnContext, withActiveContext, withSpan } from '@sozai/otel';
6
7
  import { createRuntime } from '@sozai/runtime';
7
8
  import { createPipe, writeTo } from '@sozai/stream';
8
9
  import { RequestError } from './error.js';
@@ -165,8 +166,8 @@ export class Client extends Disposer {
165
166
  delete this.#spans[meta.rid];
166
167
  }, (error)=>{
167
168
  if (error instanceof RequestError) {
168
- span.setAttribute(AttributeKeys.ERROR_CODE, error.code);
169
- span.setAttribute(AttributeKeys.ERROR_MESSAGE, error.message);
169
+ span.setAttribute(EnkakuAttributeKeys.ERROR_CODE, error.code);
170
+ span.setAttribute(EnkakuAttributeKeys.ERROR_MESSAGE, error.message);
170
171
  }
171
172
  span.setStatus({
172
173
  code: SpanStatusCode.ERROR,
@@ -251,7 +252,7 @@ export class Client extends Disposer {
251
252
  const receiveSpan = this.#spans[msg.payload.rid];
252
253
  if (receiveSpan != null) {
253
254
  receiveSpan.addEvent('stream.message.received', {
254
- [AttributeKeys.MESSAGE_DIRECTION]: 'receive'
255
+ [EnkakuAttributeKeys.MESSAGE_DIRECTION]: 'receive'
255
256
  });
256
257
  }
257
258
  void controller.receive?.write(msg.payload.val).catch(()=>{});
@@ -347,7 +348,7 @@ export class Client extends Disposer {
347
348
  }
348
349
  async sendEvent(procedure, ...args) {
349
350
  const config = args[0] ?? {};
350
- return withSpan(this.#tracer, SpanNames.CLIENT_CALL, {
351
+ return withSpan(this.#tracer, EnkakuSpanNames.CLIENT_CALL, {
351
352
  attributes: {
352
353
  [AttributeKeys.RPC_SYSTEM]: 'enkaku',
353
354
  [AttributeKeys.RPC_PROCEDURE]: procedure,
@@ -379,7 +380,7 @@ export class Client extends Disposer {
379
380
  request(procedure, ...args) {
380
381
  const config = args[0] ?? {};
381
382
  const rid = config.id ?? this.#runtime.getRandomID();
382
- const span = this.#tracer.startSpan(SpanNames.CLIENT_CALL, {
383
+ const span = this.#tracer.startSpan(EnkakuSpanNames.CLIENT_CALL, {
383
384
  attributes: {
384
385
  [AttributeKeys.RPC_SYSTEM]: 'enkaku',
385
386
  [AttributeKeys.RPC_PROCEDURE]: procedure,
@@ -456,7 +457,7 @@ export class Client extends Disposer {
456
457
  createStream(procedure, ...args) {
457
458
  const config = args[0] ?? {};
458
459
  const rid = config.id ?? this.#runtime.getRandomID();
459
- const span = this.#tracer.startSpan(SpanNames.CLIENT_CALL, {
460
+ const span = this.#tracer.startSpan(EnkakuSpanNames.CLIENT_CALL, {
460
461
  attributes: {
461
462
  [AttributeKeys.RPC_SYSTEM]: 'enkaku',
462
463
  [AttributeKeys.RPC_PROCEDURE]: procedure,
@@ -540,7 +541,7 @@ export class Client extends Disposer {
540
541
  createChannel(procedure, ...args) {
541
542
  const config = args[0] ?? {};
542
543
  const rid = config.id ?? this.#runtime.getRandomID();
543
- const span = this.#tracer.startSpan(SpanNames.CLIENT_CALL, {
544
+ const span = this.#tracer.startSpan(EnkakuSpanNames.CLIENT_CALL, {
544
545
  attributes: {
545
546
  [AttributeKeys.RPC_SYSTEM]: 'enkaku',
546
547
  [AttributeKeys.RPC_PROCEDURE]: procedure,
@@ -622,7 +623,7 @@ export class Client extends Disposer {
622
623
  const channelSpan = this.#spans[rid];
623
624
  if (channelSpan != null) {
624
625
  channelSpan.addEvent('channel.message.sent', {
625
- [AttributeKeys.MESSAGE_DIRECTION]: 'send'
626
+ [EnkakuAttributeKeys.MESSAGE_DIRECTION]: 'send'
626
627
  });
627
628
  }
628
629
  this.#logger.trace('send value to channel {procedure} with ID {rid}: {value}', {
package/lib/error.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { ErrorReplyPayload } from '@enkaku/protocol';
2
- export { type ErrorCode, ErrorCodes } from '@enkaku/protocol';
3
2
  export type ErrorObjectType<Code extends string = string, Data extends Record<string, unknown> = Record<string, unknown>> = {
4
3
  code: Code;
5
4
  message: string;
package/lib/error.js CHANGED
@@ -1,4 +1,3 @@
1
- export { ErrorCodes } from '@enkaku/protocol';
2
1
  export class RequestError extends Error {
3
2
  static fromPayload(payload) {
4
3
  return new RequestError({
package/lib/index.d.ts CHANGED
@@ -11,5 +11,5 @@
11
11
  */
12
12
  export type { ChannelCall, ChannelDefinitionsType, ClientDefinitionsType, ClientParams, EventDefinitionsType, RequestCall, RequestDefinitionsType, StreamCall, StreamDefinitionsType, } from './client.js';
13
13
  export { Client } from './client.js';
14
- export { type ErrorCode, ErrorCodes, type ErrorObjectType, RequestError, type RequestErrorParams, } from './error.js';
14
+ export { type ErrorObjectType, RequestError, type RequestErrorParams, } from './error.js';
15
15
  export type { ClientEmitter, ClientEvents, ClientRequestStatus } from './events.js';
package/lib/index.js CHANGED
@@ -9,4 +9,4 @@
9
9
  *
10
10
  * @module client
11
11
  */ export { Client } from './client.js';
12
- export { ErrorCodes, RequestError } from './error.js';
12
+ export { RequestError } from './error.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enkaku/client",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://enkaku.dev",
6
6
  "description": "Enkaku RPC client",
@@ -26,18 +26,19 @@
26
26
  ],
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
+ "@kokuin/token": "^0.1.1",
29
30
  "@sozai/async": "^0.1.0",
30
31
  "@sozai/event": "^0.1.0",
31
32
  "@sozai/execution": "^0.1.0",
32
33
  "@sozai/log": "^0.1.0",
34
+ "@sozai/otel": "^0.2.0",
33
35
  "@sozai/runtime": "^0.1.0",
34
- "@sozai/otel": "^0.1.0",
35
36
  "@sozai/stream": "^0.1.0",
36
- "@kokuin/token": "^0.1.0"
37
+ "@enkaku/otel": "^0.18.1"
37
38
  },
38
39
  "devDependencies": {
39
- "@enkaku/protocol": "^0.18.0",
40
- "@enkaku/transport": "^0.18.0"
40
+ "@enkaku/protocol": "^0.18.1",
41
+ "@enkaku/transport": "^0.18.1"
41
42
  },
42
43
  "scripts": {
43
44
  "build:clean": "del lib",