基於go-ora 的 oracle prometheus exporter
阿新 • • 發佈:2020-12-10
還是基於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