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

gcp/observability: Add support for custom tags #5565

Merged
merged 4 commits into from
Aug 11, 2022

Conversation

zasweq
Copy link
Contributor

@zasweq zasweq commented Aug 5, 2022

This PR adds support for custom tags in Observability for Metrics, Tracing, and Logging. Custom tags are defined in the configuration and attached to emitted Logs, Traces, and Metrics. Currently there is no way to test this E2E, so the best we can do is verify the config passed into the Tracing and Metrics exporter has the correct custom tags present. Also, since this added a new field to the configuration, we decided it would be better if we got rid of the implementation detail of representation the configuration with a proto file, which I switched to an internal struct.

This PR does the following:

  • Deletes support for the previous way you set custom tags, by setting Environment Variables with "GRPC_OBSERVABILITY_" as a prefix
  • Rewrote the testing injection logic for Metrics and Tracing, previously pass in exporter, now global function you overwrite
  • Adds new custom tags field in configuration and attaches them to any emitted Metrics, Traces, or Logs.
  • Switch proto representation of configuration to an internal go struct

RELEASE NOTES:

  • O11y: Add support for custom tags

@zasweq zasweq requested a review from dfawley August 5, 2022 02:06
@zasweq zasweq added the Type: Feature New features or improvements in behavior label Aug 5, 2022
@zasweq zasweq added this to the 1.49 Release milestone Aug 5, 2022
@@ -41,6 +39,69 @@ const (

var logFilterPatternRegexp = regexp.MustCompile(logFilterPatternRegexpStr)

// LogFilter represents a method logging configuration.
type LogFilter struct {
Copy link
Member

Choose a reason for hiding this comment

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

This type should not be exported, right? Same below.

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.

// configuration is required for tracing/metrics/logging to function. This
// config captures the most common knobs for gRPC users. It's always possible to
// override with explicit config in code.
type ObvConfig struct {
Copy link
Member

Choose a reason for hiding this comment

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

Just config? Or maybe jsonConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chose config.

@@ -38,26 +37,59 @@ var (
defaultMetricsReportingInterval = time.Second * 30
)

func convertTagsToMonitoringLabels(tags map[string]string) *stackdriver.Labels {
Copy link
Member

Choose a reason for hiding this comment

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

Drop the convert; it's cleaner?

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.

@dfawley dfawley assigned zasweq and unassigned dfawley Aug 11, 2022
Copy link
Contributor Author

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

Thanks for the comments :D!

// configuration is required for tracing/metrics/logging to function. This
// config captures the most common knobs for gRPC users. It's always possible to
// override with explicit config in code.
type ObvConfig struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chose config.

@@ -38,26 +37,59 @@ var (
defaultMetricsReportingInterval = time.Second * 30
)

func convertTagsToMonitoringLabels(tags map[string]string) *stackdriver.Labels {
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.

@zasweq zasweq assigned dfawley and unassigned zasweq Aug 11, 2022
@dfawley dfawley assigned zasweq and unassigned dfawley Aug 11, 2022
@zasweq zasweq merged commit c7fe135 into grpc:master Aug 11, 2022
@dfawley dfawley changed the title O11Y: Added support for custom tags gcp/observability: Add support for custom tags Aug 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants