mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
- Go module: github.com/SigNoz/signoz-otel-collector → github.com/hanzoai/otel-collector - All signoz-prefixed packages → o11y-prefixed - Docker: signoz/* → ghcr.io/hanzoai/otel-collector - ClickHouse exporter → Hanzo Datastore - Env vars: SIGNOZ_* → HANZO_* - Directory renames for all processor/receiver/exporter packages
76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
package o11ymeterconnector
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil"
|
|
"go.opentelemetry.io/collector/pdata/pcommon"
|
|
)
|
|
|
|
type meterMetric struct {
|
|
spanCount int
|
|
spanSize int
|
|
metricDataPointCount int
|
|
metricDataPointSize int
|
|
logCount int
|
|
logSize int
|
|
attrs pcommon.Map
|
|
}
|
|
|
|
type aggregatedMeterMetrics struct {
|
|
meterMetrics map[[16]byte]*meterMetric
|
|
sync.Mutex
|
|
}
|
|
|
|
func newAggregatedMeterMetrics() *aggregatedMeterMetrics {
|
|
return &aggregatedMeterMetrics{
|
|
meterMetrics: map[[16]byte]*meterMetric{},
|
|
}
|
|
}
|
|
|
|
func (agm *aggregatedMeterMetrics) UpdateMetricDataPointsMeterMetrics(attrs pcommon.Map, count, size int) {
|
|
key := pdatautil.MapHash(attrs)
|
|
agm.Lock()
|
|
defer agm.Unlock()
|
|
|
|
meterMetrics, ok := agm.meterMetrics[key]
|
|
if !ok {
|
|
meterMetrics = &meterMetric{attrs: attrs}
|
|
agm.meterMetrics[key] = meterMetrics
|
|
}
|
|
meterMetrics.metricDataPointCount += count
|
|
meterMetrics.metricDataPointSize += size
|
|
}
|
|
|
|
func (agm *aggregatedMeterMetrics) UpdateSpanMeterMetrics(attrs pcommon.Map, count, size int) {
|
|
key := pdatautil.MapHash(attrs)
|
|
agm.Lock()
|
|
defer agm.Unlock()
|
|
|
|
meterMetrics, ok := agm.meterMetrics[key]
|
|
if !ok {
|
|
meterMetrics = &meterMetric{attrs: attrs}
|
|
agm.meterMetrics[key] = meterMetrics
|
|
}
|
|
meterMetrics.spanCount += count
|
|
meterMetrics.spanSize += size
|
|
}
|
|
|
|
func (agm *aggregatedMeterMetrics) UpdateLogMeterMetrics(attrs pcommon.Map, count, size int) {
|
|
key := pdatautil.MapHash(attrs)
|
|
agm.Lock()
|
|
defer agm.Unlock()
|
|
|
|
meterMetrics, ok := agm.meterMetrics[key]
|
|
if !ok {
|
|
meterMetrics = &meterMetric{attrs: attrs}
|
|
agm.meterMetrics[key] = meterMetrics
|
|
}
|
|
meterMetrics.logCount += count
|
|
meterMetrics.logSize += size
|
|
}
|
|
|
|
func (agm *aggregatedMeterMetrics) Purge() {
|
|
agm.meterMetrics = map[[16]byte]*meterMetric{}
|
|
}
|