// Copyright (C) 2022 Mya Pitzeruse // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // package okit import ( "context" ) // Logger defines common operations for writing log messages. type Logger interface { // Debug adds a debug message to the event stream, if configured. Debug(msg string, tags ...Tag) // Info adds an informational message to the event stream. Info(msg string, tags ...Tag) // Warn adds a warning to the event stream. Warn(msg string, tags ...Tag) // Error adds an error to the event stream. Error(msg string, tags ...Tag) } // Emitter is used to send multidimensional events to the underlying stream. type Emitter interface { // Emit sends the named event along the underlying stream. Emit(event string, tags ...Tag) } // Observer allows metrics to be captured and emit from the system. type Observer interface { // Observe records the associated metric and value. Observe(metric string, value float64, tags ...Tag) } // DoneFunc represents a function that is called when a trace is complete. type DoneFunc func() // Tracer allows method calls to be instrumented for debugging. type Tracer interface { // Trace captures the method calling context and returns a function that can be invoked to complete the trace. Trace(ctx context.Context, tags ...Tag) (context.Context, DoneFunc) } // Span defines an internal structure for tracking traces across an application. This structure is only used for // tracking purposes and direct modifications will not be reflected. type Span struct { // TraceID specifies an identifier for the overall trace event. This value is often inherited from a parent. TraceID string // ID uniquely identifies a span within a trace. ID string // ParentID points to the id of the wrapping span. ParentID string } type Wither[T any] interface { With(tags ...Tag) T } // Interface defines an abstraction that contains all the user-facing functions. type Interface[T any] interface { Logger Emitter Observer Tracer Wither[T] }