Documentation
¶
Index ¶
- func AddTag(key, value string) error
- func Context() context.Context
- func Init(config Config, additionalAttrs ...any) errordeprecated
- func InitWithConfig(ctx context.Context, cfg config.Config) (context.Context, error)
- func IsRunning() bool
- func SetTracerProvider(ctx context.Context, tp trace.TracerProvider) error
- func Start() error
- func Stop(ctx ...context.Context) error
- func TagWrapper(ctx context.Context, key, value string, fn func(context.Context) error) error
- func WrapTracerProvider(ctx context.Context, tp trace.TracerProvider) (trace.TracerProvider, error)
- type Configdeprecated
- type ProfilingLogger
- func (p ProfilingLogger) DebugContext(ctx context.Context, msg string, args ...interface{})
- func (p ProfilingLogger) Debugf(msg string, params ...interface{})
- func (p ProfilingLogger) ErrorContext(ctx context.Context, msg string, args ...interface{})
- func (p ProfilingLogger) Errorf(msg string, params ...interface{})
- func (p ProfilingLogger) InfoContext(ctx context.Context, msg string, args ...interface{})
- func (p ProfilingLogger) Infof(msg string, params ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTag ¶ added in v1.3.0
AddTag adds a key-value pair tag to the current profiling context This is a no-op for pprof backend as it doesn't support runtime tagging
func Context ¶ added in v1.3.0
Context returns the context associated with the profiler This context is cancelled when Stop() is called
func InitWithConfig ¶ added in v1.1.0
InitWithConfig initializes profiling with the new configuration format. If ctx is nil, context.Background() is used. Returns the context used by the profiler for use throughout the application.
func IsRunning ¶ added in v1.1.0
func IsRunning() bool
IsRunning returns whether profiling is currently active
func SetTracerProvider ¶ added in v1.3.0
func SetTracerProvider(ctx context.Context, tp trace.TracerProvider) error
SetTracerProvider wraps and registers a TracerProvider globally. This is a convenience function combining WrapTracerProvider and otel.SetTracerProvider.
For Pyroscope backend, wraps the provided TracerProvider with Pyroscope integration. For other backends, registers the provider unchanged.
func Stop ¶ added in v1.1.0
Stop stops profiling gracefully If ctx is provided, it's used for shutdown operations; otherwise the global context is used
func TagWrapper ¶ added in v1.3.0
TagWrapper executes a function with additional profiling tags The tags are only applied during the execution of the function The provided context is passed to the function For pprof backend, this simply executes the function without adding tags If ctx is nil, the global profiler context is used
func WrapTracerProvider ¶ added in v1.3.0
func WrapTracerProvider(ctx context.Context, tp trace.TracerProvider) (trace.TracerProvider, error)
WrapTracerProvider wraps a standard TracerProvider with Pyroscope profiling when using the Pyroscope backend. For other backends, returns the original provider.
This function is optional and allows users to integrate with OpenTelemetry without directly importing github.com/grafana/otel-profiling-go
If profiler is not initialized, returns an error. If backend is not Pyroscope, returns the original provider unchanged.
Types ¶
type Config
deprecated
added in
v1.0.6
type Config struct {
ApplicationName string `json:"application_name" validate:"required"` // ApplicationName specifies the name of the application.
ServerAddress string `json:"server_address"` // ServerAddress specifies the address of the profiling server.
Type string `json:"type" validate:"oneof=pyroscope pprof"` // Type specifies the type of profiler.
Tags map[string]string `json:"tags"` // Tags specifies the tags to be added to the profiler.
}
Deprecated: Use config.Config instead. This legacy configuration struct is maintained for backward compatibility but new code should use the more flexible config.Config struct with the new configuration format.
type ProfilingLogger ¶
type ProfilingLogger struct{}
ProfilingLogger implements the logging interface required by profiling libraries
func (ProfilingLogger) DebugContext ¶ added in v1.1.0
func (p ProfilingLogger) DebugContext(ctx context.Context, msg string, args ...interface{})
DebugContext logs debug using the slog package with context
func (ProfilingLogger) Debugf ¶
func (p ProfilingLogger) Debugf(msg string, params ...interface{})
func (ProfilingLogger) ErrorContext ¶ added in v1.1.0
func (p ProfilingLogger) ErrorContext(ctx context.Context, msg string, args ...interface{})
ErrorContext logs error using the slog package with context
func (ProfilingLogger) Errorf ¶
func (p ProfilingLogger) Errorf(msg string, params ...interface{})
func (ProfilingLogger) InfoContext ¶ added in v1.1.0
func (p ProfilingLogger) InfoContext(ctx context.Context, msg string, args ...interface{})
InfoContext logs info using the slog package with context
func (ProfilingLogger) Infof ¶
func (p ProfilingLogger) Infof(msg string, params ...interface{})
For backward compatibility with pyroscope library, implement the original methods using context functions
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
advanced
command
|
|
|
basic
command
|
|
|
deprecated
command
|
|
|
echo_integration
command
|
|
|
otel_integration
command
|
|
|
tagging
command
|
|
|
internal
|
|