-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refer to _incubating values to fix attribute names on aio-pika
- Loading branch information
1 parent
23e66eb
commit ff997cd
Showing
3 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_required_attributes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from unittest import TestCase | ||
|
||
from opentelemetry.instrumentation.aio_pika.span_builder import SpanBuilder | ||
from opentelemetry.trace import Span, get_tracer | ||
|
||
# https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#messaging-attributes | ||
# use as example: opentelemetry-instrumentation-redis/tests/test_redis.py | ||
|
||
|
||
REQUIRED_SPAN_ATTRIBUTES = { | ||
"messaging.operation.type": { | ||
"type": str() | ||
}, | ||
"messaging.system": { | ||
"type": str() | ||
}, | ||
} | ||
CONDITIONALLY_REQUIRED_SPAN_ATTRIBUTES = { | ||
"error.type" : { | ||
"type": str() | ||
}, | ||
"messaging.batch.message_count" : { | ||
"type": int() | ||
}, | ||
"messaging.destination.anonymous" : { | ||
"type": bool() | ||
}, | ||
"messaging.destination.name" : { | ||
"type": str() | ||
}, | ||
"messaging.destination.template" : { | ||
"type": str() | ||
}, | ||
"messaging.destination.temporary" : { | ||
"type": bool() | ||
}, | ||
"server.address" : { | ||
"type": str() | ||
}, | ||
} | ||
|
||
|
||
class TestBuilder(TestCase): | ||
def test_consumer_required_attributes(self): | ||
builder = SpanBuilder(get_tracer(__name__)) | ||
builder.set_as_consumer() | ||
builder.set_destination("destination") | ||
span = builder.build() | ||
self.assertTrue(isinstance(span, Span)) | ||
|
||
def test_producer_required_attributes(self): | ||
builder = SpanBuilder(get_tracer(__name__)) | ||
builder.set_as_producer() | ||
builder.set_destination("destination") | ||
span = builder.build() | ||
self.assertTrue(isinstance(span, Span)) |