Skip to content

Commit

Permalink
Add docs note about setup code in lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
basepi committed Jan 4, 2023
1 parent d05e052 commit 0298025
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/serverless.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ def handler(event, context):
return {"statusCode": r.status_code, "body": "Success!"}
----

Note: any database or connection pool setup should go inside of your handler,
otherwise the agent will not be able to instrument those objects and you may
see missing spans. Example:


[source,python]
----
conn = None
@capture_serverless()
def handler(event, context):
global conn
if not conn:
conn = pymysql.connect(host=rds_host, user=name, passwd=password, db=db_name, connect_timeout=5)
----

[float]
==== Step 3: Configure APM on AWS Lambda

Expand Down

0 comments on commit 0298025

Please sign in to comment.