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

[mdatagen] Generate wrappers for recording telemetry metrics #12182

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

crobert-1
Copy link
Member

Description

This is essentially reviving #10911, the first step towards #10801. The goal is to be able to use mdatagen to handle more use cases around telemetry metrics, similar to regular metrics, especially to be able to set attributes on the telemetry metrics.

Link to tracking issue

Part of #10801

Testing

Code has been generated for different telemetry metric types, existing tests use this behavior pretty heavily.

@crobert-1 crobert-1 requested review from bogdandrutu, dmitryax and a team as code owners January 25, 2025 00:11
@crobert-1 crobert-1 marked this pull request as draft January 25, 2025 00:16
Copy link

codecov bot commented Jan 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.59%. Comparing base (ee0f0ae) to head (8d42d44).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12182      +/-   ##
==========================================
+ Coverage   91.57%   91.59%   +0.01%     
==========================================
  Files         483      483              
  Lines       26383    26443      +60     
==========================================
+ Hits        24160    24220      +60     
  Misses       1762     1762              
  Partials      461      461              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@crobert-1 crobert-1 marked this pull request as ready for review January 25, 2025 00:32
Comment on lines +102 to +141
func (builder *TelemetryBuilder) RecordProcessorBatchBatchSendSize(ctx context.Context, val int64, opts ...metric.RecordOption) {
builder.ProcessorBatchBatchSendSize.Record(ctx, val, opts...)
}

func (builder *TelemetryBuilder) RecordProcessorBatchBatchSendSizeBytes(ctx context.Context, val int64, opts ...metric.RecordOption) {
builder.ProcessorBatchBatchSendSizeBytes.Record(ctx, val, opts...)
}

func (builder *TelemetryBuilder) RecordProcessorBatchBatchSizeTriggerSend(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorBatchBatchSizeTriggerSend.Add(ctx, val, opts...)
}

func (builder *TelemetryBuilder) RecordProcessorBatchTimeoutTriggerSend(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorBatchTimeoutTriggerSend.Add(ctx, val, opts...)
}
Copy link
Member

Choose a reason for hiding this comment

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

Few things here:

  1. We will confuse the user when using Add/Record because we don't respect the same semantics as otel.
  2. What is the next level for this PR? Can you just provide a sketch code that you want to end with, please don't make the code changes, just provide a draft code for me to understand.

Copy link
Member Author

@crobert-1 crobert-1 Jan 27, 2025

Choose a reason for hiding this comment

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

  1. We will confuse the user when using Add/Record because we don't respect the same semantics as otel.

Good call out. My thought process was to make it as simple and consistent for the user as possible. This also matches mdatagen's functionality for metrics, which always have Record as the prefix irrespective of metric type.

  1. What is the next level for this PR? Can you just provide a sketch code that you want to end with, please don't make the code changes, just provide a draft code for me to understand.

The goal is to bring up internal telemetry functionality to the same level as receiver metrics using mdatagen. My intention would be to make the metric itself private to the internal/metadata package within a component, then only expose the Record method.

Something like:

type AttributeFoo string

type metricProcessorBatchBatchSendSize struct {
}

type TelemetryBuilder {
  metricProcessorBatchBatchSendSendSize metricProcessorBatchBatchSendSendSize
}

func (builder *TelemetryBuilder) RecordProcessorBatchBatchSendSendSize(ctx context.Context, val int64, foo string) {
}

Going this direction allows us to implement support for the documented schema of mdatagen, especially telemetry metric attributes, and enforcing the set value for enabled in the schema.

I can open an issue with this proposal if it would be better for tracking and discussion.

Copy link
Member

Choose a reason for hiding this comment

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

  1. @bogdandrutu, do you want to use Add<MetricName> for sum type? That sounds reasonable. We don't have DataPoint suffix here as we have in the normal builder, and that makes sense. So we can probably provide an interface closer to the go SDK instead.

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@crobert-1
Copy link
Member Author

Apologies for letting this go stale, I've updated.

@bogdandrutu I've replied to your question, can you review again when you get a chance?

@github-actions github-actions bot removed the Stale label Feb 15, 2025
Copy link
Contributor

github-actions bot commented Mar 5, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added Stale and removed Stale labels Mar 5, 2025
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 20, 2025
@crobert-1 crobert-1 force-pushed the tel_metric_attributes branch from 230e064 to 9065f51 Compare March 20, 2025 16:17
@github-actions github-actions bot removed the Stale label Mar 21, 2025
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.

3 participants