Skip to content

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
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).

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 needed.

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.

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.

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.

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

@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.

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Un-comment?

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should pass the context from CollectOpsAgentSelfMetrics as an argument.

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.

@franciscovalentecastro franciscovalentecastro force-pushed the fcovalente-otel-logging-feature-tracking branch from d063ce8 to f1b5bcc Compare February 4, 2025 16:00
@franciscovalentecastro franciscovalentecastro merged commit 1fba16f into master Feb 7, 2025
65 of 69 checks passed
@franciscovalentecastro franciscovalentecastro deleted the fcovalente-otel-logging-feature-tracking branch February 7, 2025 18:51
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.

4 participants