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

77 lines
2.5 KiB
Go

// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package o11yspanmetricsprocessor
import (
"context"
"time"
"github.com/google/uuid"
"github.com/tilinna/clock"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/processor"
semconv "go.opentelemetry.io/otel/semconv/v1.27.0"
"github.com/hanzoai/otel-collector/processor/o11yspanmetricsprocessor/internal/metadata"
)
const (
maxNumberOfServicesToTrack = 256
maxNumberOfOperationsToTrackPerService = 2048
)
// NewFactory creates a factory for the spanmetrics processor.
func NewFactory() processor.Factory {
return processor.NewFactory(
metadata.Type,
createDefaultConfig,
processor.WithTraces(createTracesProcessor, metadata.TracesStability),
)
}
func createDefaultConfig() component.Config {
return &Config{
AggregationTemporality: "AGGREGATION_TEMPORALITY_CUMULATIVE",
DimensionsCacheSize: defaultDimensionsCacheSize,
skipSanitizeLabel: dropSanitizationFeatureGate.IsEnabled(),
MetricsFlushInterval: 60 * time.Second,
EnableExpHistogram: false,
MaxServicesToTrack: maxNumberOfServicesToTrack,
MaxOperationsToTrackPerService: maxNumberOfOperationsToTrackPerService,
}
}
func createTracesProcessor(ctx context.Context, params processor.Settings, cfg component.Config, nextConsumer consumer.Traces) (processor.Traces, error) {
var instanceID string
serviceInstanceId, ok := params.Resource.Attributes().Get(string(semconv.ServiceInstanceIDKey))
if ok {
instanceID = serviceInstanceId.AsString()
} else {
instanceUUID, _ := uuid.NewRandom()
instanceID = instanceUUID.String()
}
p, err := newProcessor(params.Logger, instanceID, cfg, metricsTicker(ctx, cfg))
if err != nil {
return nil, err
}
p.tracesConsumer = nextConsumer
return p, nil
}
func metricsTicker(ctx context.Context, cfg component.Config) *clock.Ticker {
return clock.FromContext(ctx).NewTicker(cfg.(*Config).MetricsFlushInterval)
}