Documentation
¶
Index ¶
- Constants
- func InjectField[T any](ctx context.Context, key string, value T) context.Context
- func InjectFields(ctx context.Context, tags map[string]string) context.Context
- func NewContext(ctx context.Context) context.Context
- func NotifyErrorToInstrumentation(ctx context.Context, err error)
- func SetInContext(ctx context.Context, m *Monitor) context.Context
- type Config
- type ExternalServiceInfo
- type MockstackTracer
- type MockstackTracer_Expecter
- type MockstackTracer_StackTrace_Call
- func (_c *MockstackTracer_StackTrace_Call) Return(_a0 errors.StackTrace) *MockstackTracer_StackTrace_Call
- func (_c *MockstackTracer_StackTrace_Call) Run(run func()) *MockstackTracer_StackTrace_Call
- func (_c *MockstackTracer_StackTrace_Call) RunAndReturn(run func() errors.StackTrace) *MockstackTracer_StackTrace_Call
- type Monitor
- func (m *Monitor) Errorf(err error, msg string, args ...interface{})
- func (m *Monitor) Flush(maxWait time.Duration)
- func (m *Monitor) Infof(format string, args ...interface{})
- func (m *Monitor) ReportError(err error, tags map[string]string)
- func (m *Monitor) With(tags map[string]string) *Monitor
- func (m *Monitor) WithTag(key string, value string) *Monitor
Constants ¶
const DefaultFlushWait = 10 * time.Second // 10 sec (this flush) + 10 sec for server shutdown grace = 20 sec which is reasonable considering k8s grace is 30sec
DefaultFlushWait represents the default wait time for flushing
Variables ¶
This section is empty.
Functions ¶
func InjectField ¶
InjectField injects a field to Logger and trace.Span in context
func NewContext ¶
NewContext copies the logger from old to a new context Use this when you want to use a new context but copy the logger over from the original context
Types ¶
type Config ¶
type Config struct { ServerName string Environment string Version string Writer io.Writer // Support write log to buffer for testing SentryDSN string // To capture error, skip init Sentry if it's not provided OtelExporterURL string // To support OpenTelemetry ExtraTags map[string]string }
Config holds Monitor configuration
type ExternalServiceInfo ¶
ExternalServiceInfo holds the ext svc info
func NewExternalServiceInfo ¶
func NewExternalServiceInfo(rawURL string) ExternalServiceInfo
NewExternalServiceInfo creates a new ExternalServiceInfo from the given url
type MockstackTracer ¶
MockstackTracer is an autogenerated mock type for the stackTracer type
func NewMockstackTracer ¶
func NewMockstackTracer(t interface { mock.TestingT Cleanup(func()) }) *MockstackTracer
NewMockstackTracer creates a new instance of MockstackTracer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockstackTracer) EXPECT ¶
func (_m *MockstackTracer) EXPECT() *MockstackTracer_Expecter
func (*MockstackTracer) StackTrace ¶
func (_m *MockstackTracer) StackTrace() errors.StackTrace
StackTrace provides a mock function with no fields
type MockstackTracer_Expecter ¶
type MockstackTracer_Expecter struct {
// contains filtered or unexported fields
}
func (*MockstackTracer_Expecter) StackTrace ¶
func (_e *MockstackTracer_Expecter) StackTrace() *MockstackTracer_StackTrace_Call
StackTrace is a helper method to define mock.On call
type MockstackTracer_StackTrace_Call ¶
MockstackTracer_StackTrace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StackTrace'
func (*MockstackTracer_StackTrace_Call) Return ¶
func (_c *MockstackTracer_StackTrace_Call) Return(_a0 errors.StackTrace) *MockstackTracer_StackTrace_Call
func (*MockstackTracer_StackTrace_Call) Run ¶
func (_c *MockstackTracer_StackTrace_Call) Run(run func()) *MockstackTracer_StackTrace_Call
func (*MockstackTracer_StackTrace_Call) RunAndReturn ¶
func (_c *MockstackTracer_StackTrace_Call) RunAndReturn(run func() errors.StackTrace) *MockstackTracer_StackTrace_Call
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor represents instance for logging and capture error
func FromContext ¶
FromContext gets the logger from context
func InjectOutgoingTracingInfo ¶
func InjectOutgoingTracingInfo(m *Monitor, spanCtx trace.SpanContext) *Monitor
func InjectTracingInfo ¶
func InjectTracingInfo(m *Monitor, spanCtx trace.SpanContext) *Monitor
func (*Monitor) Flush ¶
Flush will flush all the monitor data left in the queue to the monitoring service