Unverified Commit d97ee744 authored by Hong Minhee's avatar Hong Minhee
Browse files

Instrument actor key pairs dispatcher

parent 30b888df
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -118,9 +118,10 @@ Fedify automatically instruments the following operations with OpenTelemetry
spans:

| Span name                              | [Span kind] | Description                                 |
|----------------------------------|-------------|---------------------------------------|
|----------------------------------------|-------------|---------------------------------------------|
| `{method} {template}`                  | Server      | Serves the incoming HTTP request.           |
| `activitypub.dispatch_actor`           | Server      | Dispatches the ActivityPub actor.           |
| `activitypub.dispatch_actor_key_pairs` | Server      | Dispatches the ActivityPub actor key pairs. |
| `activitypub.get_actor_handle`         | Client      | Resolves the actor handle.                  |
| `activitypub.lookup_object`            | Client      | Looks up the Activity Streams object.       |
| `activitypub.parse_object`             | Internal    | Parses the Activity Streams object.         |
+21 −2
Original line number Diff line number Diff line
@@ -1062,8 +1062,27 @@ export class FederationImpl<TContextData> implements Federation<TContextData> {
    };
    this.actorCallbacks = callbacks;
    const setters: ActorCallbackSetters<TContextData> = {
      setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>) {
        callbacks.keyPairsDispatcher = dispatcher;
      setKeyPairsDispatcher: (
        dispatcher: ActorKeyPairsDispatcher<TContextData>,
      ) => {
        callbacks.keyPairsDispatcher = (ctx, identifier) =>
          this.#getTracer().startActiveSpan(
            "activitypub.dispatch_actor_key_pairs",
            { kind: SpanKind.SERVER },
            async (span) => {
              try {
                return await dispatcher(ctx, identifier);
              } catch (e) {
                span.setStatus({
                  code: SpanStatusCode.ERROR,
                  message: String(e),
                });
                throw e;
              } finally {
                span.end();
              }
            },
          );
        return setters;
      },
      mapHandle(mapper: ActorHandleMapper<TContextData>) {