Skip to content

Commit

Permalink
Merge branch 'main' into feature/metric_status_code_span_not_recording
Browse files Browse the repository at this point in the history
  • Loading branch information
GonzaloGuasch authored Dec 26, 2024
2 parents adeb7e9 + 16eaec8 commit 966142e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Deprecated==1.2.14
iniconfig==2.0.0
packaging==24.0
pluggy==1.5.0
psycopg2-binary==2.9.9
psycopg2-binary==2.9.10
py-cpuinfo==9.0.0
pytest==7.4.4
tomli==2.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def tearDown(self):
with self.disable_logging():
CassandraInstrumentor().uninstrument()

@property
def _mocked_session(self):
return cassandra.cluster.Session(cluster=mock.Mock(), hosts=[])

def test_instrument_uninstrument(self):
instrumentation = CassandraInstrumentor()
instrumentation.instrument()
Expand All @@ -67,7 +71,7 @@ def test_instrumentor(
):
mock_create_response_future.return_value = mock.Mock()
mock_session_init.return_value = None
mock_connect.return_value = cassandra.cluster.Session()
mock_connect.return_value = self._mocked_session

CassandraInstrumentor().instrument()

Expand Down Expand Up @@ -100,7 +104,7 @@ def test_custom_tracer_provider(
):
mock_create_response_future.return_value = mock.Mock()
mock_session_init.return_value = None
mock_connect.return_value = cassandra.cluster.Session()
mock_connect.return_value = self._mocked_session

resource = resources.Resource.create({})
result = self.create_tracer_provider(resource=resource)
Expand All @@ -124,7 +128,7 @@ def test_instrument_connection_no_op_tracer_provider(
):
mock_create_response_future.return_value = mock.Mock()
mock_session_init.return_value = None
mock_connect.return_value = cassandra.cluster.Session()
mock_connect.return_value = self._mocked_session

tracer_provider = trace_api.NoOpTracerProvider()
CassandraInstrumentor().instrument(tracer_provider=tracer_provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

import logging
from typing import ContextManager, Optional, Tuple
from typing import TYPE_CHECKING, Optional, Tuple

from celery import registry # pylint: disable=no-name-in-module
from celery.app.task import Task

from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import Span

if TYPE_CHECKING:
from contextlib import AbstractContextManager

logger = logging.getLogger(__name__)

# Celery Context key
Expand Down Expand Up @@ -123,7 +128,7 @@ def attach_context(
task: Optional[Task],
task_id: str,
span: Span,
activation: ContextManager[Span],
activation: AbstractContextManager[Span],
token: Optional[object],
is_publish: bool = False,
) -> None:
Expand Down Expand Up @@ -171,7 +176,7 @@ def detach_context(task, task_id, is_publish=False) -> None:

def retrieve_context(
task, task_id, is_publish=False
) -> Optional[Tuple[Span, ContextManager[Span], Optional[object]]]:
) -> Optional[Tuple[Span, AbstractContextManager[Span], Optional[object]]]:
"""Helper to retrieve an active `Span`, `ContextManager` and context token
stored in a `Task` instance
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
amqp==5.2.0
asgiref==3.8.1
billiard==4.2.0
billiard==4.2.1
celery==5.3.6
click==8.1.7
click-didyoumean==0.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Deprecated==1.2.14
iniconfig==2.0.0
packaging==24.0
pluggy==1.5.0
psycopg==3.1.18
psycopg==3.2.2
py-cpuinfo==9.0.0
pytest==7.4.4
tomli==2.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Deprecated==1.2.14
iniconfig==2.0.0
packaging==24.0
pluggy==1.5.0
psycopg2==2.9.9
psycopg2==2.9.10
py-cpuinfo==9.0.0
pytest==7.4.4
tomli==2.0.1
Expand Down
2 changes: 2 additions & 0 deletions sdk-extension/opentelemetry-sdk-extension-aws/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## Version 2.1.0 (2024-12-24)

- Make ec2 resource detector silent when loaded outside AWS
([#3120](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3120))
- Make ecs and beanstalk resource detector silent when loaded outside AWS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "2.1.0.dev"
__version__ = "2.2.0.dev"

0 comments on commit 966142e

Please sign in to comment.