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

Logging botocore request & response data #1058

Open
athewsey opened this issue Jan 22, 2025 · 0 comments
Open

Logging botocore request & response data #1058

athewsey opened this issue Jan 22, 2025 · 0 comments

Comments

@athewsey
Copy link

By default, it seems like the botocore instrumentation in this layer is recording only basic metadata for boto3 requests in my Lambda code. I was hoping to re-configure it to include the request and response body parameters as metadata - for a subset of services & operations.

I see opentelemetry-python-contrib's BotocoreInstrumentor supports request_hook and response_hook parameters that look like they should be able to fill this purpose (by e.g. calling span.set_attribute in the hook to add additional information).

...But when I try to set up instrumentation with these hooks in my Lambda code, like below:

from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
BotocoreInstrumentor().instrument(request_hook=otel_req_hook, response_hook=otel_resp_hook)

...I find my hooks are not called - and I get a log entry suggesting it's because tracing was already set up before my function code initialized:

[WARNING]	2025-01-22T16:52:38.974Z		Attempting to instrument while already instrumented

Sorry if I'm coming at this from the wrong direction, as pretty new to it all... But is there no way to re-configure the botocore instrumentation with this Lambda layer? Or no alternative way to request API request & response params get attached to the boto traces?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant