Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added aio-pika instrumentation #1095

Merged
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9ccb612
Added aio-pika instrumentation
ofek1weiss May 18, 2022
0ea7f7c
Merge branch 'main' into feature/aio-pika-instrumentation
srikanthccv May 18, 2022
191d803
Ran lint
ofek1weiss May 18, 2022
5cc1ccc
Merge branch 'feature/aio-pika-instrumentation' of github.com:ofek1we…
ofek1weiss May 18, 2022
ab4d65c
Added aio-pika to changelog
ofek1weiss May 18, 2022
b99668f
Fixed according to flake8
ofek1weiss May 19, 2022
7a2e0f2
Ran tox -e generate
ofek1weiss May 19, 2022
5f3865f
Added ofek1weiss to component owners
ofek1weiss May 22, 2022
0e8004f
fixed readme according to cr
ofek1weiss May 22, 2022
ee480d7
Moved _DEFAULT_ATTRIBUTES to be top level
ofek1weiss May 22, 2022
3d54438
Changed to use default getter
ofek1weiss May 22, 2022
a30aafe
Updated version
ofek1weiss May 22, 2022
a30d48a
Updated version
ofek1weiss May 31, 2022
0d22a64
Moved changelog entry to unreleased
ofek1weiss May 31, 2022
43973fc
Changed imports to be absolute
ofek1weiss May 31, 2022
18ad348
Small semantic changes
ofek1weiss May 31, 2022
5262a93
fixed tracer usage
ofek1weiss May 31, 2022
b589163
Fixed tests
ofek1weiss May 31, 2022
c2c557a
Merge branch 'main' into feature/aio-pika-instrumentation
ofek1weiss May 31, 2022
68deeac
Change to work using wrapt
ofek1weiss Jun 2, 2022
b8de8ef
Merge branch 'feature/aio-pika-instrumentation' of github.com:ofek1we…
ofek1weiss Jun 2, 2022
302e6eb
Merge branch 'main' into feature/aio-pika-instrumentation
srikanthccv Jun 2, 2022
521cd13
Merge branch 'main' into feature/aio-pika-instrumentation
srikanthccv Jun 5, 2022
7195712
Resolved conflicts
ofek1weiss Jun 24, 2022
1f765b8
Fixed linting
ofek1weiss Jun 24, 2022
83f71e7
Fixed changelog conflict
ofek1weiss Jun 24, 2022
4b333b3
Pulled main
ofek1weiss Jun 26, 2022
05e8780
Merge branch 'main' into feature/aio-pika-instrumentation
ocelotl Jun 27, 2022
6fb0452
Updated core repo sha
ofek1weiss Jun 27, 2022
bb2c608
Merge branch 'main' into feature/aio-pika-instrumentation
ocelotl Jun 29, 2022
690e813
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
ofek1weiss Jul 1, 2022
fb9f15a
Changed opentelemetry-test-utils requirement to be the newest
ofek1weiss Jul 1, 2022
10e4f53
Merge branch 'feature/aio-pika-instrumentation' of github.com:ofek1we…
ofek1weiss Jul 1, 2022
9bc4f23
Fixed readme format
ofek1weiss Jul 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed according to flake8
  • Loading branch information
ofek1weiss committed May 19, 2022
commit b99668f9a4e2dd9d3f8ee2a80d81a9374825cce9
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
# limitations under the License.
from typing import Any, Callable, Optional

from aio_pika import Channel, Queue, RobustQueue, connect
from aio_pika import Queue, RobustQueue
from aio_pika.abc import AbstractIncomingMessage
from aio_pika.queue import ConsumerTag

Original file line number Diff line number Diff line change
@@ -34,34 +34,34 @@ def __init__(self):
self._operation: MessagingOperationValues = None
self._kind: SpanKind = None
self._destination: str = None

def set_as_producer(self):
self._kind = SpanKind.PRODUCER

def set_as_consumer(self):
self._kind = SpanKind.CONSUMER

def set_operation(self, operation: MessagingOperationValues):
self._operation = operation

def set_destination(self, destination: str):
self._destination = destination
self._attributes[SpanAttributes.MESSAGING_DESTINATION] = destination

def set_channel(self, channel: AbstractChannel):
url = channel.connection.connection.url
self._attributes.update({
SpanAttributes.NET_PEER_NAME: url.host,
SpanAttributes.NET_PEER_PORT: url.port
})

def set_message(self, message: AbstractMessage):
properties = message.properties
if properties.message_id:
self._attributes[SpanAttributes.MESSAGING_MESSAGE_ID] = properties.message_id
if properties.correlation_id:
self._attributes[SpanAttributes.MESSAGING_CONVERSATION_ID] = properties.correlation_id

def build(self) -> Optional[Span]:
if context.get_value('suppress_instrumentation') or context.get_value(context._SUPPRESS_INSTRUMENTATION_KEY):
return None
@@ -78,7 +78,7 @@ def build(self) -> Optional[Span]:
else:
span.set_attribute(SpanAttributes.MESSAGING_TEMP_DESTINATION, True)
return span

def _generate_span_name(self) -> str:
operation_value = self._operation.value if self._operation else 'send'
return f'{self._destination} {operation_value}'
Original file line number Diff line number Diff line change
@@ -12,19 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio
from argparse import Namespace
from typing import Type
from unittest import TestCase, mock

from aio_pika import Exchange
from yarl import URL

from opentelemetry.instrumentation.aio_pika.instrumented_exchange import (
InstrumentedExchange,
RobustInstrumentedExchange,
)
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import NonRecordingSpan, Span
from opentelemetry.trace import NonRecordingSpan

from .consts import (
CHANNEL,
Original file line number Diff line number Diff line change
@@ -12,19 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio
from argparse import Namespace
from typing import Type
from unittest import TestCase, mock

from aio_pika import Queue
from yarl import URL

from opentelemetry.instrumentation.aio_pika.instrumented_queue import (
InstrumentedQueue,
RobustInstrumentedQueue,
)
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import NonRecordingSpan, Span
from opentelemetry.trace import NonRecordingSpan

from .consts import (
CHANNEL,
@@ -35,7 +33,6 @@
MESSAGE_ID,
MESSAGING_SYSTEM,
QUEUE_NAME,
ROUTING_KEY,
SERVER_HOST,
SERVER_PORT,
)
Original file line number Diff line number Diff line change
@@ -24,13 +24,13 @@ def test_build(self):
builder.set_destination('destination')
span = builder.build()
self.assertTrue(isinstance(span, Span))

def test_no_destination(self):
builder = SpanBuilder()
builder.set_as_consumer()
with self.assertRaises(AssertionError):
builder.build()

def test_no_kind(self):
builder = SpanBuilder()
builder.set_destination('destination')