-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AWS Distro with to create a basic file structure. Add unit tests workflow.
- Loading branch information
Showing
11 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
AWS OpenTelemetry Distro | ||
======================================== | ||
|
||
Installation | ||
------------ | ||
|
||
:: | ||
|
||
pip install aws-opentelemetry-distro | ||
|
||
|
||
This package provides AWS OpenTelemetry Python Distro, which allows for auto-instrumentation of Python applications. | ||
|
||
References | ||
---------- | ||
|
||
* `OpenTelemetry Project <https://opentelemetry.io/>`_ | ||
* `Example using opentelemetry-distro <https://opentelemetry.io/docs/instrumentation/python/distro/>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "aws-opentelemetry-distro" | ||
dynamic = ["version"] | ||
description = "AWS OpenTelemetry Python Distro" | ||
readme = "README.rst" | ||
license = "Apache-2.0" | ||
requires-python = ">=3.7" | ||
|
||
dependencies = [ | ||
"opentelemetry-api ~= 1.12", | ||
"opentelemetry-instrumentation == 0.43b0", | ||
"opentelemetry-sdk ~= 1.13", | ||
"opentelemetry-sdk-extension-aws ~= 2.0.1" | ||
] | ||
|
||
[project.optional-dependencies] | ||
test = [] | ||
|
||
[project.entry-points.opentelemetry_configurator] | ||
aws_configurator = "opentelemetry.distro.aws_opentelemetry_configurator:AwsOpenTelemetryConfigurator" | ||
|
||
[project.entry-points.opentelemetry_distro] | ||
aws_distro = "opentelemetry.distro.aws_opentelemetry_distro:AwsOpenTelemetryDistro" | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/aws-observability/aws-otel-python-instrumentation/tree/main/opentelemetry-distro" | ||
|
||
[tool.hatch.version] | ||
path = "src/amazon/opentelemetry/distro/version.py" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
include = [ | ||
"/src", | ||
"/tests", | ||
] | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["src/amazon/opentelemetry"] |
30 changes: 30 additions & 0 deletions
30
opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_configurator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# 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.trace import set_tracer_provider | ||
|
||
|
||
class AwsTracerProvider(TracerProvider): | ||
def __init__( | ||
self | ||
): | ||
pass | ||
# TODO: | ||
# 1. Add SpanMetricsProcessor to generate AppSignal metrics from spans and exports them | ||
# 2. Add AttributePropagatingSpanProcessor to propagate span attributes from parent to child | ||
# 3. Add AwsMetricAttributesSpanExporter to add more attributes to all spans. | ||
# 4. Add AlwaysRecordSampler to record all spans. | ||
|
||
|
||
class AwsOpenTelemetryConfigurator(_BaseConfigurator): | ||
def __init__(self): | ||
self.trace_provider = None | ||
|
||
def _configure(self, **kwargs): | ||
self.trace_provider = AwsTracerProvider() | ||
set_tracer_provider(self.trace_provider) | ||
|
||
def get_trace_provider(self): | ||
return self.trace_provider |
13 changes: 13 additions & 0 deletions
13
opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_distro.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 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 | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class AwsOpenTelemetryDistro(BaseDistro): | ||
def _configure(self, **kwargs): | ||
super(AwsOpenTelemetryDistro, self)._configure() |
4 changes: 4 additions & 0 deletions
4
opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
__version__ = "0.0.1" |
18 changes: 18 additions & 0 deletions
18
...elemetry-distro/tests/amazon/opentelemetry/distro/test_aws_opentelementry_configurator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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, | ||
) | ||
|
||
|
||
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) |
14 changes: 14 additions & 0 deletions
14
opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_opentelemetry_distro.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 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 | ||
|
||
|
||
class TestAwsOpenTelemetryDistro(TestCase): | ||
def test_package_available(self): | ||
try: | ||
require(["aws-opentelemetry-distro"]) | ||
except DistributionNotFound: | ||
self.fail("aws-opentelemetry-distro not installed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters