func (m *Metrics) DocumentResolveTime(value time.Duration) {
	m.docResolveTime.Observe(value.Seconds())
	logger.Debugf("DocumentResolve time: %s", value)
}
DocumentResolveTime records the time it takes the REST handler to resolve a document.
package metrics
import (
	"sync"
	"time"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/trustbloc/edge-core/pkg/log"
)
const (
	namespace = "orb"
	activityPub                   = "activitypub"
	apPostTimeMetric              = "outbox_post_seconds"
	apResolveInboxesTimeMetric    = "outbox_resolve_inboxes_seconds"
	apInboxHandlerTimeMetric      = "inbox_handler_seconds"
	apOutboxActivityCounterMetric = "outbox_count"
	anchor                                         = "anchor"
	anchorWriteTimeMetric                          = "write_seconds"
	anchorWitnessMetric                            = "witness_seconds"
	anchorProcessWitnessedMetric                   = "process_witnessed_seconds"
	anchorWriteBuildCredTimeMetric                 = "write_build_cred_seconds"
	anchorWriteGetWitnessesTimeMetric              = "write_get_witnesses_seconds"
	anchorWriteSignCredTimeMetric                  = "write_sign_cred_seconds"
	anchorWritePostOfferActivityTimeMetric         = "write_post_offer_activity_seconds"
	anchorWriteGetPreviousAnchorsGetBulkTimeMetric = "write_get_previous_anchor_get_bulk_seconds"
	anchorWriteGetPreviousAnchorsTimeMetric        = "write_get_previous_anchor_seconds"
	anchorWriteSignWithLocalWitnessTimeMetric      = "write_sign_with_local_witness_seconds"
	anchorWriteSignWithServerKeyTimeMetric         = "write_sign_with_server_key_seconds"
	anchorWriteSignLocalWitnessLogTimeMetric       = "write_sign_local_witness_log_seconds"
	anchorWriteSignLocalStoreTimeMetric            = "write_sign_local_store_seconds"
	anchorWriteSignLocalWatchTimeMetric            = "write_sign_local_watch_seconds"
	anchorWriteResolveHostMetaLinkTimeMetric       = "write_resolve_host_meta_link_seconds"
	operationQueue                 = "opqueue"
	opQueueAddOperationTimeMetric  = "add_operation_seconds"
	opQueueBatchCutTimeMetric      = "batch_cut_seconds"
	opQueueBatchRollbackTimeMetric = "batch_rollback_seconds"
	opQueueBatchAckTimeMetric      = "batch_ack_seconds"
	opQueueBatchNackTimeMetric     = "batch_nack_seconds"
	opQueueBatchSizeMetric         = "batch_size"
	observer                        = "observer"
	observerProcessAnchorTimeMetric = "process_anchor_seconds"
	observerProcessDIDTimeMetric    = "process_did_seconds"
	cas                    = "cas"
	casWriteTimeMetric     = "write_seconds"
	casResolveTimeMetric   = "resolve_seconds"
	casCacheHitCountMetric = "cache_hit_count"
	casReadTimeMetric      = "read_seconds"
	document                  = "document"
	docCreateUpdateTimeMetric = "create_update_seconds"
	docResolveTimeMetric      = "resolve_seconds"
	db                  = "db"
	dbPutTimeMetric     = "put_seconds"
	dbGetTimeMetric     = "get_seconds"
	dbGetTagsTimeMetric = "get_tags_seconds"
	dbGetBulkTimeMetric = "get_bulk_seconds"
	dbQueryTimeMetric   = "query_seconds"
	dbDeleteTimeMetric  = "delete_seconds"
	vct                                  = "vct"
	vctWitnessAddProofVCTNilTimeMetric   = "witness_add_proof_vct_nil_seconds"
	vctWitnessAddVCTimeMetric            = "witness_add_vc_seconds"
	vctWitnessAddProofTimeMetric         = "witness_add_proof_seconds"
	vctWitnessWebFingerTimeMetric        = "witness_webfinger_seconds"
	vctWitnessVerifyVCTTimeMetric        = "witness_verify_vct_signature_seconds"
	vctAddProofParseCredentialTimeMetric = "witness_add_proof_parse_credential_seconds"
	vctAddProofSignTimeMetric            = "witness_add_proof_sign_seconds"
	signer                         = "signer"
	signerGetKeyTimeMetric         = "get_key_seconds"
	signerSignMetric               = "sign_seconds"
	signerAddLinkedDataProofMetric = "add_linked_data_proof_seconds"
)
var logger = log.New("metrics")
var (
	createOnce sync.Once  
	instance   *Metrics   
)
type Metrics struct {
	apOutboxPostTime           prometheus.Histogram
	apOutboxResolveInboxesTime prometheus.Histogram
	apInboxHandlerTimes        map[string]prometheus.Histogram
	apOutboxActivityCounts     map[string]prometheus.Counter
	anchorWriteTime                          prometheus.Histogram
	anchorWitnessTime                        prometheus.Histogram
	anchorProcessWitnessedTime               prometheus.Histogram
	anchorWriteBuildCredTime                 prometheus.Histogram
	anchorWriteGetWitnessesTime              prometheus.Histogram
	anchorWriteSignCredTime                  prometheus.Histogram
	anchorWritePostOfferActivityTime         prometheus.Histogram
	anchorWriteGetPreviousAnchorsGetBulkTime prometheus.Histogram
	anchorWriteGetPreviousAnchorsTime        prometheus.Histogram
	anchorWriteSignWithLocalWitnessTime      prometheus.Histogram
	anchorWriteSignWithServerKeyTime         prometheus.Histogram
	anchorWriteSignLocalWitnessLogTime       prometheus.Histogram
	anchorWriteSignLocalStoreTime            prometheus.Histogram
	anchorWriteSignLocalWatchTime            prometheus.Histogram
	anchorWriteResolveHostMetaLinkTime       prometheus.Histogram
	opqueueAddOperationTime  prometheus.Histogram
	opqueueBatchCutTime      prometheus.Histogram
	opqueueBatchRollbackTime prometheus.Histogram
	opqueueBatchAckTime      prometheus.Histogram
	opqueueBatchNackTime     prometheus.Histogram
	opqueueBatchSize         prometheus.Gauge
	observerProcessAnchorTime prometheus.Histogram
	observerProcessDIDTime    prometheus.Histogram
	casWriteTime     prometheus.Histogram
	casResolveTime   prometheus.Histogram
	casCacheHitCount prometheus.Counter
	casReadTimes     map[string]prometheus.Histogram
	docCreateUpdateTime prometheus.Histogram
	docResolveTime      prometheus.Histogram
	dbPutTimes     map[string]prometheus.Histogram
	dbGetTimes     map[string]prometheus.Histogram
	dbGetTagsTimes map[string]prometheus.Histogram
	dbGetBulkTimes map[string]prometheus.Histogram
	dbQueryTimes   map[string]prometheus.Histogram
	dbDeleteTimes  map[string]prometheus.Histogram
	vctWitnessAddProofVCTNilTimes   prometheus.Histogram
	vctWitnessAddVCTimes            prometheus.Histogram
	vctWitnessAddProofTimes         prometheus.Histogram
	vctWitnessAddWebFingerTimes     prometheus.Histogram
	vctWitnessVerifyVCTimes         prometheus.Histogram
	vctAddProofParseCredentialTimes prometheus.Histogram
	vctAddProofSignTimes            prometheus.Histogram
	signerGetKeyTimes               prometheus.Histogram
	signerSignTimes                 prometheus.Histogram
	signerAddLinkedDataProofTimes   prometheus.Histogram
}
func Get() *Metrics {
	createOnce.Do(func() {
		instance = newMetrics()
	})
	return instance
}
func newMetrics() *Metrics {  
	activityTypes := []string{"Create", "Announce", "Offer", "Like", "Follow", "InviteWitness", "Accept", "Reject"}
	dbTypes := []string{"CouchDB", "MongoDB"}
	m := &Metrics{
		apOutboxPostTime:                         newOutboxPostTime(),
		apOutboxResolveInboxesTime:               newOutboxResolveInboxesTime(),
		anchorWriteTime:                          newAnchorWriteTime(),
		anchorWriteBuildCredTime:                 newAnchorWriteBuildCredTime(),
		anchorWriteGetWitnessesTime:              newAnchorWriteGetWitnessesTime(),
		anchorWriteSignCredTime:                  newAnchorWriteSignCredTime(),
		anchorWritePostOfferActivityTime:         newAnchorWritePostOfferActivityTime(),
		anchorWriteGetPreviousAnchorsGetBulkTime: newAnchorWriteGetPreviousAnchorsGetBulkTime(),
		anchorWriteGetPreviousAnchorsTime:        newAnchorWriteGetPreviousAnchorsTime(),
		anchorWitnessTime:                        newAnchorWitnessTime(),
		anchorProcessWitnessedTime:               newAnchorProcessWitnessedTime(),
		anchorWriteSignWithLocalWitnessTime:      newAnchorWriteSignWithLocalWitnessTime(),
		anchorWriteSignWithServerKeyTime:         newAnchorWriteSignWithServerKeyTime(),
		anchorWriteSignLocalWitnessLogTime:       newAnchorWriteSignLocalWitnessLogTime(),
		anchorWriteSignLocalStoreTime:            newAnchorWriteSignLocalStoreTime(),
		anchorWriteSignLocalWatchTime:            newAnchorWriteSignLocalWatchTime(),
		anchorWriteResolveHostMetaLinkTime:       newAnchorWriteResolveHostMetaLinkTime(),
		opqueueAddOperationTime:                  newOpQueueAddOperationTime(),
		opqueueBatchCutTime:                      newOpQueueBatchCutTime(),
		opqueueBatchRollbackTime:                 newOpQueueBatchRollbackTime(),
		opqueueBatchAckTime:                      newOpQueueBatchAckTime(),
		opqueueBatchNackTime:                     newOpQueueBatchNackTime(),
		opqueueBatchSize:                         newOpQueueBatchSize(),
		observerProcessAnchorTime:                newObserverProcessAnchorTime(),
		observerProcessDIDTime:                   newObserverProcessDIDTime(),
		casWriteTime:                             newCASWriteTime(),
		casResolveTime:                           newCASResolveTime(),
		casReadTimes:                             newCASReadTimes(),
		casCacheHitCount:                         newCASCacheHitCount(),
		docCreateUpdateTime:                      newDocCreateUpdateTime(),
		docResolveTime:                           newDocResolveTime(),
		apInboxHandlerTimes:                      newInboxHandlerTimes(activityTypes),
		apOutboxActivityCounts:                   newOutboxActivityCounts(activityTypes),
		dbPutTimes:                               newDBPutTime(dbTypes),
		dbGetTimes:                               newDBGetTime(dbTypes),
		dbGetTagsTimes:                           newDBGetTagsTime(dbTypes),
		dbGetBulkTimes:                           newDBGetBulkTime(dbTypes),
		dbQueryTimes:                             newDBQueryTime(dbTypes),
		dbDeleteTimes:                            newDBDeleteTime(dbTypes),
		vctWitnessAddProofVCTNilTimes:            newVCTWitnessAddProofVCTNilTime(),
		vctWitnessAddVCTimes:                     newVCTWitnessAddVCTime(),
		vctWitnessAddProofTimes:                  newVCTWitnessAddProofTime(),
		vctWitnessAddWebFingerTimes:              newVCTWitnessWebFingerTime(),
		vctWitnessVerifyVCTimes:                  newVCTWitnessVerifyVCTTime(),
		vctAddProofParseCredentialTimes:          newVCTAddProofParseCredentialTime(),
		vctAddProofSignTimes:                     newVCTAddProofSignTime(),
		signerGetKeyTimes:                        newSignerGetKeyTime(),
		signerSignTimes:                          newSignerSignTime(),
		signerAddLinkedDataProofTimes:            newSignerAddLinkedDataProofTime(),
	}
	prometheus.MustRegister(
		m.apOutboxPostTime, m.apOutboxResolveInboxesTime,
		m.anchorWriteTime, m.anchorWitnessTime, m.anchorProcessWitnessedTime, m.anchorWriteBuildCredTime,
		m.anchorWriteGetWitnessesTime, m.anchorWriteSignCredTime, m.anchorWritePostOfferActivityTime,
		m.anchorWriteGetPreviousAnchorsGetBulkTime, m.anchorWriteGetPreviousAnchorsTime,
		m.anchorWriteSignWithLocalWitnessTime, m.anchorWriteSignWithServerKeyTime, m.anchorWriteSignLocalWitnessLogTime,
		m.anchorWriteSignLocalStoreTime, m.anchorWriteSignLocalWatchTime,
		m.opqueueAddOperationTime, m.opqueueBatchCutTime, m.opqueueBatchRollbackTime,
		m.opqueueBatchAckTime, m.opqueueBatchNackTime, m.opqueueBatchSize,
		m.observerProcessAnchorTime, m.observerProcessDIDTime,
		m.casWriteTime, m.casResolveTime, m.casCacheHitCount,
		m.docCreateUpdateTime, m.docResolveTime,
		m.vctWitnessAddProofVCTNilTimes, m.vctWitnessAddVCTimes, m.vctWitnessAddProofTimes,
		m.vctWitnessAddWebFingerTimes, m.vctWitnessVerifyVCTimes, m.vctAddProofParseCredentialTimes,
		m.vctAddProofSignTimes, m.signerSignTimes, m.signerGetKeyTimes, m.signerAddLinkedDataProofTimes,
		m.anchorWriteResolveHostMetaLinkTime,
	)
	for _, c := range m.apInboxHandlerTimes {
		prometheus.MustRegister(c)
	}
	for _, c := range m.dbPutTimes {
		prometheus.MustRegister(c)
	}
	for _, c := range m.dbGetTimes {
		prometheus.MustRegister(c)
	}
	for _, c := range m.dbGetTagsTimes {
		prometheus.MustRegister(c)
	}
	for _, c := range m.dbGetBulkTimes {
		prometheus.MustRegister(c)
	}
	for _, c := range m.apOutboxActivityCounts {
		prometheus.MustRegister(c)
	}
	for _, c := range m.casReadTimes {
		prometheus.MustRegister(c)
	}
	return m
}
func (m *Metrics) OutboxPostTime(value time.Duration) {
	m.apOutboxPostTime.Observe(value.Seconds())
	logger.Debugf("OutboxPost time: %s", value)
}
func (m *Metrics) OutboxResolveInboxesTime(value time.Duration) {
	m.apOutboxResolveInboxesTime.Observe(value.Seconds())
	logger.Debugf("OutboxResolveInboxes time: %s", value)
}
func (m *Metrics) InboxHandlerTime(activityType string, value time.Duration) {
	if c, ok := m.apInboxHandlerTimes[activityType]; ok {
		c.Observe(value.Seconds())
	}
	logger.Debugf("InboxHandler time for activity [%s]: %s", activityType, value)
}
func (m *Metrics) OutboxIncrementActivityCount(activityType string) {
	if c, ok := m.apOutboxActivityCounts[activityType]; ok {
		c.Inc()
	}
}
func (m *Metrics) WriteAnchorTime(value time.Duration) {
	m.anchorWriteTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor time: %s", value)
}
func (m *Metrics) WriteAnchorBuildCredentialTime(value time.Duration) {
	m.anchorWriteBuildCredTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor build credential time: %s", value)
}
func (m *Metrics) WriteAnchorGetWitnessesTime(value time.Duration) {
	m.anchorWriteGetWitnessesTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor get witness time: %s", value)
}
func (m *Metrics) WriteAnchorSignCredentialTime(value time.Duration) {
	m.anchorWriteSignCredTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor sign credential time: %s", value)
}
func (m *Metrics) WriteAnchorPostOfferActivityTime(value time.Duration) {
	m.anchorWritePostOfferActivityTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor sign credential time: %s", value)
}
func (m *Metrics) WriteAnchorGetPreviousAnchorsGetBulkTime(value time.Duration) {
	m.anchorWriteGetPreviousAnchorsGetBulkTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor getPreviousAnchor geBulk time: %s", value)
}
func (m *Metrics) WriteAnchorGetPreviousAnchorsTime(value time.Duration) {
	m.anchorWriteGetPreviousAnchorsTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor getPreviousAnchor time: %s", value)
}
func (m *Metrics) WriteAnchorSignWithLocalWitnessTime(value time.Duration) {
	m.anchorWriteSignWithLocalWitnessTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor sign with local witness time: %s", value)
}
func (m *Metrics) WriteAnchorSignWithServerKeyTime(value time.Duration) {
	m.anchorWriteSignWithServerKeyTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor sign with server key time: %s", value)
}
func (m *Metrics) WriteAnchorSignLocalWitnessLogTime(value time.Duration) {
	m.anchorWriteSignLocalWitnessLogTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor witness log inside sign local time: %s", value)
}
func (m *Metrics) WriteAnchorSignLocalStoreTime(value time.Duration) {
	m.anchorWriteSignLocalStoreTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor store inside sign local time: %s", value)
}
func (m *Metrics) WriteAnchorSignLocalWatchTime(value time.Duration) {
	m.anchorWriteSignLocalWatchTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor watch inside sign local time: %s", value)
}
func (m *Metrics) WriteAnchorResolveHostMetaLinkTime(value time.Duration) {
	m.anchorWriteResolveHostMetaLinkTime.Observe(value.Seconds())
	logger.Debugf("WriteAnchor resolve host meta link time: %s", value)
}
func (m *Metrics) WitnessAnchorCredentialTime(value time.Duration) {
	m.anchorWitnessTime.Observe(value.Seconds())
	logger.Debugf("WitnessAnchorCredential time: %s", value)
}
func (m *Metrics) ProcessWitnessedAnchorCredentialTime(value time.Duration) {
	m.anchorProcessWitnessedTime.Observe(value.Seconds())
	logger.Debugf("ProcessWitnessedAnchorCredential time: %s", value)
}
func (m *Metrics) AddOperationTime(value time.Duration) {
	m.opqueueAddOperationTime.Observe(value.Seconds())
	logger.Debugf("AddOperation time: %s", value)
}
func (m *Metrics) BatchCutTime(value time.Duration) {
	m.opqueueBatchCutTime.Observe(value.Seconds())
	logger.Infof("BatchCut time: %s", value)
}
func (m *Metrics) BatchRollbackTime(value time.Duration) {
	m.opqueueBatchRollbackTime.Observe(value.Seconds())
	logger.Debugf("BatchRollback time: %s", value)
}
func (m *Metrics) BatchAckTime(value time.Duration) {
	m.opqueueBatchAckTime.Observe(value.Seconds())
	logger.Debugf("BatchAck time: %s", value)
}
func (m *Metrics) BatchNackTime(value time.Duration) {
	m.opqueueBatchNackTime.Observe(value.Seconds())
	logger.Debugf("BatchNack time: %s", value)
}
func (m *Metrics) BatchSize(value float64) {
	m.opqueueBatchSize.Set(value)
	logger.Infof("BatchSize: %s", value)
}
func (m *Metrics) ProcessAnchorTime(value time.Duration) {
	m.observerProcessAnchorTime.Observe(value.Seconds())
	logger.Infof("ProcessAnchor time: %s", value)
}
func (m *Metrics) ProcessDIDTime(value time.Duration) {
	m.observerProcessDIDTime.Observe(value.Seconds())
	logger.Infof("ProcessDID time: %s", value)
}
func (m *Metrics) CASWriteTime(value time.Duration) {
	m.casWriteTime.Observe(value.Seconds())
	logger.Debugf("CASWrite time: %s", value)
}
func (m *Metrics) CASResolveTime(value time.Duration) {
	m.casResolveTime.Observe(value.Seconds())
	logger.Debugf("CASResolve time: %s", value)
}
func (m *Metrics) CASIncrementCacheHitCount() {
	m.casCacheHitCount.Inc()
}
func (m *Metrics) CASReadTime(casType string, value time.Duration) {
	if c, ok := m.casReadTimes[casType]; ok {
		c.Observe(value.Seconds())
	}
}
func (m *Metrics) DocumentCreateUpdateTime(value time.Duration) {
	m.docCreateUpdateTime.Observe(value.Seconds())
	logger.Debugf("DocumentCreateUpdate time: %s", value)
}