-
Notifications
You must be signed in to change notification settings - Fork 873
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
Document Instrumenter API #4544
Document Instrumenter API #4544
Conversation
dafadff
to
24f1cad
Compare
Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> Co-authored-by: Nikita Salnikov-Tarnovski <[email protected]> Co-authored-by: Lauri Tulmin <[email protected]>
24f1cad
to
0d787ef
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.
misc drive-by comments only, please accept or reject any at your preference and hit merge, this doc is 💯
try (Scope scope = context.makeCurrent()) { | ||
Response response = actualMethod(request); | ||
instrumenter.end(context, request, response, null); | ||
return response; | ||
} catch (Throwable error) { | ||
instrumenter.end(context, request, null, error); | ||
throw error; | ||
} |
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.
@anuraaga did we discuss this previously?
@mateuszrzeszutek this might be too weird for doc anyways...
try (Scope scope = context.makeCurrent()) { | |
Response response = actualMethod(request); | |
instrumenter.end(context, request, response, null); | |
return response; | |
} catch (Throwable error) { | |
instrumenter.end(context, request, null, error); | |
throw error; | |
} | |
Response response = null; | |
Throwable error = null; | |
try (Scope scope = context.makeCurrent()) { | |
response = actualMethod(request); | |
return response; | |
} catch (Throwable t) { | |
error = t; | |
throw t; | |
} finally { | |
instrumenter.end(context, request, response, error); | |
} |
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.
Well - our docs should reflect our practice :) I think ending without the scope active is generally better but we haven't made such a change ourselves really
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.
👍 opened #4596 to discuss/implement and we can update the doc later if we make the change
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'll merge this PR as it is -- the doc can be updated as part of #4596 later, when all instrumentations follow that pattern.
The sample `ContextCustomizer` listed above inserts an additional `InProcessingAttributesHolder` to | ||
the `Context` before it is returned from the `Instrumenter#start()` method. | ||
The `InProcessingAttributesHolder` class, as its name implies, may be used to keep track of | ||
attributes that are not available on request start or end - for example, if the instrumented library | ||
exposes important information only during the processing. The holder class can be looked up from the | ||
current `Context` and filled in with that information between the instrumented operation start and | ||
end. It can be later passed as `RESPONSE` type (or a part of it) to the `Instrumenter#end()` method | ||
so that the configured `AttributesExtractor` can process the collected information and turn it into | ||
telemetry attributes. |
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.
nice example
Co-authored-by: Trask Stalnaker <[email protected]>
* Document Instrumenter API * Apply suggestions from code review Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> Co-authored-by: Nikita Salnikov-Tarnovski <[email protected]> Co-authored-by: Lauri Tulmin <[email protected]> * reformat and code review comments * code review comments * Apply suggestions from code review Co-authored-by: Trask Stalnaker <[email protected]> * formatting Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]> Co-authored-by: Nikita Salnikov-Tarnovski <[email protected]> Co-authored-by: Lauri Tulmin <[email protected]> Co-authored-by: Trask Stalnaker <[email protected]>
Resolves #4280 (together with the previous #4443 PR)
CC @theletterf