func NewInstance(ns string, class string) error {
	sc := SocketCollector{}
	ns = strings.Replace(ns, "-", "_", -1)
	socketPath := "/tmp/prometheus-nginx.socket"
	listener, err := net.Listen("unix", socketPath)
	if err != nil {
		return err
	}
	if err := os.Chmod(socketPath, 0777); err != nil {
		return err
	}
	sc.listener = listener
	sc.ns = ns
	sc.ingressClass = class
	requestTags := []string{"host", "status", "protocol", "method", "path", "upstream_name", "upstream_ip", "upstream_status"}
	collectorTags := []string{}
	sc.upstreamResponseTime = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name: "upstream_response_time_seconds",
			Help: "The time spent on receiving the response from the upstream server",
		},
		requestTags,
	)
	sc.requestTime = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name: "request_duration_seconds",
			Help: "The request processing time in seconds",
		},
		requestTags,
	)
	sc.requestLength = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "request_length_bytes",
			Help:    "The request length (including request line, header, and request body)",
			Buckets: prometheus.LinearBuckets(10, 10, 10),  
		},
		requestTags,
	)
	sc.requests = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "requests",
			Help: "The total number of client requests.",
		},
		collectorTags,
	)
	sc.bytesSent = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "bytes_sent",
			Help:    "The the number of bytes sent to a client",
			Buckets: prometheus.ExponentialBuckets(10, 10, 7),  
		},
		requestTags,
	)
	sc.collectorSuccess = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "collector_last_run_successful",
			Help: "Whether the last collector run was successful (success = 1, failure = 0).",
		},
		collectorTags,
	)
	sc.collectorSuccessTime = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "collector_last_run_successful_timestamp_seconds",
			Help: "Timestamp of the last successful collector run",
		},
		collectorTags,
	)
	prometheus.MustRegister(sc.upstreamResponseTime)
	prometheus.MustRegister(sc.requestTime)
	prometheus.MustRegister(sc.requestLength)
	prometheus.MustRegister(sc.requests)
	prometheus.MustRegister(sc.bytesSent)
	prometheus.MustRegister(sc.collectorSuccess)
	prometheus.MustRegister(sc.collectorSuccessTime)
	go sc.Run()
	return nil
}
NewInstance creates a new SocketCollector instance
package collector
import (
	"encoding/json"
	"net"
	"strings"
	"time"
	"github.com/golang/glog"
	"github.com/prometheus/client_golang/prometheus"
	"os"
)
type socketData struct {
	Host   string `json:"host"`    
	Status string `json:"status"`  
	BytesSent float64 `json:"bytesSent"`  
	Protocol string `json:"protocol"`  
	Method   string `json:"method"`    
	RequestLength float64 `json:"requestLength"`  
	RequestTime   float64 `json:"requestTime"`    
	UpstreamName         string  `json:"upstreamName"`          
	UpstreamIP           string  `json:"upstreamIP"`            
	UpstreamResponseTime float64 `json:"upstreamResponseTime"`  
	UpstreamStatus       string  `json:"upstreamStatus"`        
	Path string `json:"path"`  
}
type SocketCollector struct {
	upstreamResponseTime *prometheus.HistogramVec
	requestTime          *prometheus.HistogramVec
	requestLength        *prometheus.HistogramVec
	bytesSent            *prometheus.HistogramVec
	collectorSuccess     *prometheus.GaugeVec
	collectorSuccessTime *prometheus.GaugeVec
	requests             *prometheus.CounterVec
	listener             net.Listener
	ns                   string
	ingressClass         string
}