Skip to content

Commit bc068d4

Browse files
uglidebasepi
andauthored
Fix code examples in Starlette/FastAPI doc (#1939)
- Add required 'SERVER_URL' config param - Fix import in FastAPI code example - Use the correct variable when referring to APM client Co-authored-by: Colton Myers <[email protected]>
1 parent cda2fef commit bc068d4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/starlette.asciidoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ from elasticapm.contrib.starlette import make_apm_client, ElasticAPM
5757
apm = make_apm_client({
5858
'SERVICE_NAME': '<SERVICE-NAME>',
5959
'SECRET_TOKEN': '<SECRET-TOKEN>',
60+
'SERVER_URL': '<SERVER-URL>',
6061
})
6162
app = Starlette()
6263
app.add_middleware(ElasticAPM, client=apm)
@@ -72,7 +73,7 @@ is almost exactly the same as with Starlette:
7273
[source,python]
7374
----
7475
from fastapi import FastAPI
75-
from elasticapm.contrib.starlette ElasticAPM
76+
from elasticapm.contrib.starlette import ElasticAPM
7677
7778
app = FastAPI()
7879
app.add_middleware(ElasticAPM)
@@ -93,14 +94,14 @@ Capture an arbitrary exception by calling
9394
try:
9495
1 / 0
9596
except ZeroDivisionError:
96-
apm.client.capture_exception()
97+
apm.capture_exception()
9798
----
9899

99100
Log a generic message with <<client-api-capture-message,`capture_message`>>:
100101

101102
[source,python]
102103
----
103-
apm.client.capture_message('hello, world!')
104+
apm.capture_message('hello, world!')
104105
----
105106

106107
[float]

0 commit comments

Comments
 (0)