还是基于iamseth/oracledb_exporter 的扩展,很简单,就是替换依赖,以前有一个基于godror/godror
调整的版本,go-ora 是一个纯golang开发的oracle 驱动,以下是一个调整试用
需要修改的代码
- go.mod
module github.com/iamseth/oracledb_exporter
go 1.14
require (
github.com/BurntSushi/toml v0.3.1
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.6.0
github.com/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"
"github.com/BurntSushi/toml"
_ "github.com/sijms/go-ora"
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"gopkg.in/alecthomas/kingpin.v2"
//Required for debugging
_ "net/http/pprof"
)
说明
目前不太好的是go-ora 性能不是很好,但是从跨平台的角度来说go-ora一个很不错的选择,具体可以参考代码https://github.com/rongfengliang/oracledb_exporter/tree/v1.0.1,如果需要分析性能可以集合pprof,我通过
测试发现性能还是差异很大的,参考火焰图
参考资料
https://github.com/sijms/go-ora
https://github.com/iamseth/oracledb_exporter
https://github.com/rongfengliang/oracledb_exporter
https://www.cnblogs.com/rongfengliang/p/14109740.html
https://github.com/godror/godror
https://github.com/rongfengliang/go-ora-godror