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

Add standard metrics custom processor and request duration metric #33955

Merged
merged 14 commits into from
Feb 8, 2023

Conversation

vishweshbankwar
Copy link
Member

@vishweshbankwar vishweshbankwar commented Feb 7, 2023

This PR adds a custom span processor for extracting standard metrics. It also adds request/duration metric.

TODOs:

  1. Add remaining metrics.
  2. Additional tests which includes updated sampler.
  3. Update Changelog.

From end user perspective this will be enabled by default on configuring metric exporter.

Adding the complete design plan for extracting standard metrics below

Proposal: Standard metric collection in OpenTelemetry can be enabled by customizing following two parts in SDK:

Sampler: When the sampler decides to drop the data return SamplingResult.RecordOnly  instead of SamplingResult.None. This will achieve following two things:
Span will be created and will be populated with all the information (tags, events etc.)SampledFlag will still be set to false. So, this will not impact propagated sampling decision i.e. traceflags information.

Custom Processor:Add a custom processor which will extract standard metrics information as required. These metrics can then be reported as standard metrics using a metric exporter.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@vishweshbankwar vishweshbankwar added the Monitor - Exporter Monitor OpenTelemetry Exporter label Feb 7, 2023
@vishweshbankwar vishweshbankwar merged commit 6615941 into main Feb 8, 2023
@vishweshbankwar vishweshbankwar deleted the vibankwa/add-standard-metrics-custom-processor branch February 8, 2023 01:15
}

TagList tags = default;
tags.Add(new KeyValuePair<string, object>(StandardMetricConstants.RequestResultCodeKey, statusCodeAttributeValue));
Copy link
Contributor

Choose a reason for hiding this comment

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

handle the case where statusCodeAttributeValue is null

tags.Add(new KeyValuePair<string, object>(StandardMetricConstants.IsAutoCollectedKey, "True"));
tags.Add(new KeyValuePair<string, object>(StandardMetricConstants.IsSyntheticKey, "False"));
tags.Add(new KeyValuePair<string, object>(StandardMetricConstants.CloudRoleInstanceKey, StandardMetricResource.RoleInstance));
tags.Add(new KeyValuePair<string, object>(StandardMetricConstants.CloudRoleNameKey, StandardMetricResource.RoleName));
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be in resource.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Need to look in to this. Resource attributes are not converted to telemetry custom dimensions right now. And standard metric requires these to be at the dimension level.

Copy link
Contributor

Choose a reason for hiding this comment

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

if resource attributes are not converted, then its already a bug in MetricExporter, that must be separately addressed. Atleast the rolename/roleinstance part from resource should be set as dimensions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Atleast the rolename/roleinstance part from resource should be set as dimensions.

This gets converted to cloud role and role instance on telemetryItem level not as dimensions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Atleast the rolename/roleinstance part from resource should be set as dimensions.

This gets converted to cloud role and role instance on telemetryItem level not as dimensions.

yes got it. that is incorrect and should be fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we duplicate again in telemetry properties?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monitor - Exporter Monitor OpenTelemetry Exporter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants