Skip to content

Commit b1fcdb3

Browse files
authored
Changing span unsampled flag to be sampled flag (#260)
*Issue #, if available:* Previously we use `aws.trace.flag.unsampled` mark the span is unsampled. The change updates this attribute to be `aws.trace.flag.sampled`. *Description of changes:* #### span is unsampled: If span has no span attribute aws.trace.flag.sampled , value type is boolean and value is false. #### span is sampled: If span has no span attribute aws.trace.flag.sampled or span has span attribute aws.trace.flag.sampled , value type is boolean and value is true, or span has span attribute aws.trace.flag.sampled , value type is NOT boolean By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 2064f2d commit b1fcdb3

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/_aws_attribute_keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
AWS_REMOTE_RESOURCE_IDENTIFIER: str = "aws.remote.resource.identifier"
1212
AWS_SDK_DESCENDANT: str = "aws.sdk.descendant"
1313
AWS_CONSUMER_PARENT_SPAN_KIND: str = "aws.consumer.parent.span.kind"
14-
AWS_TRACE_FLAG_UNSAMPLED: str = "aws.trace.flag.unsampled"
14+
AWS_TRACE_FLAG_SAMPLED: str = "aws.trace.flag.sampled"
1515

1616
# AWS_#_NAME attributes are not supported in python as they are not part of the Semantic Conventions.
1717
# TODO:Move to Semantic Conventions when these attributes are added.

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_batch_unsampled_span_processor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@
33
import logging
44
from typing import Optional
55

6-
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_TRACE_FLAG_UNSAMPLED
6+
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_TRACE_FLAG_SAMPLED
77
from opentelemetry.context import Context
88
from opentelemetry.sdk.trace import ReadableSpan, Span
99
from opentelemetry.sdk.trace.export import BatchSpanProcessor as BaseBatchSpanProcessor
1010

1111
logger = logging.getLogger(__name__)
1212

13-
SPANUNSAMPLED_FLAG = "OTEL_AWS_APP_SIGNALS_ENABLED"
14-
1513

1614
class BatchUnsampledSpanProcessor(BaseBatchSpanProcessor):
1715

1816
# pylint: disable=no-self-use
1917
def on_start(self, span: Span, parent_context: Optional[Context] = None) -> None:
2018
if not span.context.trace_flags.sampled:
21-
span.set_attribute(AWS_TRACE_FLAG_UNSAMPLED, True)
19+
span.set_attribute(AWS_TRACE_FLAG_SAMPLED, False)
2220

2321
def on_end(self, span: ReadableSpan) -> None:
2422
if span.context.trace_flags.sampled:

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_batch_unsampled_span_processor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest import TestCase
44
from unittest.mock import MagicMock, patch
55

6-
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_TRACE_FLAG_UNSAMPLED
6+
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_TRACE_FLAG_SAMPLED
77
from amazon.opentelemetry.distro.aws_batch_unsampled_span_processor import BatchUnsampledSpanProcessor
88
from opentelemetry.trace import TraceFlags
99

@@ -43,7 +43,7 @@ def test_on_end_not_sampled(self, mock_span_class):
4343
self.processor.on_end(mock_span2)
4444

4545
self.assertEqual(len(self.processor.queue), 1)
46-
self.assertIn(AWS_TRACE_FLAG_UNSAMPLED, mock_span1.set_attribute.call_args_list[0][0][0])
46+
self.assertIn(AWS_TRACE_FLAG_SAMPLED, mock_span1.set_attribute.call_args_list[0][0][0])
4747

4848
self.processor.shutdown()
4949
mock_span2 = mock_span_class.return_value

lambda-layer/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ cd lambda-layer
4747

4848
Once the script has successfully run, you will see the deployed Lambda sample app in your AWS account. You can trigger the
4949
Lambda function and view the traces and metrics through the AWS CloudWatch Console.
50+
51+
## Configuration
52+
53+
By default the layer enable botocore and aws-lambda instrumentation libraries only for better Lambda cold start performance. To
54+
enable all opentelemetry python
55+
supported libraries you can set environment variable `OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=none`. Refer to details in
56+
[OpenTelemetry Python Disabling Specific Instrumentations](Disabling Specific Instrumentations)

0 commit comments

Comments
 (0)