Implement AwsSpanMetricsProcessor and MetricsAttributeGenerator #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this commit, we are implementing AwsSpanMetricsProcessor and AwsSpanMetricsProcessorBuilder. We needed to also implement the MetricsAttributeGenerator interface, since it is a dependency of AwsSpanMetricsProcessor, and we needed to implement a stub for AwsMetricsAttributeGenerator, since it is a dependency of AwsSpanMetricsProcessorBuilder. As much as possible, we are attempting to mirror the implementation of these clases found in https://github.com/aws-observability/aws-otel-java-instrumentation
General
@staticmethod
vs# pylint: disable=no-self-use
vs module method - The google style guide recommends against @staticmethod, but I have used it inMetricAttributeGenerator
as I don't see a good way to have a static class and inheritance.# pylint: disable=no-self-use
is used inAwsSpanMetricsProcessor
to maintain overridden, inherited methods. Otherwise, I've tried to use module methods where possible.AwsMetricAttributeGenerator
Methods:
generateMetricAttributeMapFromSpan
- Seegenerate_metric_attributes_dict_from_span
- Note that this will be properly implemented in next PR.AwsSpanMetricsProcessor
Constants:
NANOS_TO_MILLIS
- See_NANOS_TO_MILLIS
ERROR_CODE_LOWER_BOUND
- See_ERROR_CODE_LOWER_BOUND
ERROR_CODE_UPPER_BOUND
- See_ERROR_CODE_UPPER_BOUND
FAULT_CODE_LOWER_BOUND
- See_FAULT_CODE_LOWER_BOUND
FAULT_CODE_UPPER_BOUND
- See_FAULT_CODE_UPPER_BOUND
Methods:
AwsSpanMetricsProcessor
- See__init__
onStart
- Seeon_start
onEnd
- Seeon_end
recordErrorOrFault
- See_record_metrics
recordLatency
- See_record_error_or_fault
recordMetrics
- See_record_latency
create
- Not required, python doesn't have the concept of private methods/constructors, so it's not meaningful to abstract instantiation into a helper.isStartRequired
- Not part ofSpanProcessor
interface in Python.isEndRequired
- Not part ofSpanProcessor
interface in Python.shutdown
- Part ofSpanProcessor
interface. In Java, default implementations are provided, not so in Python. Impl matches Java behaviour (no-op).force_flush
- Part ofSpanProcessor
interface. In Java, default implementations are provided, not so in Python. Impl matches Java behaviour (no-op).AwsSpanMetricsProcessorBuilder
Constants:
ERROR
- See_ERROR
FAULT
- See_FAULT
LATENCY
- See_LATENCY
LATENCY_UNITS
- See_LATENCY_UNITS
DEFAULT_GENERATOR
- See_DEFAULT_GENERATOR
DEFAULT_SCOPE_NAME
- See_DEFAULT_SCOPE_NAME
Methods:
AwsSpanMetricsProcessorBuilder
- See__init__
setGenerator
- Seeset_generator
setScopeName
- Seeset_scope_name
build
- Seebuild
create
- Not required, python doesn't have the concept of private methods/constructors, so it's not meaningful to abstract instantiation into a helper.MetricAttributeGenerator
Constants:
SERVICE_METRIC
- See_SERVICE_METRIC
DEPENDENCY_METRIC
- See_DEPENDENCY_METRIC
Methods:
generateMetricAttributeMapFromSpan
- Seegenerate_metric_attributes_dict_from_span
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.