-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add common properties argument to WSGIApplication wrapper #88
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# Changelog | ||
|
||
## 0.11.5 | ||
- Add common properties argument to WSGIApplication initialization. | ||
|
||
## 0.11.4 | ||
- Schemas for all data types and context objects updated to the latest version. | ||
|
||
|
||
## 0.11.3 | ||
|
||
Changelog started from this version. | ||
- Changelog started from this version. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ def hello(request): | |
app = config.make_wsgi_app() | ||
|
||
# Enable Application Insights middleware | ||
app = WSGIApplication('<YOUR INSTRUMENTATION KEY GOES HERE>', app) | ||
app = WSGIApplication('<YOUR INSTRUMENTATION KEY GOES HERE>', app, common_properties={'service': 'hello_world_service'}) | ||
|
||
serve(app, host='0.0.0.0') | ||
""" | ||
|
@@ -49,6 +49,7 @@ def __init__(self, instrumentation_key, wsgi_application, *args, **kwargs): | |
self.client = applicationinsights.TelemetryClient(instrumentation_key, telemetry_channel) | ||
self.client.context.device.type = "PC" | ||
self._wsgi_application = wsgi_application | ||
self._common_properties = kwargs.pop('common_properties', {}) | ||
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. @SergeyKanzhelev How would you like the 'common_properties' parameter to be documented in the init documentation? 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. yes, it will be great if you can add a note into README.md. I see that |
||
|
||
def flush(self): | ||
"""Flushes the queued up telemetry to the service. | ||
|
@@ -104,4 +105,4 @@ def status_interceptor(status_string, headers_array, exc_info=None): | |
end_time = datetime.datetime.utcnow() | ||
duration = int((end_time - start_time).total_seconds() * 1000) | ||
|
||
self.client.track_request(name, url, success, start_time.isoformat() + 'Z', duration, response_code, http_method) | ||
self.client.track_request(name, url, success, start_time.isoformat() + 'Z', duration, response_code, http_method, self._common_properties) |
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.
We haven't shipped
11.4
yet. So it should be reported under previous title. I'll merge and fix this