• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# How to submit a bug report
2
3If you received an error message, please include it and any exceptions.
4
5We commonly need to know what platform you are on:
6
7*   JDK/JRE version (i.e., `java -version`)
8*   Operating system (i.e., `uname -a`)
9
10# How to contribute
11
12We definitely welcome patches and contributions to OpenCensus! Here are
13some guidelines and information about how to do so.
14
15## Before getting started
16
17In order to protect both you and ourselves, you will need to sign the
18[Contributor License Agreement](https://cla.developers.google.com/clas).
19
20[Eclipse](https://google-styleguide.googlecode.com/svn/trunk/eclipse-java-google-style.xml)
21and
22[IntelliJ](https://google-styleguide.googlecode.com/svn/trunk/intellij-java-google-style.xml)
23style configurations are commonly useful. For IntelliJ 14, copy the style to
24`~/.IdeaIC14/config/codestyles/`, start IntelliJ, go to File > Settings > Code
25Style, and set the Scheme to `GoogleStyle`.
26
27## Style
28We follow the [Google Java Style
29Guide](https://google.github.io/styleguide/javaguide.html). Our
30build automatically will provide warnings for simple style issues.
31
32Run the following command to format all files. This formatter uses
33[google-java-format](https://github.com/google/google-java-format):
34
35### OS X or Linux
36
37`./gradlew goJF`
38
39### Windows
40
41`gradlew.bat goJF`
42
43We also follow these project-specific guidelines:
44
45### Javadoc
46
47* All public classes and their public and protected methods MUST have javadoc.
48  It MUST be complete (all params documented etc.) Everything else
49  (package-protected classes, private) MAY have javadoc, at the code writer's
50  whim. It does not have to be complete, and reviewers are not allowed to
51  require or disallow it.
52* Each API element should have a `@since` tag specifying the minor version when
53  it was released (or the next minor version).
54* There MUST be NO javadoc errors.
55* See
56  [section 7.3.1](https://google.github.io/styleguide/javaguide.html#s7.3.1-javadoc-exception-self-explanatory)
57  in the guide for exceptions to the Javadoc requirement.
58* Reviewers may request documentation for any element that doesn't require
59  Javadoc, though the style of documentation is up to the author.
60* Try to do the least amount of change when modifying existing documentation.
61  Don't change the style unless you have a good reason.
62
63### AutoValue
64
65* Use [AutoValue](https://github.com/google/auto/tree/master/value), when
66  possible, for any new value classes. Remember to add package-private
67  constructors to all AutoValue classes to prevent classes in other packages
68  from extending them.
69
70## Building opencensus-java
71
72Continuous integration builds the project, runs the tests, and runs multiple
73types of static analysis.
74
75Run the following commands to build, run tests and most static analysis, and
76check formatting:
77
78### OS X or Linux
79
80`./gradlew clean assemble check verGJF`
81
82### Windows
83
84`gradlew.bat clean assemble check verGJF`
85
86Use these commands to run Checker Framework null analysis:
87
88### OS X or Linux
89
90`./gradlew clean assemble -PcheckerFramework`
91
92### Windows
93
94`gradlew.bat clean assemble -PcheckerFramework`
95
96### Checker Framework null analysis
97
98OpenCensus uses the [Checker Framework](https://checkerframework.org/) to
99prevent NullPointerExceptions. Since the project uses Java 6, and Java 6 doesn't
100allow annotations on types, all Checker Framework type annotations must be
101[put in comments](https://checkerframework.org/manual/#backward-compatibility).
102Putting all Checker Framework annotations and imports in comments also avoids a
103dependency on the Checker Framework library.
104
105OpenCensus uses `org.checkerframework.checker.nullness.qual.Nullable` for all
106nullable annotations on types, since `javax.annotation.Nullable` cannot be
107applied to types. However, it uses `javax.annotation.Nullable` in API method
108signatures whenever possible, so that the annotations can be uncommented and
109be included in .class files and Javadocs.
110
111### Checkstyle import control
112
113This project uses Checkstyle to specify the allowed dependencies between
114packages, using its ImportControl feature
115(http://checkstyle.sourceforge.net/config_imports.html#ImportControl).
116`buildscripts/import-control.xml` specifies the allowed imports and contains
117some guidelines on OpenCensus' inter-package dependencies. An error messsage
118such as
119`Disallowed import - edu.umd.cs.findbugs.annotations.SuppressFBWarnings. [ImportControl]`
120could mean that `import-control.xml` needs to be updated.
121
122## Benchmarks
123
124### Invoke all benchmarks on a sub-project
125
126```bash
127$ ./gradlew clean :opencensus-impl-core:jmh
128```
129
130### Invoke on a single benchmark class
131
132```bash
133./gradlew -PjmhIncludeSingleClass=BinaryFormatImplBenchmark clean :opencensus-impl-core:jmh
134```
135
136### Debug compilation errors
137When you make incompatible changes in the Benchmarks classes you may get compilation errors which
138are related to the old code not being compatible with the new code. Some of the reasons are:
139* Any plugin cannot delete the generated code (jmh generates code) because if the user configured
140the directory as the same as source code the plugin will delete users source code.
141* After you run jmh, a gradle daemon will stay alive which may cache the generated code in memory
142and use use that generated code even if the files were changed. This is an issue for classes
143generated with auto-value.
144
145Run this commands to clean the Gradle's cache:
146```bash
147./gradlew --stop
148rm -fr .gradle/
149rm -fr benchmarks/build
150```
151
152## Proposing changes
153
154Create a Pull Request with your changes. Please add any user-visible changes to
155CHANGELOG.md. The continuous integration build will run the tests and static
156analysis. It will also check that the pull request branch has no merge commits.
157When the changes are accepted, they will be merged or cherry-picked by an
158OpenCensus core developer.
159