Skip to content

Commit ff0ef2a

Browse files
committed
Clean up: Capture outgoing README
1 parent ece32c4 commit ff0ef2a

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

README.md

+27-22
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,19 @@ into the [_Moesif Portal_](https://www.moesif.com/), click on the top right menu
5959
- `moesif_aws_lambda/middleware.py` the middleware library
6060
- `lambda_function.py` sample AWS Lambda function using the middleware
6161

62+
## Optional: Capturing outgoing API calls
63+
If you want to capture all outgoing API calls from your Python Lambda function to third parties like
64+
Stripe or to your own dependencies, call `start_capture_outgoing()` to start capturing. This mechanism works by
65+
patching the [Requests](http://docs.python-requests.org/en/master/)
66+
67+
```python
68+
from moesif_aws_lambda.middleware import *
69+
start_capture_outgoing(moesif_options) # moesif_options are the configuration options.
70+
```
71+
6272
## Configuration options
6373

64-
#### __`IDENTIFY_USER`__
74+
### __`IDENTIFY_USER`__
6575

6676
Type: `(event, context) => String`
6777

@@ -77,7 +87,7 @@ def identify_user(event, context):
7787
return event["requestContext"]["identity"]["cognitoIdentityId"]
7888
```
7989

80-
#### __`IDENTIFY_COMPANY`__
90+
### __`IDENTIFY_COMPANY`__
8191

8292
Type: `(event, context) => String`
8393

@@ -95,7 +105,7 @@ def identify_company(event, context):
95105
}
96106
```
97107

98-
#### __`GET_SESSION_TOKEN`__
108+
### __`GET_SESSION_TOKEN`__
99109

100110
Type: `(event, context) => String`
101111

@@ -109,7 +119,7 @@ def get_session_token(event, context):
109119
return 'XXXXXXXXX'
110120
```
111121

112-
#### __`GET_API_VERSION`__
122+
### __`GET_API_VERSION`__
113123

114124
Type: `(event, context) => String`
115125

@@ -123,7 +133,7 @@ def get_api_version(event, context):
123133
return '1.0.0'
124134
```
125135

126-
#### __`GET_METADATA`__
136+
### __`GET_METADATA`__
127137

128138
Type: `(event, context) => String`
129139

@@ -140,7 +150,7 @@ def get_metadata(event, context):
140150
}
141151
```
142152

143-
#### __`SKIP`__
153+
### __`SKIP`__
144154

145155
Type: `(event, context) => Boolean`
146156

@@ -155,7 +165,7 @@ def should_skip(event, context):
155165
return "/" in event['path']
156166
```
157167

158-
#### __`MASK_EVENT_MODEL`__
168+
### __`MASK_EVENT_MODEL`__
159169

160170
Type: `MoesifEventModel => MoesifEventModel`
161171

@@ -167,47 +177,42 @@ def mask_event(eventmodel):
167177
return eventmodel
168178
```
169179

170-
#### __`DEBUG`__
180+
### __`DEBUG`__
171181

172182
Type: `Boolean`
173183

174184
Set to true to print debug logs if you're having integration issues.
175185

176-
#### __`LOG_BODY`__
186+
### __`LOG_BODY`__
177187

178188
Type: `Boolean`
179189

180190
`LOG_BODY` is default to true, set to false to remove logging request and response body to Moesif.
181191

182-
#### __`CAPTURE_OUTGOING_REQUESTS`__
183-
Capture all outgoing API calls from your app to third parties like Stripe or to your own dependencies while using [Requests](http://docs.python-requests.org/en/master/) library. The options below is applied to outgoing API calls.
184-
When the request is outgoing, for options functions that take request and response as input arguments, the request and response objects passed in are [Requests](http://docs.python-requests.org/en/master/api/) request or response objects.
192+
## Options for logging outgoing calls
185193

186-
```python
187-
from moesif_aws_lambda.middleware import *
188-
start_capture_outgoing(moesif_options) # moesif_options are the configuration options.
189-
```
194+
The options below are applied to outgoing API calls. The request and response objects passed in are [Requests](http://docs.python-requests.org/en/master/api/) request and [Response](https://golang.org/src/net/http/response.go) response objects.
190195

191-
##### __`SKIP_OUTGOING`__
196+
### __`SKIP_OUTGOING`__
192197
(optional) _(req, res) => boolean_, a function that takes a [Requests](http://docs.python-requests.org/en/master/api/) request and response,
193198
and returns true if you want to skip this particular event.
194199

195-
##### __`IDENTIFY_USER_OUTGOING`__
200+
### __`IDENTIFY_USER_OUTGOING`__
196201
(optional, but highly recommended) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the user id used by your system. While Moesif tries to identify users automatically,
197202
but different frameworks and your implementation might be very different, it would be helpful and much more accurate to provide this function.
198203

199-
##### __`IDENTIFY_COMPANY_OUTGOING`__
204+
### __`IDENTIFY_COMPANY_OUTGOING`__
200205
(optional) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the company id for this event.
201206

202-
##### __`GET_METADATA_OUTGOING`__
207+
### __`GET_METADATA_OUTGOING`__
203208
(optional) _(req, res) => dictionary_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and
204209
returns a dictionary (must be able to be encoded into JSON). This allows
205210
to associate this event with custom metadata. For example, you may want to save a VM instance_id, a trace_id, or a tenant_id with the request.
206211

207-
##### __`GET_SESSION_TOKEN_OUTGOING`__
212+
### __`GET_SESSION_TOKEN_OUTGOING`__
208213
(optional) _(req, res) => string_, a function that takes [Requests](http://docs.python-requests.org/en/master/api/) request and response, and returns a string that is the session token for this event. Again, Moesif tries to get the session token automatically, but if you setup is very different from standard, this function will be very help for tying events together, and help you replay the events.
209214

210-
##### __`LOG_BODY_OUTGOING`__
215+
### __`LOG_BODY_OUTGOING`__
211216
(optional) _boolean_, default True, Set to False to remove logging request and response body.
212217

213218
## Update User

0 commit comments

Comments
 (0)