Skip to content
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

Merged

Conversation

mateuszrzeszutek
Copy link
Member

Resolves #4280 (together with the previous #4443 PR)

CC @theletterf

docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
Mateusz Rzeszutek and others added 4 commits November 2, 2021 19:38
Copy link
Member

@trask trask left a 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 💯

docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
Comment on lines +87 to +94
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;
}
Copy link
Member

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...

Suggested change
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);
}

Copy link
Contributor

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

Copy link
Member

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

Copy link
Member Author

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.

docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
Comment on lines +413 to +421
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice example

docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
docs/contributing/using-instrumenter-api.md Outdated Show resolved Hide resolved
Mateusz Rzeszutek and others added 2 commits November 5, 2021 08:05
@mateuszrzeszutek mateuszrzeszutek merged commit f3ec9a2 into open-telemetry:main Nov 5, 2021
@mateuszrzeszutek mateuszrzeszutek deleted the instrumenter-docs branch November 5, 2021 14:16
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update "Writing instrumentation" document to Instrumenters
6 participants