-
Notifications
You must be signed in to change notification settings - Fork 130
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 new components to allow for generating metrics from 100% of spans without impacting sampling #802
Conversation
aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGenerator.java
Outdated
Show resolved
Hide resolved
e3c15f4
to
3c05ce9
Compare
Merge from main.
… without impacting sampling In this commit, we are adding several new components to the awsxray package: * AlwaysRecordSampler - A simple aggregate sampler that always ensures spans are "recorded" (i.e. sent to span processors). This allows us to generate metrics from 100% of spans without impacting true sampling rate. * AwsSpanMetricsProcessor - A span processor that will generate specific metrics pertaining to latency, faults, and errors. Relies on a MetricAttributeGenerator to build attributes for the metrics. * AwsMetricAttributesSpanExporter - A span exporter that relies on MetricAttributeGenerator to wraps metric attributes around the span attributes before passing the span to a delegate span exporter for export. * MetricAttributeGenerator - A generic interface for components that consumes spans and resources and produces attributes for metrics generated from these spans. * AwsMetricAttributeGenerator - A specific implementation of MetricAttributeGenerator, used for generating AWS-specific attributes. * AwsSpanMetricsProcessorBuilder - A builder class for AwsSpanMetricsProcessor. * AwsMetricAttributesSpanExporterBuilder - A builder class for AwsMetricAttributesSpanExporter. Related issue: open-telemetry#789
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of small comments. Otherwise LGTM.
aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGenerator.java
Show resolved
Hide resolved
aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessor.java
Show resolved
Hide resolved
@trask - PR is ready for your review. |
if (isKeyPresent(span, PEER_SERVICE) && !isKeyPresent(span, AWS_REMOTE_SERVICE)) { | ||
setRemoteService(span, builder, PEER_SERVICE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a callout but not a blocker - is it expected that we have added the log entry by logUnknownAttribute(AWS_REMOTE_SERVICE, span);
but the RemoteService
is actually set properly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I see what you mean, it's a little bit odd. I think for now it's ok. We plan to revise a bit of this logic in future, and it's not totally unreasonable for the time being. We don't expect PEER_SERVICE
to be frequently applied. Will make a note for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ty!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ty!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ty!
Hi @trask , just kindly check if you can help to take a look this PR. |
… as Segment name (#22835) XRayExporter will be extended to support the new AWS specific service name attributes changed in open-telemetry/opentelemetry-java-contrib#802 for X-Ray trace segment name. The new Span attribute aws.local.service will be set as Server kind segment name, and aws.remote.service attribute will set as Client kind subsegment name if the attribute exists.
… as Segment name (open-telemetry#22835) XRayExporter will be extended to support the new AWS specific service name attributes changed in open-telemetry/opentelemetry-java-contrib#802 for X-Ray trace segment name. The new Span attribute aws.local.service will be set as Server kind segment name, and aws.remote.service attribute will set as Client kind subsegment name if the attribute exists.
… as Segment name (open-telemetry#22835) XRayExporter will be extended to support the new AWS specific service name attributes changed in open-telemetry/opentelemetry-java-contrib#802 for X-Ray trace segment name. The new Span attribute aws.local.service will be set as Server kind segment name, and aws.remote.service attribute will set as Client kind subsegment name if the attribute exists.
Description:
We wish to generate key metrics from OTEL auto-instrumented spans. I had previously engaged the community to discuss this, and after some conversations, decided that the best approach would be to implement a Sampler and a Span Processor to the
contrib
repositories.The major requirements for our project are as follows:
http.route
).To meet these goals, we have developed components which we wish to contribute to the OTEL community:
AlwaysRecordSampler
.shouldSample()
will call the root sampler and, if theSampleDecision
isRECORD_AND_SAMPLE
orRECORD_ONLY
, it simply returns the result. However, if theSampleDecision
isDROP
, it will instead create a new result withSampleDecision
set toRECORD_ONLY
(all other result behaviour unchanged).MetricAttributeGenerator
AwsMetricAttributeGenerator
to produce metric attributes specific to our usecase.AwsSpanMetricsProcessor
.AwsSpanMetricsProcessorBuilder
) with metering instruments, a MetricAttributeGenerator and a resource.onEnd()
, which will:AwsMetricAttributesSpanExporter
.AwsMetricAttributesSpanExporterBuilder
) with a MetricAttributeGenerator, a Resource, and a delegate SpanExporter.export()
, which will:SpanData
identical to the original span, but with metric attributes embedded into span attributes.export
method.Existing Issue(s):
#789
Testing:
./gradlew assemble
Passes./gradlew spotlessCheck
PassesDocumentation:
These are independent components that will require configuration in the TracerProvider. We will create a document to describe the usage once it is ready for distribution.
Outstanding items:
AwsMetricAttributeGenerator
in future, but for now these are sufficient.