Browse Source

Add note about Optional/Stream usage to style guide (#8193)

Based on #8190 and
https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/8131#discussion_r1151528583

---------

Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
Trask Stalnaker 1 year ago
parent
commit
3e087e8206
1 changed files with 9 additions and 2 deletions
  1. 9 2
      docs/contributing/style-guideline.md

+ 9 - 2
docs/contributing/style-guideline.md

@@ -132,5 +132,12 @@ plugins {
 Following the reasoning from [Writing a Java library with better experience (slide 12)](https://speakerdeck.com/trustin/writing-a-java-library-with-better-experience?slide=12),
 usage of `java.util.Optional` is kept at a minimum in this project.
 
-It is ok to use `Optional` in places where it does not leak into public API signatures and where
-performance is not critical.
+It is ok to use `Optional` in places where it does not leak into public API signatures.
+
+Also, avoid `Optional` usage on the hot path (instrumentation code), unless the instrumented library
+itself uses it.
+
+## `java.util.stream.Stream` usage
+
+Avoid streams on the hot path (instrumentation code), unless the instrumented library itself uses
+them.