Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create otel_logging_supported_config feature tracking metric. #1861

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

franciscovalentecastro
Copy link
Contributor

@franciscovalentecastro franciscovalentecastro commented Jan 17, 2025

Description

Create otel_logging_support feature tracking metric.

{
    Module: "logging",
    Kind:   "service",
    Type:   "otel_logging",
    Key:    []string{"otel_logging_supported_config"},
    Value:  "true / false",
}

Related issue

b/390671495

How has this been tested?

Checklist:

  • Unit tests
    • Unit tests do not apply.
    • Unit tests have been added/modified and passed for this PR.
  • Integration tests
    • Integration tests do not apply.
    • Integration tests have been added/modified and passed for this PR.
  • Documentation
    • This PR introduces no user visible changes.
    • This PR introduces user visible changes and the corresponding documentation change has been made.
  • Minor version bump
    • This PR introduces no new features.
    • This PR introduces new features, and there is a separate PR to bump the minor version since the last release already.
    • This PR bumps the version.

@franciscovalentecastro franciscovalentecastro changed the title [Draft] Create otel_logging_support feature tracking metric. Create otel_logging_support feature tracking metric. Jan 20, 2025
@franciscovalentecastro franciscovalentecastro marked this pull request as ready for review January 20, 2025 18:28
@franciscovalentecastro franciscovalentecastro changed the title Create otel_logging_support feature tracking metric. Create otel_logging_compatible_config feature tracking metric. Jan 20, 2025
}
validProcessors := map[string]OTelProcessor{}
for k, v := range processors {
if v, ok := v.(OTelProcessor); ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually check if the processor is supported, only if it might be supported.

Instead of doing all this work to separately validate, I would just clone the config, set the experimental flag, and see if generating causes an error:

func (uc *UnifiedConfig) OTelLoggingSupported() bool {
  uc2 := uc.DeepCopy(ctx)
  if uc2.Logging == nil {
    return false
  }
  if uc2.Logging.Service == nil {
    uc2.Logging.Service = &Service{}
  }
  uc2.Logging.Service.OTelLogging = true
  _, err := uc2.GenerateOtelConfig(ctx)
  return err == nil
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wanted it per-pipeline, you could do

        pipelines, err := uc.Pipelines(ctx)
        if err != nil {
                return nil, nil, err
        }
        for name, pipeline := range pipelines {
                _, _, err := pipeline.otelComponents(ctx)
                supported[name] = err == nil
        }

Copy link
Contributor Author

@franciscovalentecastro franciscovalentecastro Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to only check the whole config and not consider individual pipelines for the current PR.

IMO, feature tracking about individual pipelines would not be very helpful for our goal (getting statistics of OTel logging supported configs), since it would require several additional metric labels to describe the pipeline in detail (which receivers, processors or features are unsupported for each pipeline).

I think it would be simpler to track specific unsupported receivers or processors, not tied to a specific pipeline. We can consider if this data is needed in the future. I consider this additional labels about which specific feature is not supported is out of scope of this initial task / PR and could added later if need.

Value: "false",
}

ctx := context.Background()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be the Context from the unit test, not context.Background(). It looks like that needs to be passed into ExtractFeatures.

@@ -101,11 +112,8 @@ func (uc *UnifiedConfig) GenerateOtelConfig(ctx context.Context) (string, error)
ReceiverPipelineName: "fluentbit",
}

if uc.Metrics.Service.LogLevel == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your current diff will cause the logging log level to override the metrics log level. I think we should stick with the existing behavior of only using the metrics log level, which you could do with

logLevel := "info"
if uc.Metrics != nil && uc.Metrics.Service != nil && uc.Metrics.Service.LogLevel != "" {
  logLevel = uc.Metrics.Service.LogLevel
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -907,15 +907,17 @@ func (uc *UnifiedConfig) ValidateCombined() error {

func (uc *UnifiedConfig) MetricsReceivers() (map[string]MetricsReceiver, error) {
validReceivers := map[string]MetricsReceiver{}
if uc.Metrics != nil {
if uc.Metrics != nil && uc.Metrics.Receivers != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary; it's valid to iterate over a nil map.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the uc.Metrics.Receivers != nil. Done.

for k, v := range uc.Metrics.Receivers {
validReceivers[k] = v
}
}
if uc.Combined != nil {
for k, v := range uc.Combined.Receivers {
if _, ok := uc.Metrics.Receivers[k]; ok {
return nil, fmt.Errorf("metrics receiver %q has the same name as combined receiver %q", k, k)
if uc.Metrics != nil && uc.Metrics.Receivers != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only needs to be if uc.Metrics != nil; subscripting a nil map is valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the uc.Metrics.Receivers != nil. Done.

@franciscovalentecastro franciscovalentecastro changed the title Create otel_logging_compatible_config feature tracking metric. Create otel_logging_supported_config feature tracking metric. Jan 24, 2025
@franciscovalentecastro franciscovalentecastro force-pushed the fcovalente-otel-logging-feature-tracking branch from a3341e2 to 73a24db Compare February 2, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants