基于go-ora 的 oracle prometheus exporter
还是基于iamseth/oracledb_exporter 的扩展,很简单,就是替换依赖,以前有一个基于godror/godror调整的版本,go-ora 是一个纯golang开发的oracle 驱动,以下是一个调整试用
需要修改的代码
- go.mod
module /iamseth/oracledb_exporter
go 1.14
require (
/BurntSushi/toml v0.3.1
/prometheus/client_golang v1.0.0
/prometheus/common v0.6.0
/sijms/go-ora v0.0.0-20201205173311-40e04fc02df4
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)
- main.go
package main
import (
"bytes"
"context"
"crypto/sha256"
"database/sql"
"errors"
"hash"
"io"
"net/http"
"os"
"strconv"
"strings"
"sync"
"time"
"/BurntSushi/toml"
_ "/sijms/go-ora"
"fmt"
"/prometheus/client_golang/prometheus"
"/prometheus/client_golang/prometheus/promhttp"
"/prometheus/common/log"
"gopkg.in/alecthomas/kingpin.v2"
//Required for debugging
_ "net/http/pprof"
)
说明
目前不太好的是go-ora 性能不是很好,但是从跨平台的角度来说go-ora一个很不错的选择,如果需要分析性能可以集合pprof,我通过
测试发现性能还是差异很大的,参考火焰图