[DOC] Provide an example when no framework is used
* [DOC] Provide an example when no framework is used
Provide an example when no framework is used.
Feel free to edit or enrich with additional references to other documentation pages.
@@ -26,6 +26,41 @@ Examples of this are
Framework integrations require some limited code changes in your app.
E.g. for Django, you need to add `elasticapm.contrib.django` to `INSTALLED_APPS`.
+[float]
+[[how-it-works-no-framework]]
+==== What if you are not using a framework
+
+If you're not using a supported framework, for example, a simple Python script, you can still
+leverage the agent's <<automatic-instrumentation,automatic instrumentation>>.
+
+In order to collect the Spans generated by the supported libraries, you need to invoke `elasticapm.instrument()`
+(just once, at the initalization stage of your application) and create at least one Transaction.
+It is up to you to determine what you consider a Transaction within your application -- it can be the whole execution of the
+script or a part of it.
+
+The example below will consider the whole execution as a single transaction with two HTTP request Spans in it.
+The `elasticapm.Client` can be setup programmatically or using the environment variables.
+
+[source,python]
+----
+import requests
+import time
+import elasticapm
+
+def main():
+ sess = requests.Session()
+ for url in [ 'https://www.elastic.co', 'https://benchmarks.elastic.co' ]:
+ resp = sess.get(url)
+ time.sleep(1)
+
+if __name__ == '__main__':
+ client = elasticapm.Client()
+ elasticapm.instrument()
+ client.begin_transaction('main')
+ main()
+ client.end_transaction('main')
+----
+
[float]
[[how-it-works-instrumentation]]
==== Instrumentation
