Skip to content

Commit

Permalink
Create otel_logging_support feature tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscovalentecastro committed Jan 17, 2025
1 parent 19231ae commit 430043b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions confgenerator/confgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"log"
"maps"
"path"
"reflect"
"regexp"
"sort"
"strconv"
Expand Down Expand Up @@ -196,6 +197,7 @@ func (p pipelineInstance) fluentBitComponents(ctx context.Context) (fbSource, er
func (p pipelineInstance) otelComponents(ctx context.Context) (map[string]otel.ReceiverPipeline, map[string]otel.Pipeline, error) {
outR := make(map[string]otel.ReceiverPipeline)
outP := make(map[string]otel.Pipeline)
fmt.Println("p.receiver = ", p.receiver, "typeof = ", reflect.TypeOf(p.receiver))
receiver, ok := p.receiver.(OTelReceiver)
if !ok {
return nil, nil, fmt.Errorf("%q is not an otel receiver", p.rID)
Expand Down Expand Up @@ -238,6 +240,7 @@ func (p pipelineInstance) otelComponents(ctx context.Context) (map[string]otel.R
}
}
for _, processorItem := range p.processors {
fmt.Println("processorItem = ", processorItem, "typeof = ", reflect.TypeOf(processorItem))
processor, ok := processorItem.Component.(OTelProcessor)
if !ok {
return nil, nil, fmt.Errorf("processor %q not supported in pipeline %q", processorItem.id, p.pID)
Expand Down
32 changes: 32 additions & 0 deletions confgenerator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,38 @@ func (uc *UnifiedConfig) OTelLoggingReceivers(ctx context.Context) (map[string]O
return validReceivers, nil
}

func (uc *UnifiedConfig) OTelLoggingProcessors(ctx context.Context) (map[string]OTelProcessor, error) {
validProcessors := map[string]OTelProcessor{}
for k, v := range uc.Logging.Processors {
if v, ok := v.(OTelProcessor); ok {
validProcessors[k] = v
}
}
return validProcessors, nil
}

func (uc *UnifiedConfig) ValidateOTelLoggingPipeline(ctx context.Context) error {
validLoggingReceivers, err := uc.LoggingReceivers(ctx)
if err != nil {
return err
}
validOTelLoggingReceivers, err := uc.OTelLoggingReceivers(ctx)
if err != nil {
return err
}
if len(validOTelLoggingReceivers) < len(validLoggingReceivers) {
return fmt.Errorf("Some defined logging receivers are not supported by otel logging")
}
validOTelLoggingProcessors, err := uc.OTelLoggingProcessors(ctx)
if err != nil {
return err
}
if len(validOTelLoggingProcessors) < len(uc.Logging.Processors) {
return fmt.Errorf("Some defined logging processors are not supported by otel logging")
}
return nil
}

func (uc *UnifiedConfig) ValidateMetrics(ctx context.Context) error {
m := uc.Metrics
subagent := "metrics"
Expand Down
19 changes: 19 additions & 0 deletions confgenerator/feature_tracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package confgenerator

import (
"context"
"errors"
"fmt"
"reflect"
Expand Down Expand Up @@ -74,6 +75,7 @@ type CustomFeatures interface {
func ExtractFeatures(uc *UnifiedConfig) ([]Feature, error) {
allFeatures := getOverriddenDefaultPipelines(uc)
allFeatures = append(allFeatures, getSelfLogCollection(uc))
allFeatures = append(allFeatures, getOTelLoggingSupport(uc))

var err error
var tempTrackedFeatures []Feature
Expand Down Expand Up @@ -437,6 +439,23 @@ func getMetadata(field reflect.StructField) metadata {
}
}

func getOTelLoggingSupport(uc *UnifiedConfig) Feature {
feature := Feature{
Module: "logging",
Kind: "service",
Type: "otel_logging",
Key: []string{"otel_logging_support"},
Value: "true",
}

ctx := context.Background()
if uc.ValidateOTelLoggingPipeline(ctx) != nil {
feature.Value = "false"
}

return feature
}

func getSelfLogCollection(uc *UnifiedConfig) Feature {
feature := Feature{
Module: "global",
Expand Down

0 comments on commit 430043b

Please sign in to comment.