-
Notifications
You must be signed in to change notification settings - Fork 212
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
api docs and API simplifications [WIP] #112
Conversation
dab17f5
to
cdbb607
Compare
docs/api.asciidoc
Outdated
|
||
[break] | ||
[[client-api-capture-exception]] | ||
==== `Client.capture_exception()` |
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.
This Client.capture_exception()
looks like a class method, but then you actually call client.capture_exception()
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.
I used a capital C in all the titles that of methods on Client
, I thought it would be clear that it means "method on the Client class", didn't really think of the issue that it could be mistaken as a class method.
Class methods (or static methods) are used relatively seldom in Python, so I don't think most readers would be confused.
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.
ok, maybe it is just me then, coming from a ruby background.
@@ -0,0 +1,159 @@ | |||
[[api]] | |||
== Public API |
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.
Why do you split it into Client
, Error
and Transaction
API when you actually need a client
instance for all of them?
How about calling it a Client API
and then only use Error
and Transaction
later on?
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.
This is one of the things I struggled with when structuring the docs. I though by putting the "Client API" first, the reader will know further down how to get a client.
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.
One definitly should find his way around by the explanations you provide. I just think it is somehow confusing to describe it as three seperate APIs. I would only distinguish between the elasticapm
and the elasticapm.Client
API. And the split up elasticapm.Client
into
- getting an instance
- error capturing
- transaction capturing
docs/api.asciidoc
Outdated
* `message`: The message as a string. | ||
* `param_message`: Alternatively, a parametrized message as a dictionary. | ||
The dictionary contains two values: `message`, and `params`. | ||
This allows the APM server to group messages together that have share the same |
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.
This sentence is a bit malformed: This allows the APM server to group messages together that have share the same parametrized message.
docs/api.asciidoc
Outdated
===== Arguments | ||
|
||
* `message`: The message as a string. | ||
* `param_message`: Alternatively, a parametrized message as a dictionary. |
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.
What if one doesn't provide message
nor param_message
? Maybe a sentence like Either message or param_message need to be provided.
.. Or is it ok to not provide any of them?
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.
Excellent point, one of the two is needed
docs/api.asciidoc
Outdated
[[transaction-api]] | ||
=== Transaction API | ||
|
||
[break] |
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.
Although the usage is straightforward, it would be nice to also have an example in for the transaction
cmds, as you also have examples for client
and error
related usage.
docs/api.asciidoc
Outdated
|
||
[break] | ||
[[api-elasticapm-instrument]] | ||
==== `elasticapm.instrument()` |
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.
This doesn't seem to be related to transaction
specific cmds, so maybe you want to move it to its own section like Auto-Instrumentation
.
docs/api.asciidoc
Outdated
===== Arguments | ||
|
||
* `data`: A dictionary with the data to be attached. This should be a flat key/value `dict` object. | ||
* `_key`: The key to use for this `dict` object. Defaults to `custom`. |
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.
Does the underscore in _key
indicate it is private? The documented possibility of modifying the variable looks somehow weird.
docs/api.asciidoc
Outdated
* `data`: A dictionary with the data to be attached. This should be a flat key/value `dict` object. | ||
* `_key`: The key to use for this `dict` object. Defaults to `custom`. | ||
+ | ||
NOTE: This should only be overridden by framework integrations. |
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.
It would be great to add optional
or mandatory
to every parameter you describe. Sometimes you mention it is optional, sometimes you mention a default, sometimes none of both.
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.
For begin_transaction
and end_transaction
it is not very clear to me if the params are required or not.
docs/api.asciidoc
Outdated
|
||
[break] | ||
[[api-set-transaction-name]] | ||
==== `elasticapm.set_transaction_name()` |
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.
Why is begin_transaction
and end_transaction
a method of client
byt set_transaction_name
and set_transaction_data
are not?
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.
in most places you'd use set_transaction_name
& Co, you don't have a client
instance or the current transaction. With this, we can put the difficulty of getting the current transaction into our code, instead of leaving it to the user to acquire the current transaction somehow.
At the moment, the current transaction is stored on a thread local. But that only works for singlethreaded code, so we probably need to change that in the future. The way it is now, that change would be nicely encapsulated.
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.
How can you not have a current transaction when you want to override the name of the current transaction?
I ofc don't have the insights into the agent, but from a pure user perspective I'd somwhow expect that set_transaction_name
and begin/stop_transaction
is within the same context.
But this might be somehow out of scope for this PR anyways, just realized that when looking at the docs.
7957f28
to
711543a
Compare
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.
The documentation looks great @beniwohli!
I only left some minor comments.
docs/api.asciidoc
Outdated
|
||
Returns the id of the message as a string. | ||
|
||
NOTE: either the `message` or the `param_message` argument is required. |
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.
Could you start with a capital letter here?
docs/api.asciidoc
Outdated
== Public API | ||
|
||
The Elastic APM Python agent has several public APIs. | ||
Most of these APIs are not needed when using one of our supported frameworks (Django and Flask), |
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.
How about changing this to something like Most of the public API functionality is not needed when..
docs/api.asciidoc
Outdated
* `data`: A dictionary with the data to be attached. This should be a flat key/value `dict` object. | ||
* `_key`: The key to use for this `dict` object. Defaults to `custom`. | ||
+ | ||
NOTE: This should only be overridden by framework integrations. |
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.
For begin_transaction
and end_transaction
it is not very clear to me if the params are required or not.
docs/api.asciidoc
Outdated
This includes a wide range of standard library and 3rd party modules. | ||
A list of instrumented modules can be found in `elasticapm.intrumentation.register`. | ||
This function should be called as early as possibly in the startup of your application. | ||
For supported frameworks, this is called automatically. Example: |
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.
A link to the docs listing the supported framework would be a nice to have here.
711543a
to
753865e
Compare
* documents large parts of the public API * changed API of `capture_exception`, `capture_message`. Instead of an opaque `data` argument, they now have keyword arguments for `context`, `custom`, etc. * removed special handling of template errors in Django. This only ever worked with `TEMPLATE_DEBUG` enabled, and the data was never shown.
753865e
to
0a94ad6
Compare
Forward-port from #112 * documents large parts of the public API * changed API of `capture_exception`, `capture_message`. Instead of an opaque `data` argument, they now have keyword arguments for `context`, `custom`, etc. * removed special handling of template errors in Django. This only ever worked with `TEMPLATE_DEBUG` enabled, and the data was never shown.
* documents large parts of the public API * changed API of `capture_exception`, `capture_message`. Instead of an opaque `data` argument, they now have keyword arguments for `context`, `custom`, etc. * removed special handling of template errors in Django. This only ever worked with `TEMPLATE_DEBUG` enabled, and the data was never shown. closes #112
This changes the API of exception tracking. It gets rid of the somewhat opaque
data
argument and instead uses explicit keyword arguments forcontext
,custom
etc.It also removes Django-template-specific code in the exception tracking. It only worked when
TEMPLATE_DEBUG
was set to true (which shouldn't be the case in production code), and was never exposed in the UI.