otlpaudit

package
v1.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 1

README

OpenTelemetry Event Library

Go library for creating and sending audit log events to OpenTelemetry collector using HTTP requests.

Dependencies

  • go 1.23 or higher
  • Working OpenTelemetry collector instance with a HTTP receiver

How to use

Configuration

Configuration is being read from config.yaml file. The consumers should use LoadConfig function provided within common package to load and unmarshal configuration into a struct to be used by consumers. The section related to this library in consumer's config should look like this:

audit:
  endpoint: "<YOUR_ENDPOINT>"
  # potential auth config

The library allows two ways of authenticating against the target endpoint: mTLS and Basic Auth. If needed, they should be configured within the config.yaml. Please note that only one authenticating method can be implemented at a time. If both are provided, mTLS is prioritized. Example config snippets:

  basicAuth:
    username:
      source: file
      file:
        path: <JSON_FILE>
        format: json
        jsonPath: "$.<KEY_FOR_USERNAME_IN_JSONFILE>"
    password:
      source: file
      file:
        path: <JSON_FILE>
        format: json
        jsonPath: "$.<KEY_FOR_PASSWORD_IN_JSONFILE>"
   mtls:
    cert:
      source: file
      file:
        path: <JSON_FILE>
        format: json
        jsonPath: "$.<KEY_FOR_CERT_IN_JSONFILE>"
    certKey:
      source: file
      file:
        path: <JSON_FILE>
        format: json
        jsonPath: "$.<KEY_FOR_KEY_IN_JSONFILE>"
    serverCa:
      source: file
      file:
        path: <JSON_FILE>
        format: json
        jsonPath: "$.<KEY_FOR_SERVERCA_IN_JSONFILE>"

All of the secrets for Basic Auth and mTLS are defined as SourceRef - see common package for more info.

Event creation and sending

To use the library, consuming service must first instantiate a new audit logger using the config data, create event object and call the sending function to dispatch event.

Creating events

To create the event use one of provided New<EVENT_TYPE>Event(eventMetadata EventMetadata, args ...) (plog.Logs, error) functions. For each type it expects a EventMetadata object - it contains fields shared across each event type. To create one, use NewEventMetadata(userInitiatorID, tenantID, eventCorrelationID string) (userInitiatorID and tenantID are mandatory).

Sending events

Created event should be passed to SendEvent function that takes care of dispatching the event to collector defined in the config.

Full set of calls on the consumer side would look like for example like this:

auditLogger, _ := otlpaudit.NewLogger(&cfg.Audit)
eventMetadata, _ := otlpaudit.NewEventMetadata("userInitID", "tenantID", "eventCorrelationID")
event, _ := otlpaudit.NewCmkCreateEvent(eventMetadata, "cmkID")
auditLogger.SendEvent(ctx, event) 
Non-blocking / queued delivery

SendEvent above blocks the caller until the HTTP request to the collector completes and returns an error if the collector is unavailable. When a service should emit audit events fire-and-forget and let the SDK handle eventual delivery, wrap the logger in a QueuedAuditLogger via NewQueuedLogger. It buffers events in an in-memory queue and delivers them from background workers, retrying transient failures with exponential backoff.

auditLogger, _ := otlpaudit.NewLogger(&cfg.Audit)
queued := otlpaudit.NewQueuedLogger(auditLogger, otlpaudit.QueuedOptions{
    OnError: func(err error) { slog.Error("audit delivery failed", "error", err) },
})
defer queued.Close(ctx) // drains the queue on shutdown

event, _ := otlpaudit.NewCmkCreateEvent(eventMetadata, "cmkID")
if err := queued.SendEvent(event); err != nil {
    // queue is full (otlpaudit errQueueFull) or the logger is closed
}

QueuedAuditLogger.SendEvent never blocks and takes no context — delivery (and its context) is owned by the background workers. It returns an error only when the event could not be enqueued: the queue is full, or the logger has been closed. Behavior is configured via QueuedOptions (all fields optional):

Field Default Description
QueueSize 1024 Capacity of the buffered queue. When full, SendEvent drops and errors.
Workers 1 Number of background delivery goroutines.
MaxRetries 5 Retry attempts after the first failure before the event is dropped.
BaseDelay 100ms First exponential-backoff step (doubles each retry, with jitter).
MaxDelay 30s Upper bound on the backoff step.
OnError nil Receives errors for events dropped after exhausting all retries.

Events dropped because the queue was full are reported to the caller via the SendEvent return value; events dropped after exhausting all retries are routed to OnError. Always call Close(ctx) on shutdown to drain buffered events; if ctx expires before the queue is drained, in-flight sends are aborted and the context's error is returned.

Additional Properties

There is also a functionality of additional properties introduced that allow to add properties to OTLP logs separate from those belonging to specific event types. Please keep in mind that they'll be propagated to every event. The additional properties are loaded via config as a literal:

additionalProperties: |
    property1: x
    property2: y

Event catalog

Event type Function signature
keyCreate NewKeyCreateEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType)
keyDelete NewKeyDeleteEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType)
keyRestore NewKeyRestoreEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType)
keyPurge NewKeyPurgeEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType)
keyRotate NewKeyRotateEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType)
keyEnable NewKeyEnableEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType)
keyDisable NewKeyDisableEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType)
workflowStart NewWorkflowStartEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool)
workflowUpdate NewWorkflowUpdateEvent(metadata EventMetadata, objectID string, oldValue, newValue any, dpp bool)
workflowExecute NewWorkflowExecuteEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool)
workflowTerminate NewWorkflowTerminateEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool)
groupCreate NewGroupCreateEvent(metadata EventMetadata, objectID string, value any, dpp bool)
groupRead NewGroupReadEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool)
groupDelete NewGroupDeleteEvent(metadata EventMetadata, objectID string, value any, dpp bool)
groupUpdate NewGroupUpdateEvent(metadata EventMetadata, objectID, propertyName string, oldValue, newValue any, dpp bool)
userLoginSuccess NewUserLoginSuccessEvent(metadata EventMetadata, objectID string, l LoginMethod, t MfaType, u UserType, value any)
userLoginFailure NewUserLoginFailureEvent(metadata EventMetadata, objectID string, l LoginMethod, f FailReason, value any)
tenantOnboarding NewTenantOnboardingEvent(metadata EventMetadata, tenantID string)
tenantOffboarding NewTenantOffboardingEvent(metadata EventMetadata, tenantID string)
tenantUpdate NewTenantUpdateEvent(metadata EventMetadata, objectID, propertyName string, t TenantUpdateActionType, oldValue, newValue any)
configurationCreate NewConfigurationCreateEvent(metadata EventMetadata, objectID string, value any)
configurationRead NewConfigurationUpdateEvent(metadata EventMetadata, objectID string, oldValue, newValue any) `
configurationDelete NewConfigurationDeleteEvent(metadata EventMetadata, objectID string, value any)
configurationUpdate NewConfigurationReadEvent(metadata EventMetadata, objectID, channelType, channelID string, value any)
credentialCreate NewCredentialCreateEvent(metadata EventMetadata, credentialID string, c CredentialType)
credentialExpiration NewCredentialExpirationEvent(metadata EventMetadata, credentialID string, c CredentialType)
credentialDelete NewCredentialDeleteEvent(metadata EventMetadata, credentialID string, c CredentialType)
credentialRevokation NewCredentialRevokationEvent(metadata EventMetadata, credentialID string, c CredentialType)
cmkOnboarding NewCmkOnboardingEvent(metadata EventMetadata, cmkID, systemID string)
cmkOffboarding NewCmkOffboardingEvent(metadata EventMetadata, cmkID, systemID string)
cmkSwitch NewCmkSwitchEvent(metadata EventMetadata, cmkID, cmkIDOld, cmkIDNew string)
cmkTenantModification NewCmkTenantModificationEvent(metadata EventMetadata, cmkID, systemID string, c CmkAction)
cmkTenantDelete NewCmkTenantDeleteEvent(metadata EventMetadata, cmkID string)
cmkCreate NewCmkCreateEvent(metadata EventMetadata, cmkID string)
cmkDelete NewCmkDeleteEvent(metadata EventMetadata, cmkID string)
cmkDetach NewCmkDetachEvent(metadata EventMetadata, cmkID string, systemID string)
cmkRestore NewCmkRestoreEvent(metadata EventMetadata, cmkID string)
cmkEnable NewCmkEnableEvent(metadata EventMetadata, cmkID string)
cmkDisable NewCmkDisableEvent(metadata EventMetadata, cmkID string)
cmkRotate NewCmkRotateEvent(metadata EventMetadata, cmkID string)
cmkAvailable NewCmkAvailableEvent(metadata EventMetadata, cmkID string)
cmkUnavailable NewCmkUnavailableEvent(metadata EventMetadata, cmkID string)
unauthenticatedRequest NewUnauthenticatedRequestEvent(metadata EventMetadata)
unauthorizedRequest NewUnauthorizedRequestEvent(metadata EventMetadata, resource string, action string)
accessGranted NewAccessGrantedEvent(metadata EventMetadata, resource, action string, value any)

All the enums in the functions above are provided within this library. For every enum values can be empty (it will be set to UNSPECIFIED), but if they are provided they must match the enums defined in this library, otherwise there will be an error. All *value properties are optional with the exception of ones present in event types: tenantUpdate, configurationCreate, configurationRead, configurationDelete and configurationUpdate. All other properties are considered required.

Documentation

Index

Constants

View Source
const (
	ConfigCreateEvent           = "configurationCreate"
	ConfigReadEvent             = "configurationRead"
	ConfigUpdateEvent           = "configurationUpdate"
	ConfigDeleteEvent           = "configurationDelete"
	GroupCreateEvent            = "groupCreate"
	GroupReadEvent              = "groupRead"
	GroupUpdateEvent            = "groupUpdate"
	GroupDeleteEvent            = "groupDelete"
	KeyCreateEvent              = "keyCreate"
	KeyDeleteEvent              = "keyDelete"
	KeyRestoreEvent             = "keyRestore"
	KeyPurgeEvent               = "keyPurge"
	KeyRotateEvent              = "keyRotate"
	KeyEnableEvent              = "keyEnable"
	KeyDisableEvent             = "keyDisable"
	WorkflowStartEvent          = "workflowStart"
	WorkflowUpdateEvent         = "workflowUpdate"
	WorkflowExecuteEvent        = "workflowExecute"
	WorkflowTerminateEvent      = "workflowTerminate"
	UserLoginSuccessEvent       = "userLoginSuccess"
	UserLoginFailureEvent       = "userLoginFailure"
	TenantOnboardingEvent       = "tenantOnboarding"
	TenantOffboardingEvent      = "tenantOffboarding"
	TenantUpdateEvent           = "tenantUpdate"
	CredentialExpirationEvent   = "credentialExpiration"
	CredentialCreateEvent       = "credentialCreate"
	CredentialRevokationEvent   = "credentialRevokation"
	CredentialDeleteEvent       = "credentialDelete"
	CmkOnboardingEvent          = "cmkOnboarding"
	CmkOffboardingEvent         = "cmkOffboarding"
	CmkSwitchEvent              = "cmkSwitch"
	CmkTenantModificationEvent  = "cmkTenantModification"
	CmkTenantDeleteEvent        = "cmkTenantDelete"
	CmkCreateEvent              = "cmkCreate"
	CmkDeleteEvent              = "cmkDelete"
	CmkDetachEvent              = "cmkDetach"
	CmkRestoreEvent             = "cmkRestore"
	CmkEnableEvent              = "cmkEnable"
	CmkDisableEvent             = "cmkDisable"
	CmkRotateEvent              = "cmkRotate"
	CmkAvailableEvent           = "cmkAvailable"
	CmkUnavailableEvent         = "cmkUnavailable"
	UnauthorizedRequestEvent    = "unauthorizedRequest"
	AccessGrantedEvent          = "accessGranted"
	UnauthenticatedRequestEvent = "unauthenticatedRequest"
)
View Source
const (
	EventTypeKey          = "eventType"
	ObjectIDKey           = "objectID"
	ObjectTypeKey         = "objectType"
	ActionTypeKey         = "actionType"
	ChannelTypeKey        = "channelType"
	ChannelIDKey          = "channelID"
	LoginMethodKey        = "loginMethod"
	MfaTypeKey            = "mfaType"
	UserTypeKey           = "userType"
	FailureReasonKey      = "failureReason"
	CredentialTypeKey     = "credentialType"
	ValueKey              = "value"
	PropertyNameKey       = "propertyName"
	OldValueKey           = "oldValue"
	NewValueKey           = "newValue"
	DppKey                = "dpp"
	UserInitiatorIDKey    = "userInitiatorID"
	TenantIDKey           = "tenantID"
	EventCorrelationIDKey = "eventCorrelationID"
	SystemIDKey           = "systemID"
	CmkIDKey              = "cmkID"
	CmkIDOldKey           = "cmkIDOld"
	CmkIDNewKey           = "cmkIDNew"
	ResourceKey           = "resource"
	ActionKey             = "action"
)
View Source
const UNSPECIFIED = "UNSPECIFIED"

Variables

This section is empty.

Functions

func NewAccessGrantedEvent added in v1.20.0

func NewAccessGrantedEvent(metadata EventMetadata, resource, action string, value any) (plog.Logs, error)

func NewCmkAvailableEvent added in v1.5.0

func NewCmkAvailableEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkCreateEvent added in v0.2.2

func NewCmkCreateEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkDeleteEvent added in v0.3.0

func NewCmkDeleteEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkDetachEvent added in v1.7.0

func NewCmkDetachEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkDisableEvent added in v0.2.2

func NewCmkDisableEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkEnableEvent added in v0.2.2

func NewCmkEnableEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkOffboardingEvent added in v0.2.2

func NewCmkOffboardingEvent(metadata EventMetadata, cmkID, systemID string) (plog.Logs, error)

func NewCmkOnboardingEvent added in v0.2.2

func NewCmkOnboardingEvent(metadata EventMetadata, cmkID, systemID string) (plog.Logs, error)

func NewCmkRestoreEvent added in v0.2.2

func NewCmkRestoreEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkRotateEvent added in v0.2.2

func NewCmkRotateEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkSwitchEvent added in v0.2.2

func NewCmkSwitchEvent(metadata EventMetadata, systemID, cmkIDOld, cmkIDNew string) (plog.Logs, error)

func NewCmkTenantDeleteEvent added in v1.7.0

func NewCmkTenantDeleteEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewCmkTenantModificationEvent added in v0.2.2

func NewCmkTenantModificationEvent(metadata EventMetadata, cmkID, systemID string, c CmkAction) (plog.Logs, error)

func NewCmkUnavailableEvent added in v1.5.0

func NewCmkUnavailableEvent(metadata EventMetadata, cmkID string) (plog.Logs, error)

func NewConfigurationCreateEvent

func NewConfigurationCreateEvent(metadata EventMetadata, objectID string, value any) (plog.Logs, error)

func NewConfigurationDeleteEvent

func NewConfigurationDeleteEvent(metadata EventMetadata, objectID string, value any) (plog.Logs, error)

func NewConfigurationReadEvent

func NewConfigurationReadEvent(metadata EventMetadata, objectID, channelType, channelID string, value any) (plog.Logs, error)

func NewConfigurationUpdateEvent

func NewConfigurationUpdateEvent(metadata EventMetadata, objectID string, oldValue, newValue any) (plog.Logs, error)

func NewCredentialCreateEvent

func NewCredentialCreateEvent(metadata EventMetadata, credentialID string, c CredentialType) (plog.Logs, error)

func NewCredentialDeleteEvent

func NewCredentialDeleteEvent(metadata EventMetadata, credentialID string, c CredentialType) (plog.Logs, error)

func NewCredentialExpirationEvent

func NewCredentialExpirationEvent(metadata EventMetadata, credentialID string, c CredentialType) (plog.Logs, error)

func NewCredentialRevokationEvent

func NewCredentialRevokationEvent(metadata EventMetadata, credentialID string, c CredentialType) (plog.Logs, error)

func NewGroupCreateEvent

func NewGroupCreateEvent(metadata EventMetadata, objectID string, value any, dpp bool) (plog.Logs, error)

func NewGroupDeleteEvent

func NewGroupDeleteEvent(metadata EventMetadata, objectID string, value any, dpp bool) (plog.Logs, error)

func NewGroupReadEvent

func NewGroupReadEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool) (plog.Logs, error)

func NewGroupUpdateEvent

func NewGroupUpdateEvent(metadata EventMetadata, objectID, propertyName string, oldValue, newValue any, dpp bool) (plog.Logs, error)

func NewKeyCreateEvent

func NewKeyCreateEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType) (plog.Logs, error)

func NewKeyDeleteEvent

func NewKeyDeleteEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType) (plog.Logs, error)

func NewKeyDisableEvent added in v0.2.2

func NewKeyDisableEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType) (plog.Logs, error)

func NewKeyEnableEvent added in v0.2.2

func NewKeyEnableEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType) (plog.Logs, error)

func NewKeyPurgeEvent added in v0.2.2

func NewKeyPurgeEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType) (plog.Logs, error)

func NewKeyRestoreEvent added in v0.2.2

func NewKeyRestoreEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType) (plog.Logs, error)

func NewKeyRotateEvent added in v0.2.2

func NewKeyRotateEvent(metadata EventMetadata, objectID, systemID, cmkID string, t KeyType) (plog.Logs, error)

func NewTenantOffboardingEvent

func NewTenantOffboardingEvent(metadata EventMetadata, tenantID string) (plog.Logs, error)

func NewTenantOnboardingEvent

func NewTenantOnboardingEvent(metadata EventMetadata, tenantID string) (plog.Logs, error)

func NewTenantUpdateEvent

func NewTenantUpdateEvent(metadata EventMetadata, objectID, propertyName string, oldValue, newValue any) (plog.Logs, error)

func NewUnauthenticatedRequestEvent added in v0.5.0

func NewUnauthenticatedRequestEvent(metadata EventMetadata) (plog.Logs, error)

func NewUnauthorizedRequestEvent added in v0.5.0

func NewUnauthorizedRequestEvent(metadata EventMetadata, resource, action string) (plog.Logs, error)

func NewUserLoginFailureEvent

func NewUserLoginFailureEvent(metadata EventMetadata, objectID string, l LoginMethod, f FailReason, value any) (plog.Logs, error)

func NewUserLoginSuccessEvent

func NewUserLoginSuccessEvent(metadata EventMetadata, objectID string, l LoginMethod, t MfaType, u UserType, value any) (plog.Logs, error)

func NewWorkflowExecuteEvent

func NewWorkflowExecuteEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool) (plog.Logs, error)

func NewWorkflowStartEvent

func NewWorkflowStartEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool) (plog.Logs, error)

func NewWorkflowTerminateEvent

func NewWorkflowTerminateEvent(metadata EventMetadata, objectID, channelID, channelType string, value any, dpp bool) (plog.Logs, error)

func NewWorkflowUpdateEvent

func NewWorkflowUpdateEvent(metadata EventMetadata, objectID string, oldValue, newValue any, dpp bool) (plog.Logs, error)

Types

type AuditLogger added in v0.2.2

type AuditLogger struct {
	// contains filtered or unexported fields
}

func NewLogger added in v0.2.2

func NewLogger(config *commoncfg.Audit) (*AuditLogger, error)

func (*AuditLogger) SendEvent added in v0.2.2

func (auditLogger *AuditLogger) SendEvent(ctx context.Context, logs plog.Logs) error

type CmkAction added in v0.2.2

type CmkAction string
const (
	CMKACTION_ONBOARD      CmkAction = "ONBOARD"
	CMKACTION_BLOCK        CmkAction = "BLOCK"
	CMKACTION_SHUTDOWN     CmkAction = "SHUTDOWN"
	CMKACTION_CSEKFALLBACK CmkAction = "CSEKFALLBACK"
	CMKACTION_RESTORE      CmkAction = "RESTORE"
)

func (CmkAction) IsValid added in v0.2.2

func (c CmkAction) IsValid() bool

type CredentialType

type CredentialType string
const (
	CREDTYPE_X509CERT CredentialType = "X509_CERTIFICATE"
	CREDTYPE_KEY      CredentialType = "KEY"
	CREDTYPE_SECRET   CredentialType = "SECRET"
)

func (CredentialType) IsValid

func (c CredentialType) IsValid() bool

type EventMetadata

type EventMetadata map[string]string

func NewEventMetadata

func NewEventMetadata(userInitiatorID, tenantID, eventCorrelationID string) (EventMetadata, error)

type FailReason

type FailReason string
const (
	FAILREASON_PASSWORD        FailReason = "PASSWORD"
	FAILREASON_MFAFAIL         FailReason = "MFA_FAILED"
	FAILREASON_USERNOTFOUND    FailReason = "USER_NOT_FOUND"
	FAILREASON_USERLOCKED      FailReason = "USER_LOCKED"
	FAILREASON_USERBLOCKED     FailReason = "USER_BLOCKED"
	FAILREASON_USERUNVERIFIED  FailReason = "USER_UNVERIFIED"
	FAILREASON_USEREXPIRED     FailReason = "USER_EXPIRED"
	FAILREASON_USERINVALID     FailReason = "USER_INVALID"
	FAILREASON_INSECURECONNECT FailReason = "INSECURE_CONNECTION"
	FAILREASON_METHODDISABLED  FailReason = "LOGIN_METHOD_DISABLED"
	FAILREASON_TOKENEXPIRED    FailReason = "TOKEN_EXPIRED"
	FAILREASON_TOKENREVOKED    FailReason = "TOKEN_REVOKED"
	FAILREASON_TOKENINVALID    FailReason = "TOKEN_INVALID"
	FAILREASON_SESSIONEXPIRED  FailReason = "SESSION_EXPIRED"
	FAILREASON_SESSIONREVOKED  FailReason = "SESSION_REVOKED"
	FAILREASON_CERTEXPIRED     FailReason = "CERTIFICATE_EXPIRED"
	FAILREASON_CERTREVOKED     FailReason = "CERTIFICATE_REVOKED"
	FAILREASON_CERTINVALID     FailReason = "CERTIFICATE_INVALID"
)

func (FailReason) IsValid

func (r FailReason) IsValid() bool

type KeyCreateActionType

type KeyCreateActionType string

type KeyReadActionType

type KeyReadActionType string

type KeyType added in v0.2.2

type KeyType string
const (
	KEYTYPE_SYSTEM  KeyType = "SYSTEM"
	KEYTYPE_SERVICE KeyType = "SERVICE"
	KEYTYPE_DATA    KeyType = "DATA"
	KEYTYPE_KEK     KeyType = "KEK"
)

func (KeyType) IsValid added in v0.2.2

func (l KeyType) IsValid() bool

type KeyUpdateActionType

type KeyUpdateActionType string

type LoginMethod

type LoginMethod string
const (
	LOGINMETHOD_OPENIDCONNECT LoginMethod = "OPEN_ID_CONNECT"
	LOGINMETHOD_X509CERT      LoginMethod = "X509_CERTIFICATE"
)

func (LoginMethod) IsValid

func (l LoginMethod) IsValid() bool

type MfaType

type MfaType string
const (
	MFATYPE_WEBAUTHN MfaType = "WEB_AUTHN"
	MFATYPE_NONE     MfaType = "NONE"
)

func (MfaType) IsValid

func (l MfaType) IsValid() bool

type QueuedAuditLogger added in v1.21.0

type QueuedAuditLogger struct {
	// contains filtered or unexported fields
}

QueuedAuditLogger wraps an AuditLogger with a non-blocking, channel-based queue and background delivery. It is safe for concurrent use by multiple goroutines. Create one with NewQueuedLogger and always Close it to drain buffered events.

func NewQueuedLogger added in v1.21.0

func NewQueuedLogger(sink *AuditLogger, opts QueuedOptions) *QueuedAuditLogger

NewQueuedLogger returns a QueuedAuditLogger delivering events to sink. It starts the configured number of background workers immediately.

func (*QueuedAuditLogger) Close added in v1.21.0

func (q *QueuedAuditLogger) Close(ctx context.Context) error

Close stops accepting new events, drains events already queued (with retries), and waits for the background workers to finish. It is idempotent. If ctx is cancelled before the queue is drained, in-flight sends and pending backoffs are aborted and ctx's error is returned; otherwise it returns nil.

func (*QueuedAuditLogger) SendEvent added in v1.21.0

func (q *QueuedAuditLogger) SendEvent(logs plog.Logs) error

SendEvent enqueues logs for background delivery and returns immediately. It never blocks: if the queue is full the event is dropped and errQueueFull is returned. After Close it returns errLoggerClosed.

type QueuedOptions added in v1.21.0

type QueuedOptions struct {
	// QueueSize is the capacity of the buffered event queue. SendEvent drops
	// events (returning errQueueFull) once the queue is full. Defaults to 1024.
	QueueSize int

	// Workers is the number of background goroutines delivering events to the
	// underlying logger. Defaults to 1.
	Workers int

	// MaxRetries is the number of additional delivery attempts after the first
	// one fails. Each retry is spaced by an exponential backoff. Once exhausted
	// the event is reported to OnError and dropped. Values <= 0 default to 5.
	MaxRetries int

	// BaseDelay is the first backoff step. Subsequent steps double it up to
	// MaxDelay. Defaults to 100ms.
	BaseDelay time.Duration

	// MaxDelay caps the backoff step. Defaults to 30s.
	MaxDelay time.Duration

	// OnError receives errors from background delivery, which cannot be returned
	// to a caller: events dropped because the queue was full are not routed here
	// (SendEvent returns errQueueFull directly), but events dropped after
	// exhausting all retries are. When nil such errors are dropped silently;
	// supply a handler (e.g. logging) to observe them.
	OnError func(error)
}

QueuedOptions configures a QueuedAuditLogger. The zero value is valid and uses the defaults documented on each field.

type TenantUpdateActionType

type TenantUpdateActionType string
const (
	TENANTUPDATE_TESTMODE        TenantUpdateActionType = "TEST_MODE"
	TENANTUPDATE_WORKFLOWENABLE  TenantUpdateActionType = "WORKFLOW_ENABLE"
	TENANTUPDATE_WORKFLOWDISABLE TenantUpdateActionType = "WORKFLOW_DISABLE"
)

func (TenantUpdateActionType) IsValid

func (t TenantUpdateActionType) IsValid() bool

type UserLoginFailureActionType

type UserLoginFailureActionType string

type UserType

type UserType string
const (
	USERTYPE_BUSINESS  UserType = "BUSINESS_USER"
	USERTYPE_TECHNICAL UserType = "TECHNICAL_USER"
)

func (UserType) IsValid

func (u UserType) IsValid() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL