Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .github/scripts/type-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
cd "$REPO_ROOT"

mypy --install-types --non-interactive \
packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python \
packages/aws-durable-execution-sdk-python/tests

mypy --install-types --non-interactive \
packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel \
packages/aws-durable-execution-sdk-python-otel/tests

# comment out this for now as there are many type check errors in this package
#mypy --install-types --non-interactive \
# packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing \
# packages/aws-durable-execution-sdk-python-testing/tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import re
from datetime import datetime, UTC

from opentelemetry.sdk.trace import IdGenerator, RandomIdGenerator
from opentelemetry.sdk.trace import RandomIdGenerator

HASH_LENGTH = 16
HASHED_ID_PATTERN = re.compile(r"^[0-9a-f]{16}$")
Expand Down Expand Up @@ -65,7 +65,7 @@ def operation_id_to_span_id(operation_id: str) -> int:
return int(hashed_operation_id, 16)


class DeterministicIdGenerator(IdGenerator):
class DeterministicIdGenerator(RandomIdGenerator):
Comment thread
wangyb-A marked this conversation as resolved.
"""An ID generator that produces deterministic span IDs when a pending
operation ID is set, and random IDs otherwise.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

from opentelemetry import trace, context
from opentelemetry.context import Context
from opentelemetry.sdk.trace import TracerProvider as SdkTracerProvider
from opentelemetry.sdk.trace.sampling import TraceIdRatioBased
from opentelemetry.trace import (
Tracer,
StatusCode,
SpanContext,
Span,
TracerProvider,
Link,
TraceFlags,
)
Expand Down Expand Up @@ -80,7 +80,7 @@ class DurableExecutionOtelPlugin(DurableInstrumentationPlugin):

def __init__(
self,
trace_provider: TracerProvider,
trace_provider: SdkTracerProvider,
context_extractor: ContextExtractor | None = None,
sampling_rate: float = 1.0,
instrument_name: str = DEFAULT_INSTRUMENT_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,17 @@ def wrapper(event: Any, context: LambdaContext) -> MutableMapping[str, Any]:
) as executor,
contextlib.closing(execution_state) as execution_state,
):
execution_operation = execution_state.get_execution_operation()

# execute the plugins
plugin_executor.on_invocation_start(
execution_arn=invocation_input.durable_execution_arn,
lambda_context=context,
execution_start_time=execution_state.get_execution_operation().start_timestamp,
execution_start_time=(
execution_operation.start_timestamp
if execution_operation is not None
else None
),
is_first_invocation=not execution_state.is_replaying(),
)
# Thread 1: Run background checkpoint processing
Expand Down
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ requires-python = ">=3.11"
workspace.members = ["packages/*"]

[tool.hatch.envs.test]
detached = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, I didn't know about this setting.

detached = true

In this case, I guess we could technically add this for all envs in the pyproject.toml?

workspace.members = ["packages/*"]
dependencies = [
"coverage[toml]",
Expand Down Expand Up @@ -38,11 +39,17 @@ markers = [
]

[tool.hatch.envs.types]
detached = true
workspace.members = ["packages/*"]
extra-dependencies = ["mypy>=1.0.0", "pytest", "boto3-stubs[lambda]"]
extra-dependencies = [
"mypy>=1.0.0",
"pytest",
"boto3-stubs[lambda]",
"opentelemetry-sdk>=1.20.0",
]

[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args}"
check = "bash .github/scripts/type-checks.sh"

[tool.hatch.envs.dev-core]
workspace.members = ["packages/aws-durable-execution-sdk-python"]
Expand Down
Loading