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

feat: http endpoint filtering for aws resources #653

Merged
Show file tree
Hide file tree
Changes from 2 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
21 changes: 20 additions & 1 deletion src/lumigo_opentelemetry/instrumentations/botocore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from typing import Dict, Any

from lumigo_opentelemetry.libs.general_utils import lumigo_safe_execute
from lumigo_opentelemetry.resources.span_processor import set_span_skip_export
from opentelemetry.trace import Span, SpanKind

from lumigo_opentelemetry.instrumentations import AbstractInstrumentor
from lumigo_opentelemetry.instrumentations.botocore.parsers import AwsParser
from lumigo_opentelemetry.libs.sampling import should_sample
from lumigo_opentelemetry.utils.span_utils import safe_get_span_attributes


class BotoCoreInstrumentorWrapper(AbstractInstrumentor):
Expand All @@ -21,8 +29,19 @@ def install_instrumentation(self) -> None:

BotocoreInstrumentor().instrument(
request_hook=AwsParser.request_hook,
response_hook=AwsParser.response_hook,
response_hook=filtered_resource_hook,
)


def filtered_resource_hook(
span: Span, service_name: str, operation_name: str, result: Dict[Any, Any]
) -> None:
AwsParser.response_hook(span, service_name, operation_name, result)
with lumigo_safe_execute("aws: response_hook skip check"):
span_attributes = safe_get_span_attributes(span)
if span_attributes:
if not should_sample(span_attributes, SpanKind.CLIENT):
set_span_skip_export(span)


instrumentor: AbstractInstrumentor = BotoCoreInstrumentorWrapper()
Loading
Loading