Skip to content

[Task] Extend IAuthKitPlugin with Observability Hooks #39

Description

@rian-be

Summary

Extend IAuthKitPlugin with four additive observability hooks so plugins can contribute their own signal surface to the host: declared metrics (GetMetrics), OpenTelemetry sources (GetOpenTelemetrySources), logging configuration (ConfigureLogging), and tracing tags (GetTracingTags). All hooks are additive default interface implementations, so existing plugins compile and behave unchanged.

Goal

Let plugins participate in the host wide observability pipeline metrics, tracing, and logging without owning sinks, samplers, or pipelines. The host wires the sinks the plugin only declares what it emits.

Background

Today IAuthKitPlugin has no observability surface. Plugins emit traces, metrics, or custom loggers ad hoc via DI-registered services, so the host cannot discover which sources to connect or which tags to attach to its spans, and plugin log output does not flow through a coherent logging configuration. The contract gives the host the declarative signal surface it needs without dictating a vendor.

Fields

ID Member Type Notes
H1 GetMetrics() IEnumerable<MetricDefinition> Metric descriptors (name, description, unit); host registers them.
H2 GetOpenTelemetrySources() IEnumerable<string> OpenTelemetry source/tracer names the host connects to its pipeline.
H3 ConfigureLogging void ConfigureLogging(ILoggingBuilder) Plugin registers filters/loggers on the host's logging builder.
H4 GetTracingTags() IReadOnlyDictionary<string,string> Plugin-provided tags attached to host activity spans.

Proposed Contract

public interface IAuthKitPlugin
{
    IEnumerable<MetricDefinition> GetMetrics() => [];
    IEnumerable<string> GetOpenTelemetrySources() => [];
    void ConfigureLogging(ILoggingBuilder builder) { }
    IReadOnlyDictionary<string, string> GetTracingTags() => new Dictionary<string, string>();
}

MetricDefinition is new immutable record (name, optional description/unit) living in AuthKit.Plugins.Abstractions (MetricDefinition).

Decisions

  • Host owns the sinks and tracer. The contract only declares what the plugin emits source name never implies a vendor or a bootstrap mechanism. No OpenTelemetry SDK dependency is mandated on the contract itself.
  • GetTracingTags contributes only tags, never span creation or parent context, so the plugin cannot interfere with the host's span lifecycle.
  • ConfigureLogging configures the host's ILoggingBuilder, not separate plugin pipeline ordering rules are defined by the host.
  • Code status: none of these hooks exist in the current IAuthKitPlugin this task adds all of them.

Validation

  • Host registers metrics returned by GetMetrics and exposes them at runtime.
  • Host connects every source returned by GetOpenTelemetrySources to its tracer.
  • ConfigureLogging-registered filters/loggers take effect.
  • GetTracingTags values are attached to host spans.
  • Existing plugins that do not implement the hooks still compile and load.

Acceptance Criteria

  • Plugins declare metrics, OpenTelemetry sources, logging configuration, and tracing tags through the contract.
  • The host wires the declared signals without plugin owned sinks or samplers.
  • Default implementations keep existing plugins source compatible.
  • No metric backend or vendor is chosen by the contract.

Non Goals

  • No metric backend selection by the contract; the host wires the sink.
  • No OpenTelemetry SDK dependency on the contract.
  • No separate plugin log pipeline.
  • No span creation by the plugin only tag contribution.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Core operationadditiveAdditive, non-breaking changearea/abstractionsAuthKit.Plugins.Abstractions contractcontractChanges the plugin contractsub-taskChild task of an epic

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions