Skip to content

Commit cad2b44

Browse files
committed
typecheck fixes
1 parent e240e09 commit cad2b44

File tree

15 files changed

+65
-65
lines changed

15 files changed

+65
-65
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ include = [
206206
"instrumentation-genai/opentelemetry-instrumentation-weaviate",
207207
"util/opentelemetry-util-genai",
208208
"exporter/opentelemetry-exporter-credential-provider-gcp",
209-
"sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler",
209+
"sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace",
210210
]
211211
# We should also add type hints to the test suite - It helps on finding bugs.
212212
# We are excluding for now because it's easier, and more important to add to the instrumentation packages.

sdk-extension/opentelemetry-sdk-extension-aws/pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ classifiers = [
2525
"Programming Language :: Python :: 3.13",
2626
]
2727
dependencies = [
28-
"opentelemetry-api ~= 1.23",
29-
"opentelemetry-sdk ~= 1.23",
30-
"opentelemetry-instrumentation ~= 0.44b0",
31-
"opentelemetry-semantic-conventions ~= 0.44b0",
28+
"opentelemetry-api ~= 1.26",
29+
"opentelemetry-sdk ~= 1.26",
30+
"opentelemetry-instrumentation ~= 0.47b0",
31+
"opentelemetry-semantic-conventions ~= 0.47b0",
3232
"requests ~= 2.28",
3333
]
3434

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_aws_xray_sampling_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
DEFAULT_SAMPLING_PROXY_ENDPOINT = "http://127.0.0.1:2000"
3838

3939

40-
class _AwsXRaySamplingClient:
40+
class _AwsXRaySamplingClient: # pyright: ignore[reportUnusedClass]
4141
def __init__(
4242
self,
4343
endpoint: str = DEFAULT_SAMPLING_PROXY_ENDPOINT,

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_clock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import datetime
2020

2121

22-
class _Clock:
22+
class _Clock: # pyright: ignore[reportUnusedClass]
2323
def __init__(self):
2424
self.__datetime = datetime.datetime
2525

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_fallback_sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from opentelemetry.util.types import Attributes
3838

3939

40-
class _FallbackSampler(Sampler):
40+
class _FallbackSampler(Sampler): # pyright: ignore[reportUnusedClass]
4141
def __init__(self, clock: _Clock):
4242
self.__rate_limiting_sampler = _RateLimitingSampler(1, clock)
4343
self.__fixed_rate_sampler = TraceIdRatioBased(0.05)

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_matcher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
import re
2222

23-
from opentelemetry.semconv.resource import CloudPlatformValues
23+
from opentelemetry.semconv._incubating.attributes.cloud_attributes import (
24+
CloudPlatformValues,
25+
)
2426
from opentelemetry.util.types import Attributes, AttributeValue
2527

2628
cloud_platform_mapping = {

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_rate_limiter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from opentelemetry.sdk.extension.aws.trace.sampler._clock import _Clock
2424

2525

26-
class _RateLimiter:
26+
class _RateLimiter: # pyright: ignore[reportUnusedClass]
2727
def __init__(self, max_balance_in_seconds: int, quota: int, clock: _Clock):
2828
# max_balance_in_seconds is usually 1
2929
# pylint: disable=invalid-name

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_rate_limiting_sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from opentelemetry.util.types import Attributes
3333

3434

35-
class _RateLimitingSampler(Sampler):
35+
class _RateLimitingSampler(Sampler): # pyright: ignore[reportUnusedClass]
3636
def __init__(self, quota: int, clock: _Clock):
3737
self.__quota = quota
3838
self.__reservoir = _RateLimiter(1, quota, clock)

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_rule_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
DEFAULT_TARGET_POLLING_INTERVAL_SECONDS = 10
5151

5252

53-
class _RuleCache:
53+
class _RuleCache: # pyright: ignore[reportUnusedClass]
5454
def __init__(
5555
self,
5656
resource: Resource,

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_sampling_rule_applier.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,27 @@
4848
SamplingResult,
4949
TraceIdRatioBased,
5050
)
51-
from opentelemetry.semconv.resource import (
51+
from opentelemetry.semconv._incubating.attributes.aws_attributes import (
52+
AWS_ECS_CONTAINER_ARN,
53+
)
54+
from opentelemetry.semconv._incubating.attributes.cloud_attributes import (
55+
CLOUD_PLATFORM,
56+
CLOUD_RESOURCE_ID,
5257
CloudPlatformValues,
53-
ResourceAttributes,
5458
)
55-
from opentelemetry.semconv.trace import SpanAttributes
59+
from opentelemetry.semconv._incubating.attributes.http_attributes import (
60+
HTTP_REQUEST_METHOD,
61+
)
62+
from opentelemetry.semconv._incubating.attributes.server_attributes import (
63+
SERVER_ADDRESS,
64+
)
65+
from opentelemetry.semconv._incubating.attributes.service_attributes import (
66+
SERVICE_NAME,
67+
)
68+
from opentelemetry.semconv._incubating.attributes.url_attributes import (
69+
URL_FULL,
70+
URL_PATH,
71+
)
5672
from opentelemetry.trace import Link, SpanKind
5773
from opentelemetry.trace.span import TraceState
5874
from opentelemetry.util.types import Attributes, AttributeValue
@@ -199,27 +215,24 @@ def matches(self, resource: Resource, attributes: Attributes) -> bool:
199215
# If `URL_PATH/URL_FULL/HTTP_REQUEST_METHOD/SERVER_ADDRESS` are not populated
200216
# also check `HTTP_TARGET/HTTP_URL/HTTP_METHOD/HTTP_HOST` respectively as backup
201217
url_path = attributes.get(
202-
SpanAttributes.URL_PATH,
203-
attributes.get(SpanAttributes.HTTP_TARGET, None),
218+
URL_PATH,
219+
attributes.get("http.target", None),
204220
)
205221
url_full = attributes.get(
206-
SpanAttributes.URL_FULL,
207-
attributes.get(SpanAttributes.HTTP_URL, None),
222+
URL_FULL,
223+
attributes.get("http.url", None),
208224
)
209225
http_request_method = attributes.get(
210-
SpanAttributes.HTTP_REQUEST_METHOD,
211-
attributes.get(SpanAttributes.HTTP_METHOD, None),
226+
HTTP_REQUEST_METHOD,
227+
attributes.get("http.method", None),
212228
)
213229
server_address = attributes.get(
214-
SpanAttributes.SERVER_ADDRESS,
215-
attributes.get(SpanAttributes.HTTP_HOST, None),
230+
SERVER_ADDRESS,
231+
attributes.get("http.host", None),
216232
)
217233

218234
# Resource shouldn't be none as it should default to empty resource
219-
if resource is not None:
220-
service_name = resource.attributes.get(
221-
ResourceAttributes.SERVICE_NAME, ""
222-
)
235+
service_name = resource.attributes.get(SERVICE_NAME, "")
223236

224237
# target may be in url
225238
if url_path is None and isinstance(url_full, str):
@@ -263,12 +276,7 @@ def __create_reservoir_sampler(self, quota: int) -> Sampler:
263276

264277
# pylint: disable=no-self-use
265278
def __get_service_type(self, resource: Resource) -> str:
266-
if resource is None:
267-
return ""
268-
269-
cloud_platform = resource.attributes.get(
270-
ResourceAttributes.CLOUD_PLATFORM, None
271-
)
279+
cloud_platform = resource.attributes.get(CLOUD_PLATFORM, None)
272280
if not isinstance(cloud_platform, str):
273281
return ""
274282

@@ -277,15 +285,11 @@ def __get_service_type(self, resource: Resource) -> str:
277285
def __get_arn(
278286
self, resource: Resource, attributes: Attributes
279287
) -> AttributeValue:
280-
if resource is not None:
281-
arn = resource.attributes.get(
282-
ResourceAttributes.AWS_ECS_CONTAINER_ARN, None
283-
)
284-
if arn is not None:
285-
return arn
288+
arn = resource.attributes.get(AWS_ECS_CONTAINER_ARN, None)
289+
if arn is not None:
290+
return arn
286291
if (
287-
resource is not None
288-
and resource.attributes.get(ResourceAttributes.CLOUD_PLATFORM)
292+
resource.attributes.get(CLOUD_PLATFORM)
289293
== CloudPlatformValues.AWS_LAMBDA.value
290294
):
291295
return self.__get_lambda_arn(resource, attributes)
@@ -295,20 +299,20 @@ def __get_lambda_arn(
295299
self, resource: Resource, attributes: Attributes
296300
) -> AttributeValue:
297301
arn = resource.attributes.get(
298-
ResourceAttributes.CLOUD_RESOURCE_ID,
299-
resource.attributes.get(ResourceAttributes.FAAS_ID, None),
302+
CLOUD_RESOURCE_ID,
303+
resource.attributes.get("faas.id", None),
300304
)
301305
if arn is not None:
302306
return arn
303307

304308
if attributes is None:
305309
return ""
306310

307-
# Note from `SpanAttributes.CLOUD_RESOURCE_ID`:
311+
# Note from `CLOUD_RESOURCE_ID`:
308312
# "On some cloud providers, it may not be possible to determine the full ID at startup,
309313
# so it may be necessary to set cloud.resource_id as a span attribute instead."
310314
arn = attributes.get(
311-
SpanAttributes.CLOUD_RESOURCE_ID, attributes.get("faas.id", None)
315+
CLOUD_RESOURCE_ID, attributes.get("faas.id", None)
312316
)
313317
if arn is not None:
314318
return arn

0 commit comments

Comments
 (0)