Commit graph

97 commits

Author SHA1 Message Date
jianglai
1c1f95992a Move backported JUnit file to third_party (part 2)
Last commit did not pick up all the changes because MOE incorrectly attributed some changes to the wrong commit. This commit should reconcile these. Also picked up some changes to how hamcrest library is depended upon in BUILD file, which should have been included in previous commits.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177637931
2017-12-02 11:37:46 -05:00
mcilwain
e2db3f914e Clean up some code quality issues
This removes some qualifiers that aren't necessary (e.g. public/abstract on interfaces, private on enum constructors, final on private methods, static on nested interfaces/enums), uses Java 8 lambdas and features where that's an improvement

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177182945
2017-12-01 22:14:06 -05:00
mcilwain
2aa897e698 Remove unnecessary generic type arguments
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175155365
2017-11-21 18:17:31 -05:00
jianglai
a6f0ab1429 Collect proxy backend metrics
The metrics are collected in a new handler (BackendMetricsHandler), which gets outbound FullHttpRequest and inbound FullHttpResponse. All metrics collected here are backend metrics, i. e. metrics about connection between the proxy and GAE. They also corresponds to the metrics that we are correctly collection from the [] proxy, minus a few that are related to quota management, which are yet to be implemented.

This CL also removed some unnecessary steps to write the frontend protocol name and client hash certificate into backend channel attributes. Instead, BackendMetricsHandler will read these information from the frontend channel attributes directly. This is because backend channel is established after frontend channel, and reading frontend channel attributes from backend handlers always works. On the other hand, there is no easy way to guarantee that the backend channel attributes are writable from frontend handlers, because the channel itself may not have been fully established.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174513334
2017-11-07 17:43:25 -05:00
jianglai
d3254eaaeb Add a convenience method to clear all registered metrics
Also making these methods public so that other test methods can use them.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174074038
2017-11-07 17:34:36 -05:00
jianglai
4a5b9fc288 Add a convenient method to DistributionMetricSubject
Currently to assert that a given Metric<Distribution> as a certain distribution for some labels, the caller needs to manually create an ImmutableDistribution and pass it to #hasValueForLabels method. With this change, an ImmutableSet of data points can be passed to #hasDataSetForLabels method.

Also switched to use expectThrow backport from JUnit 4.13.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173544521
2017-11-07 17:17:14 -05:00
mcilwain
eed2e0c45f Remove unnecessary explicit generic type declarations
They can be inferred correctly even in Java 7, and display as
compiler warnings in IntelliJ.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173451087
2017-11-07 17:11:29 -05:00
jianglai
0573560a6c Change MetricsRegistryImpl constructor to "@VisibleForTesting public".
This enables registry isolation in tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173426040
2017-11-07 17:02:44 -05:00
jianglai
c702b4486c Use standard java thread factory instead of the AppEngine flavor
With Java 8 in GAE standard environment, we can now use standard java thread factory to run the metric reporter in the background in daemon mode, which would not interfere with basic scaling idle timeout as App Engine thread would.

Because the thread is not created by ThreadManager, no App Engine APIs can be called from it. We therefore use GoogleCredential instead of AppIdentityCredential as HttpRequestInitializer, and NetHttpTransport instead of UlrFetchTransport as HttpTransport.

MetricReporter is lazy injected because it depends on jsonCredential retrieved from CloudKms, which is not available in a test environment, causing FrontendServletTest and BackendServletTest to fail.

Some minor re-formatting with google-java-format on edited files.

Lastly removed moe comments in import statement, which makes the linter unhappy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172896227
2017-10-24 16:53:47 -04:00
mcilwain
05f6ad80ab Format some imports using fix_imports.py
Unfortunately this tool isn't smart enough to deal with the assertThat
situation (which has two static imports of a function with the same name).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172000753
2017-10-24 16:53:47 -04:00
mcilwain
c0f8da0c6e Switch from Guava Optionals to Java 8 Optionals
This was a surprisingly involved change. Some of the difficulties included
java.util.Optional purposely not being Serializable (so I had to move a
few Optionals in mapreduce classes to @Nullable) and having to add the Truth
Java8 extension library for assertion support.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171863777
2017-10-24 16:53:47 -04:00
guyben
840d53c819 Allow EventSample.record to accept numSamples=0
There's really no reason not to.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171037754
2017-10-24 16:50:30 -04:00
mcilwain
5edb7935ed Run automatic Java 8 conversion over codebase
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171174380
2017-10-10 12:09:41 -04:00
mcilwain
302a27f0db Record a version of EPP metrics with TLD for domain commands
Also fixes the issue that dry run EPP commands were incorrectly being
reported on.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171062984
2017-10-05 11:47:31 -04:00
guyben
0b5b16e97c Allow EventSample.record to accept numSamples=0
There's really no reason not to.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171037754
2017-10-05 11:41:59 -04:00
jianglai
9d8e48cf24 Refector metrics truth subject
The concrete implementation of a Metric is not of importance when asserting on the values it contains. Therefore this CL removes Metric<T> as a type parameter of AbstractMetricSubject. As a result the two implementations of the abstract subject can be used on any Metric<Long> and Metric<Distribution>, respectively.

Also migrate to Subject.Factory from deprecated SubjectFactory.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171012012
2017-10-04 16:16:45 -04:00
jianglai
dc41d7923e Remove injectable constructors in metrics library
Users of the client library should be responsible for providing the bindings required. By removing the injectable constructors and named bindings in their parameters, the client library is no longer forcing its users to provide bindings with specific named annotations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170490834
2017-10-04 16:16:45 -04:00
jianglai
ac0718079d Fix typo
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170487675
2017-10-04 16:16:45 -04:00
jianglai
ceadfea11f Remove @Inject annotation in StackDriverWriter
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170111976
2017-10-04 16:16:45 -04:00
shikhman
f27dd70c9e Automated g4 rollback of changelist 169922096.
*** Reason for rollback ***

Rolling back to fix []
*** Original change description ***

Remove @Inject annotation in StackDriverWriter

StackDriverWriter is provided by java.google.registry.monitoring.whitebox.StackdriverModule. The @Inject annotation in its constructor is not used. It also uses outdated named binding like @Named(stackdriverGcpProject) which causes confusion because that name is not provided anywhere in the code.

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169931047
2017-10-04 16:16:45 -04:00
jianglai
2814561e92 Remove @Inject annotation in StackDriverWriter
StackDriverWriter is provided by java.google.registry.monitoring.whitebox.StackdriverModule. The @Inject annotation in its constructor is not used. It also uses outdated named binding like @Named(stackdriverGcpProject) which causes confusion because that name is not provided anywhere in the code.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169922096
2017-10-04 16:16:45 -04:00
guyben
fa70bd272a Add tool to check if other requests are still running
This is needed for the Lock.java enhancement where a lock will be implicitly
released if the request owning it dies.

No matter which solution we want for refactoring the Lock itself, we will need this class.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=167600314
2017-09-12 15:51:50 -04:00
guyben
e224a67eda Change @Auth to an AutoValue, and created a set of predefined Auths
We want to be safer and more explicit about the authentication needed by the many actions that exist.

As such, we make the 'auth' parameter required in @Action (so it's always clear who can run a specific action) and we replace the @Auth with an enum so that only pre-approved configurations that are aptly named and documented can be used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162210306
2017-08-01 16:33:10 -04:00
mcilwain
0fdde1cc9e Change FibonacciFitter to just be a utility method
It turns out that StackdriverWriter uses reflection on the class of
the DistributionFitter instance, so rather than giving it custom
handling for FibonacciFitters, it's easier to turn FibonacciFitter
into a single utility method that takes advantage of existing support
for CustomFitters.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158190147
2017-06-14 10:31:29 -04:00
mcilwain
bb67841884 Add metrics for async batch operation processing
We want to know how long it's actually taking to process asynchronous
contact/host deletions and DNS refreshes on host renames. This adds
instrumentation. Five metrics are recorded as follows:

* An incrementable metric for each async task processed (split out by
  type of task and result).
* Two event metrics for processing time between when a task is enqueued
  and when it is processed -- tracked separately for contact/host
  deletion and DNS refresh on host rename.
* Two event metrics for batch size every time the two mapreduces are
  run (this is usually 0). Tracked separately for contact/host deletion
  and DNS refresh on host rename.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157001310
2017-06-05 18:17:09 -04:00
mcilwain
1adeb57fea Add a Fibonacci fitter for metrics bucketing
A Fibonacci fitter is useful in situations where you want more precision on the
low end than an ExponentialFitter with exponent base 2 provides without the
hassle of dealing with non-integer boundaries, such as would be created by an
exponential fitter with a base of less than 2. Fibonacci fitters are ideal for
integer metrics that are bounded across a certain range, e.g. integers between 1
and 1,000.

This also cleans up some unit test comments.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156773367
2017-05-23 17:22:49 -04:00
shikhman
413a634533 Automated g4 rollback of changelist 156106183.
*** Reason for rollback ***

This change is crashing alpha

*** Original change description ***

Change metrics ThreadFactory to produce daemon threads

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156336467
2017-05-17 15:19:10 -04:00
shikhman
e1f4df86bd Change metrics ThreadFactory to produce daemon threads
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156106183
2017-05-17 12:21:12 -04:00
mcilwain
4260fb573f Use the actual EPP command flow name for EppMetrics
It was previously only using the name of the inner command XML element,
e.g. "Create", "Delete", "Update", etc. This wasn't very useful because
there was no way to discriminate between operations on different types
of EPP resources.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=151131491
2017-03-27 13:30:05 -04:00
mcilwain
3a13a4d6b6 Add monitoring/metrics/contrib package to Nomulus release
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150007228
2017-03-21 14:59:31 -04:00
Ben McIlwain
0cbc2bdab6 Use Immutable types for static final fields
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149260759
2017-03-07 13:53:46 -05:00
mountford
9a15f08b3a Add Truth subjects for incrementable and event metrics
This CL adds Truth framework subjects to some metrics in the Stackdriver metrics library, in a contrib subpackage. It doesn't deal with gauge metrics, and for event metrics, the assertions can only be that a metric has or does not have a distribution for a particular set of label values. Asserting more fine-grained propositions regarding the distribution will require a distribution subject.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149112692
2017-03-07 13:46:38 -05:00
mcilwain
d6e6e8a49c Re-add some accidentally removed license headers
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146694719
2017-02-06 16:45:23 -05:00
mmuller
b70f57b7c7 Update copyright year on all license headers
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146111211
2017-02-02 16:27:22 -05:00
mcilwain
813f837956 Re-add Stackdriver metrics code
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146000275
2017-01-30 15:03:53 -05:00
shikhman
3f9c53b850 Refactor Stackdriver-over-REST specific code to a different package
Downstream users who use gRPC rather than REST don't want to pull down
rest-related dependencies.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145834701
2017-01-30 15:03:53 -05:00
mcilwain
8f8d67a17b Inject the BigQuery streaming metrics queue
This makes local development easier by allowing a stub to be injected for the
queue.

Based on Justin Graham's PR: https://github.com/google/nomulus/pull/51

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=144439454
2017-01-13 10:29:36 -05:00
shikhman
e981bad0b3 Rename all encoding methods to start with the word encode for consistency
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143973446
2017-01-12 13:58:31 -05:00
mcilwain
eaec03e670 Move ConfigModule and LocalTestConfig into RegistryConfig
This is the final preparatory step necessary in order to load and load
configuration from YAML in a static context and then provide it either via
Dagger (using ConfigModule) or through RegistryConfig's existing static
functions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143819983
2017-01-09 12:01:09 -05:00
jart
734130aa73 Restructure Maven dependencies in build
We're now using java_import_external instead of maven_jar. This allows
us to specify the relationships between jars, thereby allowing us to
eliminate scores of vendor BUILD files that did nothing but re-export
@foo//jar targets, thus addressing the concerns of djhworld on Hacker
News: https://news.ycombinator.com/item?id=12738072

We now have redundant failover mirrors, which is a feature I added to
Bazel 0.4.2 in ed7ced0018

A new standard naming convention is now being used for all Maven repos.
Those names are calculated from the group_artifact name using the
following algorithm that eliminates redundancy:
https://gist.github.com/jart/41bfd977b913c2301627162f1c038e55

The JSR330 dep has been removed from java targets if they also depend
on Dagger, since Dagger always exports JSR330.

Annotation processor dependencies should now be leaner and meaner, by
more appropriately managing what needs to be on the classpath at
runtime. This should trim down the production jar by >1MB. As it stands
currently in the open source world:

- backend_jar_deploy.jar: 50MB
- frontend_jar_deploy.jar: 30MB
- tools_jar_deploy.jar: 45MB

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143487929
2017-01-09 11:59:04 -05:00
mcilwain
28f6c770c8 Add MOE equivalence for sync on 2016-12-19
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142449539
2017-01-09 11:59:04 -05:00
mountford
0afafeff03 Move VerifyEntityIntegrityAction to batch package
By moving []s into the batch package, which is not included in the frontend service, we pave the way to remove the dependency of frontend on the [] library.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142265351
2016-12-19 11:09:20 -05:00
mcilwain
2b7d580bb3 Run buildifier on codebase to format BUILD files
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=140362453
2016-11-28 18:15:21 -05:00
cgoldfeder
84009eaccb Scope down TransferData to only ContactResource and DomainResource
HostResource and DomainApplication are not transferable, (or at
least, not directly in the case of hosts) and have no need for
the TransferData field. In a flat-flow world, we can push it down
to where it's actually used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139201423
2016-11-15 13:47:28 -05:00
jianglai
59d998954c Use correct <a> tag syntax in javadoc @see tag
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=137946021
2016-11-02 15:19:34 -04:00
jart
2e81de9954 Make essential Bazel packages publicly visible
This allows separate Bazel projects to reference Nomulus as an external
repository. They can then copy the []
directory structure into their own project and customize the Action
and Module lists for the GAE modules in their own deployment.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=136863886
2016-10-24 11:57:00 -04:00
jianglai
cbe6d2b520 Resolve some deprecation warnings
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=136399461
2016-10-18 10:32:47 -04:00
ctingue
67da55536f Clean up misc Javadoc and deprecation warnings
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=136156922
2016-10-14 17:00:33 -04:00
shikhman
f76bc70f91 Preserve test logs and test summary output for Kokoro CI runs
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135494972
2016-10-14 16:57:43 -04:00
mcilwain
b65b855067 Always use the constructor to make Immutable Collection Builders
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135359669
2016-10-07 14:37:02 -04:00