-
Notifications
You must be signed in to change notification settings - Fork 22
Genesis LLO Support in ADOT SDK #361
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
Merged
yiyuan-he
merged 16 commits into
aws-observability:genesis-dev-v2
from
yiyuan-he:genesis-llo-extraction-dev-v2
May 17, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
05c9607
loosen ADOT dependency requirements for Gen AI applications
yiyuan-he a29786a
configure trace and logs pipelines with agent observability flag
yiyuan-he f4e93d6
initial commit for llo handler
yiyuan-he 5a7d402
factor out body creation for gen ai events
yiyuan-he b6bc347
refactor: use single logs exporter and logs provider instance
yiyuan-he ea81f26
factor get gen ai event
yiyuan-he d242ef2
initial commit for llo handler unit tests
yiyuan-he 835cd3e
update doc strings in llo handler
yiyuan-he 6b6aaf7
add gen ai completion extraction and traceloop extraction + black for…
yiyuan-he d04f786
fix: function signature updates for upstream patches
yiyuan-he b34f569
tests: add additional unit tests to cover completion prompt and trace…
yiyuan-he b9b6edd
add support for openlit and llo span events
yiyuan-he a3c6251
add support for openinference in llo handler
yiyuan-he c869897
add unit tests for openlit and openinference support
yiyuan-he bd542b2
docstring updates
yiyuan-he 3f20228
refactoring
yiyuan-he File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
from typing_extensions import override | ||
|
||
from amazon.opentelemetry.distro._aws_attribute_keys import AWS_LOCAL_SERVICE | ||
from amazon.opentelemetry.distro._utils import is_agent_observability_enabled | ||
from amazon.opentelemetry.distro._aws_resource_attribute_configurator import get_service_attribute | ||
from amazon.opentelemetry.distro.always_record_sampler import AlwaysRecordSampler | ||
from amazon.opentelemetry.distro.attribute_propagating_span_processor_builder import ( | ||
|
@@ -27,7 +28,7 @@ | |
from amazon.opentelemetry.distro.sampler.aws_xray_remote_sampler import AwsXRayRemoteSampler | ||
from amazon.opentelemetry.distro.scope_based_exporter import ScopeBasedPeriodicExportingMetricReader | ||
from amazon.opentelemetry.distro.scope_based_filtering_view import ScopeBasedRetainingView | ||
from opentelemetry._logs import set_logger_provider | ||
from opentelemetry._logs import set_logger_provider, get_logger_provider | ||
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporter | ||
from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter as OTLPHttpOTLPMetricExporter | ||
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter | ||
|
@@ -91,6 +92,8 @@ | |
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT" | ||
OTEL_EXPORTER_OTLP_LOGS_HEADERS = "OTEL_EXPORTER_OTLP_LOGS_HEADERS" | ||
|
||
AGENT_OBSERVABILITY_ENABLED = "AGENT_OBSERVABILITY_ENABLED" | ||
|
||
AWS_TRACES_OTLP_ENDPOINT_PATTERN = r"https://xray\.([a-z0-9-]+)\.amazonaws\.com/v1/traces$" | ||
AWS_LOGS_OTLP_ENDPOINT_PATTERN = r"https://logs\.([a-z0-9-]+)\.amazonaws\.com/v1/logs$" | ||
|
||
|
@@ -160,16 +163,17 @@ def _initialize_components(): | |
sampler_name = _get_sampler() | ||
sampler = _custom_import_sampler(sampler_name, resource) | ||
|
||
logging_enabled = os.getenv(_OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED, "false") | ||
if logging_enabled.strip().lower() == "true": | ||
_init_logging(log_exporters, resource) | ||
|
||
Comment on lines
+166
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed order of pipeline initialization so we can pass the global logger provider instance to the span pipeline if |
||
_init_tracing( | ||
exporters=trace_exporters, | ||
id_generator=id_generator, | ||
sampler=sampler, | ||
resource=resource, | ||
) | ||
_init_metrics(metric_exporters, resource) | ||
logging_enabled = os.getenv(_OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED, "false") | ||
if logging_enabled.strip().lower() == "true": | ||
_init_logging(log_exporters, resource) | ||
|
||
|
||
def _init_logging( | ||
|
@@ -359,7 +363,15 @@ def _customize_span_exporter(span_exporter: SpanExporter, resource: Resource) -> | |
_logger.info("Detected using AWS OTLP Traces Endpoint.") | ||
|
||
if isinstance(span_exporter, OTLPSpanExporter): | ||
span_exporter = OTLPAwsSpanExporter(endpoint=traces_endpoint) | ||
if is_agent_observability_enabled(): | ||
logs_endpoint = os.getenv(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) | ||
logs_exporter = OTLPAwsLogExporter(endpoint=logs_endpoint) | ||
span_exporter = OTLPAwsSpanExporter( | ||
endpoint=traces_endpoint, | ||
logger_provider=get_logger_provider() | ||
) | ||
else: | ||
span_exporter = OTLPAwsSpanExporter(endpoint=traces_endpoint) | ||
|
||
else: | ||
_logger.warning( | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLO handling is gated behind this configuration. If false, then the ADOT SDK will have default behavior in span and logs pipelines.