Skip to main content
The plugin SDK provides built-in observability support through structured logging and metrics. This allows you to instrument your plugins for debugging and monitoring without managing the infrastructure yourself.

Logger

The SDK injects a logger into the context of every CRUD operation. The logger is pre-configured with plugin metadata (namespace, operation, resource type).

Getting the logger

Log levels

Use the appropriate level for your message:

Adding context with With()

Create a child logger with additional fields that persist across calls:

Configuring log level

Plugin logs are captured by the agent and follow the agent’s logging configuration. See the Logging section in the configuration reference to adjust log levels.

Metrics

The SDK also provides a MetricRegistry for recording custom metrics. These are exported via OpenTelemetry when enabled in the agent.

Getting the MetricRegistry

Available metric types

The SDK exposes four metric types from OpenTelemetry’s metric model:

Complete example

Here’s the SFTP plugin’s Create method with observability:

No-op fallback

If no logger or metrics are configured (e.g., during unit tests), LoggerFromContext and MetricsFromContext return no-op implementations that safely ignore all calls. Your code doesn’t need nil checks.
Previous: 13 - Local Testing | Next: 15 - Real-world plugins