profile

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright 2022 The CubeFS Authors. application memory data controller and metric exporter in localhost.

With tag `noprofile` to avoid generating scripts.

Note:

  1. You can register http handler to profile multiplexer to control.
  2. You may use environment to set variables, like `bind_addr`, `metric_exporter_labels`.
  3. You cannot access the localhost service before profile initialized.

Example:

package main

import (

    "net/http"

    // 1. you can using default handler in profile defined
    // 2. you can register handler to profile in other module
    "github.com/cubefs/cubefs/blobstore/common/profile"
	   "github.com/cubefs/cubefs/blobstore/common/rpc"

)

func registerHandler() {
    profile.HandleFunc("GET","/myself/controller", func(ctx *rpc.Context) {
        // todo something
    }, rpc.ServerOption...)
}
func main() {
 	ph := profile.NewProfileHandler("127.0.0.1:8888")
		httpServer := &http.Server{
			Addr:    "127.0.0.1:8888",
			Handler: rpc.MiddlewareHandlerWith(rpc.DefaultRouter, ph),
		}
		log.Info("Server is running at", "127.0.0.1:8888")
		go func() {
			err = httpServer.ListenAndServe()
			require.NoError(t, err)
		}()
     registerHandler()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleFunc

func HandleFunc(method, pattern string, handler rpc.HandlerFunc, opts ...rpc.ServerOption)

HandleFunc register handler func to profile serve multiplexer.

func NewProfileHandler

func NewProfileHandler(addr string) rpc.ProgressHandler

Types

type MEConfig

type MEConfig struct {
	URL    string            `yaml:"url"`
	Labels map[string]string `yaml:"labels"`
}

MEConfig metric config with yaml

Jump to

Keyboard shortcuts

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