Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Various fixes #13

Merged
merged 1 commit into from
Jan 11, 2024
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
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ profile=black
multi_line_output=3
skip=target
skip_glob=**/gen/*,.venv*/*,venv*/*,.tox/*
known_first_party=opentelemetry
known_first_party=opentelemetry,amazon
known_third_party=psutil,pytest
6 changes: 3 additions & 3 deletions aws-opentelemetry-distro/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ dependencies = [
test = []

[project.entry-points.opentelemetry_configurator]
aws_configurator = "opentelemetry.distro.aws_opentelemetry_configurator:AwsOpenTelemetryConfigurator"
aws_configurator = "amazon.opentelemetry.distro.aws_opentelemetry_configurator:AwsOpenTelemetryConfigurator"

[project.entry-points.opentelemetry_distro]
aws_distro = "opentelemetry.distro.aws_opentelemetry_distro:AwsOpenTelemetryDistro"
aws_distro = "amazon.opentelemetry.distro.aws_opentelemetry_distro:AwsOpenTelemetryDistro"

[project.urls]
Homepage = "https://github.com/aws-observability/aws-otel-python-instrumentation/tree/main/aws-opentelemetry-distro"
Expand All @@ -39,4 +39,4 @@ include = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/amazon/opentelemetry"]
packages = ["src/amazon"]
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from metric_attribute_generator import MetricAttributeGenerator

from amazon.opentelemetry.distro.metric_attribute_generator import MetricAttributeGenerator
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import BoundedAttributes, ReadableSpan


class AwsMetricAttributeGenerator(MetricAttributeGenerator):
class _AwsMetricAttributeGenerator(MetricAttributeGenerator):
"""AwsMetricAttributeGenerator generates specific metric attributes for incoming and outgoing traffic.

AwsMetricAttributeGenerator generates very specific metric attributes based on low-cardinality span and resource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from opentelemetry.sdk._configuration import _BaseConfigurator
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from logging import getLogger

from opentelemetry.instrumentation.distro import BaseDistro
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
from typing import Optional

from metric_attribute_generator import MetricAttributeGenerator
from typing_extensions import override

from amazon.opentelemetry.distro.metric_attribute_generator import MetricAttributeGenerator
from opentelemetry.context import Context
from opentelemetry.metrics import Histogram
from opentelemetry.sdk.resources import Resource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from aws_metric_attribute_generator import AwsMetricAttributeGenerator
from aws_span_metrics_processor import AwsSpanMetricsProcessor
from metric_attribute_generator import MetricAttributeGenerator

from amazon.opentelemetry.distro._aws_metric_attribute_generator import _AwsMetricAttributeGenerator
from amazon.opentelemetry.distro.aws_span_metrics_processor import AwsSpanMetricsProcessor
from amazon.opentelemetry.distro.metric_attribute_generator import MetricAttributeGenerator
from opentelemetry.sdk.metrics import Histogram, Meter, MeterProvider
from opentelemetry.sdk.resources import Resource

Expand All @@ -14,7 +13,7 @@
_LATENCY_UNITS: str = "Milliseconds"

# Defaults
_DEFAULT_GENERATOR: MetricAttributeGenerator = AwsMetricAttributeGenerator()
_DEFAULT_GENERATOR: MetricAttributeGenerator = _AwsMetricAttributeGenerator()
_DEFAULT_SCOPE_NAME: str = "AwsSpanMetricsProcessor"


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase

from amazon.opentelemetry.distro._aws_metric_attribute_generator import _AwsMetricAttributeGenerator


class TestAwsMetricAttributeGenerator(TestCase):
def test_basic(self):
generator: _AwsMetricAttributeGenerator = _AwsMetricAttributeGenerator()
self.assertEqual(generator.generate_metric_attributes_dict_from_span(None, None), {})
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase

from opentelemetry.distro.aws_opentelemetry_configurator import AwsOpenTelemetryConfigurator, AwsTracerProvider
from amazon.opentelemetry.distro.aws_opentelemetry_configurator import AwsOpenTelemetryConfigurator, AwsTracerProvider


class TestAwsOpenTelemetryConfigurator(TestCase):
# pylint: disable=no-self-use
def test_default_configuration(self):
configurator = AwsOpenTelemetryConfigurator()
configurator.configure()
trace_provider = configurator.get_trace_provider()
assert isinstance(trace_provider, AwsTracerProvider)
self.assertTrue(isinstance(trace_provider, AwsTracerProvider))
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase

from pkg_resources import DistributionNotFound, require
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase

from amazon.opentelemetry.distro.aws_span_metrics_processor import AwsSpanMetricsProcessor


class TestAwsSpanMetricsProcessor(TestCase):
def test_basic(self):
processor: AwsSpanMetricsProcessor = AwsSpanMetricsProcessor(None, None, None, None, None)
self.assertTrue(processor.force_flush)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from unittest import TestCase

from amazon.opentelemetry.distro.aws_span_metrics_processor_builder import AwsSpanMetricsProcessorBuilder


class TestAwsSpanMetricsProcessorBuilder(TestCase):
def test_basic(self):
builder: AwsSpanMetricsProcessorBuilder = AwsSpanMetricsProcessorBuilder(None, None)
self.assertIs(builder.set_scope_name("test"), builder)
Loading