Files
zeekay df7d6cb470 feat: rebrand signoz-otel-collector → Hanzo OTEL Collector
- 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
2026-03-12 00:21:24 -07:00

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{}
}