Repository navigation
[Task] Extend IAuthKitPlugin with Observability Hooks #39
Description
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.
GetTracingTagscontributes only tags, never span creation or parent context, so the plugin cannot interfere with the host's span lifecycle.ConfigureLoggingconfigures the host'sILoggingBuilder, not separate plugin pipeline ordering rules are defined by the host.- Code status: none of these hooks exist in the current
IAuthKitPluginthis task adds all of them.
Validation
- Host registers metrics returned by
GetMetricsand exposes them at runtime. - Host connects every source returned by
GetOpenTelemetrySourcesto its tracer. -
ConfigureLogging-registered filters/loggers take effect. -
GetTracingTagsvalues 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