Skip to content
Snippets Groups Projects
Commit 72067e9f authored by Apollon Oikonomopoulos's avatar Apollon Oikonomopoulos
Browse files

New upstream version 0.9.0

parents
Branches
Tags upstream/0.9.0
No related merge requests found
Showing with 1512 additions and 0 deletions
target
pom.xml
.nrepl-port
/.lein*
/resources/locales.clj
/resources/**/Messages*.class
/dev-resources/i18n/bin
language: clojure
lein: 2.7.1
jdk:
- oraclejdk7
- openjdk7
script: ./ext/travisci/test.sh
notifications:
email: false
# Java needs to be able to resolve its hostname when doing integration style
# tests, which it cannot do in certain cases with travis-ci. If we need the
# runtime/container to be able to resolve its own hostname we need to use
# either the `hostname` or `hosts` "addon" for travis. Since we don't care
# what the hostname is, here we just give it a garbage name based on the name
# of the project.
addons:
hostname: cljhttpclient
## 0.9.0
This is a feature release
* [TK-443](https://tickets.puppetlabs.com/browse/TK-443) Adds `:enable-url-metrics?` and `setEnableURLMetrics` to the clojure and java APIs respectively. This allows disabling autogenerated url based metrics.
* [PE-19979](https://tickets.puppetlabs.com/browse/PE-19979) & [SERVER-1733](https://tickets.puppetlabs.com/browse/SERVER-1733) Update dependencies via clj-parent (i18n dependency specifically).
## 0.8.0
This is a feature release
* [PDB-2640](https://tickets.puppetlabs.com/browse/PDB-2640) Added a
`:compress-request-body` request option which allows for the request
body content to be gzip-compressed before forwarding it on to the server
## 0.7.0
This is a feature release
* [SERVER-1556](https://tickets.puppetlabs.com/browse/SERVER-1556) Add
puppetlabs/clj-i18n support to clj-http-client.
* Pass the global i18n locale binding in the "accept-language" header of Clojure
client requests.
## 0.6.0
This is a feature and maintenance release
* [TK-179](https://tickets.puppetlabs.com/browse/TK-179) Refactor to eliminate Clojure/Java duplication
* [TK-316](https://tickets.puppetlabs.com/browse/TK-316) Add support for metrics
* [TK-317](https://tickets.puppetlabs.com/browse/TK-317) Add ability to pass a metrics-id
* [TK-354](https://tickets.puppetlabs.com/browse/TK-354) Add [documentation on metrics](./doc/metrics.md)
* [TK-308](https://tickets.puppetlabs.com/browse/TK-308) Bump Apache HttpAsyncClient library to 4.1.2
* [TK-402](https://tickets.puppetlabs.com/browse/TK-402) Allow metric namespace to be configurable
* Bump Trapperkeeper and Kitchensink dependencies from 1.1.1 to 1.5.1 (TK) and
1.2.0 to 1.3.0 (KS).
## 0.5.0
This is a feature release.
* [TK-312](https://tickets.puppetlabs.com/browse/TK-312) Unbuffered streams in Java to match clojure support released in 0.4.5.
* Add request function to clojure client protocol.
## 0.4.6
This is a maintenance release.
* [TK-303](https://tickets.puppetlabs.com/browse/TK-303) - update dependencies to use Apache httpasyncclient v4.1.1.
## 0.4.5
This is a feature release, and probably should have been 0.5.0 in
order to comply with semantic versioning.
* Add support for streaming responses in the Clojure API - (ca5ad63) Scott Walker <scott.walker@puppetlabs.com>
## 0.4.4
This is a maintenance release.
* [TK-196](https://tickets.puppetlabs.com/browse/TK-196) - update prismatic
dependencies to the latest versions.
## 0.4.3
This is a feature release.
* [TK-134](https://tickets.puppetlabs.com/browse/TK-134) - Introduced two new
optional client configuration settings:
- `connect-timeout-milliseconds`: maximum number of milliseconds that the
client will wait for a connection to be established.
- `socket-timeout-milliseconds`: maximum number of milliseconds that the
client will allow for no data to be available on the socket before
closing the underlying connection, 'SO_TIMEOUT' in socket terms.
## 0.4.2
This is a bugfix release.
* [TK-145](https://tickets.puppetlabs.com/browse/TK-145) - Fixed a bug which
caused some HTTP requests to incorrectly have `charset=UTF-8` added to their
`Content-Type` headers.
## 0.4.1
This is a maintenance release.
* Add documentation for making requests using the Java and Clojure clients.
* Upgrade jvm-ssl-utils (previously known as jvm-certificate-authority)
dependency to 0.7.0.
* Upgrade clj-kitchensink dependency to 1.0.0.
* Upgrade trapperkeeper dependency to 1.0.1.
## 0.4.0
This is a feature release which has some breaking changes.
* Support for non-client bound asynchronous requests has been removed from both
the Clojure and Java-layer APIs. This includes all of the request functions
that previously existed in the `client.async` Clojure namespace and the
request methods in the `AsyncHttpClient` Java class.
* Add a Java-layer API for getting an instance of an HttpClient on which
multiple requests -- e.g.., GET, POST -- can be made. Clients are created
via the `createClient` method on the new `Async` and `Sync` classes, for
a client that can make asynchronous or synchronous web requests, respectively.
* Non-client bound synchronous requests can still be performed through the Java
API but must now be done through the `Sync` classes rather than the
`SyncHttpClient` class. The `SyncHttpClient` class is now used as the type
of the instance that the `Sync.createClient()` method returns.
* The Java `RequestOptions` class was refactored into new `ClientOptions` and
`RequestOptions` classes which can be used with the client-bound `Async`
and `Sync` APIs. For non-client bound requests, options are now defined
via a `SimpleRequestOptions` class.
* Reworked connection close behavior to more robustly handle successful and
failed connections.
## 0.3.1
This is a bugfix release.
* Fix a memory leak that occurred as a result of connection failures.
## 0.3.0
This is a feature release.
* Add configuration settings for SSL Protocols and Cipher Suites to both the
Java and Clojure clients.
## 0.2.8
This is a bugfix release.
* Fix a bug in the Java client API that caused a file descriptor leak each time
a client was created for a new request.
## 0.2.7
This is a bugfix release.
* Fix a bug where the character encoding was always being set to ISO-8859-1 w/o
a charset ever being explicitly specified in the Content-Type header. We now
honor the existing charset if there is one in the header, and otherwise we
use UTF-8 and explicitly add the charset to the header.
## 0.2.6
* Add :follow-redirects and :force-redirects options to the clojure client.
* Add followRedirects and forceRedirects options to the Java client.
## 0.2.5
* Add an overloaded constructor for `RequestOptions` that accepts a String uri
## 0.2.4
* Fix a bug in the Java client API that caused an NPE if a Content-Type header
did not specify a charset
## 0.2.3
* No changes
## 0.2.2
* Add back in support for query-params map in Clojure API
## 0.2.1
* Upgrade to Apache HttpAsyncClient v4.0.2 (fixes a bug where headers don't get
included when following redirects).
## 0.2.0
* Port the code to use the Apache HttpAsyncClient library instead of
http-kit.
* The API around creating a persistent client has changed and
persistent clients are explicitly managed
* The available request options have changed. Some convenience options
have been removed.
## 0.1.7
* Explicitly target JDK6 when building release jars
## 0.1.6
* Add support for configuring client SSL context with a CA cert without a
client cert/key
## 0.1.5
* Update to latest version of puppetlabs/kitchensink
* Use puppetlabs/certificate-authority for SSL tasks
## 0.1.4
* Fix bug in sync.clj when excluding clojure.core/get
## 0.1.3
* Added a Java API for the synchronous client
# How to contribute
Third-party patches are essential for keeping puppet open-source projects
great. We want to keep it as easy as possible to contribute changes that
allow you to get the most out of our projects. There are a few guidelines
that we need contributors to follow so that we can have a chance of keeping on
top of things. For more info, see our canonical guide to contributing:
[https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md](https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md)
LICENSE 0 → 100644
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
{
"version": 1,
"file_format": "This MAINTAINERS file format is described at http://pup.pt/maintainers",
"issues": "https://tickets.puppetlabs.com/browse/TK",
"internal_list": "https://groups.google.com/a/puppet.com/forum/?hl=en#!forum/discuss-trapperkeeper-maintainers",
"people": [
{
"github": "rlinehan",
"email": "ruth@puppet.com",
"name": "Ruth Linehan"
},
{
"github": "scottyw",
"email": "scott.walker@puppet.com",
"name": "Scott Walker"
},
{
"github": "camlow325",
"email": "jeremy.barlow@puppet.com",
"name": "Jeremy Barlow"
}
]
}
include dev-resources/Makefile.i18n
# puppetlabs/http-client
[![Build Status](https://travis-ci.org/puppetlabs/clj-http-client.png?branch=master)](https://travis-ci.org/puppetlabs/clj-http-client)
This is a wrapper around the [Apache HttpAsyncClient
library](http://hc.apache.org/httpcomponents-asyncclient-4.0.x/) providing
some extra functionality for configuring SSL in a way compatible with Puppet.
## Installation
Add the following dependency to your `project.clj` file:
[![Clojars Project](http://clojars.org/puppetlabs/http-client/latest-version.svg)](http://clojars.org/puppetlabs/http-client)
## Details
Async versions of the http methods are exposed in
puppetlabs.http.client.async, and synchronous versions are in
puppetlabs.http.client.sync. For information on using these namespaces, see the page on
[making requests with clojure clients](doc/clojure-client.md).
Additionally, this library allows you to make requests using Java clients. For information
on how to do this, see the page on [making requests with java clients](doc/java-client.md).
## Support
We use the [Trapperkeeper project on JIRA](https://tickets.puppetlabs.com/browse/TK)
for tickets on clj-http-client, although Github issues are welcome too.
# -*- Makefile -*-
# This file was generated by the i18n leiningen plugin
# Do not edit this file; it will be overwritten the next time you run
# lein i18n init
#
# The name of the package into which the translations bundle will be placed
BUNDLE=puppetlabs.http_client
# The name of the POT file into which the gettext code strings (msgid) will be placed
POT_NAME=http-client.pot
# The list of names of packages covered by the translation bundle;
# by default it contains a single package - the same where the translations
# bundle itself is placed - but this can be overridden - preferably in
# the top level Makefile
PACKAGES?=$(BUNDLE)
LOCALES=$(basename $(notdir $(wildcard locales/*.po)))
BUNDLE_DIR=$(subst .,/,$(BUNDLE))
BUNDLE_FILES=$(patsubst %,resources/$(BUNDLE_DIR)/Messages_%.class,$(LOCALES))
FIND_SOURCES=find src -name \*.clj
# xgettext before 0.19 does not understand --add-location=file. Even CentOS
# 7 ships with an older gettext. We will therefore generate full location
# info on those systems, and only file names where xgettext supports it
LOC_OPT=$(shell xgettext --add-location=file -f - </dev/null >/dev/null 2>&1 && echo --add-location=file || echo --add-location)
LOCALES_CLJ=resources/locales.clj
define LOCALES_CLJ_CONTENTS
{
:locales #{$(patsubst %,"%",$(LOCALES))}
:packages [$(patsubst %,"%",$(PACKAGES))]
:bundle $(patsubst %,"%",$(BUNDLE).Messages)
}
endef
export LOCALES_CLJ_CONTENTS
i18n: msgfmt
# Update locales/<project-name>.pot
update-pot: locales/$(POT_NAME)
locales/$(POT_NAME): $(shell $(FIND_SOURCES)) | locales
@tmp=$$(mktemp $@.tmp.XXXX); \
$(FIND_SOURCES) \
| xgettext --from-code=UTF-8 --language=lisp \
--copyright-holder='Puppet <docs@puppet.com>' \
--package-name="$(BUNDLE)" \
--package-version="$(BUNDLE_VERSION)" \
--msgid-bugs-address="docs@puppet.com" \
-k \
-kmark:1 -ki18n/mark:1 \
-ktrs:1 -ki18n/trs:1 \
-ktru:1 -ki18n/tru:1 \
-ktrun:1,2 -ki18n/trun:1,2 \
-ktrsn:1,2 -ki18n/trsn:1,2 \
$(LOC_OPT) \
--add-comments --sort-by-file \
-o $$tmp -f -; \
sed -i.bak -e 's/charset=CHARSET/charset=UTF-8/' $$tmp; \
sed -i.bak -e 's/POT-Creation-Date: [^\\]*/POT-Creation-Date: /' $$tmp; \
rm -f $$tmp.bak; \
if ! diff -q -I POT-Creation-Date $$tmp $@ >/dev/null 2>&1; then \
mv $$tmp $@; \
else \
rm $$tmp; touch $@; \
fi
# Run msgfmt over all .po files to generate Java resource bundles
# and create the locales.clj file
msgfmt: $(BUNDLE_FILES) $(LOCALES_CLJ) clean-orphaned-bundles
# Force rebuild of locales.clj if its contents is not the the desired one. The
# shell echo is used to add a trailing newline to match the one from `cat`
ifneq ($(shell cat $(LOCALES_CLJ) 2> /dev/null),$(shell echo '$(LOCALES_CLJ_CONTENTS)'))
.PHONY: $(LOCALES_CLJ)
endif
$(LOCALES_CLJ): | resources
@echo "Writing $@"
@echo "$$LOCALES_CLJ_CONTENTS" > $@
# Remove every resource bundle that wasn't generated from a PO file.
# We do this because we used to generate the english bundle directly from the POT.
.PHONY: clean-orphaned-bundles
clean-orphaned-bundles:
@for bundle in resources/$(BUNDLE_DIR)/Messages_*.class; do \
locale=$$(basename "$$bundle" | sed -E -e 's/\$$?1?\.class$$/_class/' | cut -d '_' -f 2;); \
if [ ! -f "locales/$$locale.po" ]; then \
rm "$$bundle"; \
fi \
done
resources/$(BUNDLE_DIR)/Messages_%.class: locales/%.po | resources
msgfmt --java2 -d resources -r $(BUNDLE).Messages -l $(*F) $<
# Use this to initialize translations. Updating the PO files is done
# automatically through a CI job that utilizes the scripts in the project's
# `bin` file, which themselves come from the `clj-i18n` project.
locales/%.po: | locales
@if [ ! -f $@ ]; then \
touch $@ && msginit --no-translator -l $(*F) -o $@ -i locales/$(POT_NAME); \
fi
resources locales:
@mkdir $@
help:
$(info $(HELP))
@echo
.PHONY: help
define HELP
This Makefile assists in handling i18n related tasks during development. Files
that need to be checked into source control are put into the locales/ directory.
They are
locales/$(POT_NAME) - the POT file generated by 'make update-pot'
locales/$$LANG.po - the translations for $$LANG
Only the $$LANG.po files should be edited manually; this is usually done by
translators.
You can use the following targets:
i18n: refresh all the files in locales/ and recompile resources
update-pot: extract strings and update locales/$(POT_NAME)
locales/LANG.po: create translations for LANG
msgfmt: compile the translations into Java classes; this step is
needed to make translations available to the Clojure code
and produces Java class files in resources/
endef
# @todo lutter 2015-04-20: for projects that use libraries with their own
# translation, we need to combine all their translations into one big po
# file and then run msgfmt over that so that we only have to deal with one
# resource bundle
#
# This is the "override security properties file" which is used by default
# in the lein dev profile. End users may override java security properties in
# a similar manner in the production code.
#
# This file augments and overrides $JAVA_HOME/jre/lib/security/java.security
# when the java process is provided the option,
# -Djava.security.properties=./dev-resources/java.security
#
# NOTE: It is possible to make this file authoritative, discarding the values
# in $JAVA_HOME/jre/lib/security/java.security by setting the first character
# of the path to an '=' sign.
#
# Algorithm restrictions for Secure Socket Layer/Transport Layer Security
# (SSL/TLS) processing
# In some environments, certain algorithms or key lengths may be undesirable
# when using SSL/TLS. This section describes the mechanism for disabling
# algorithms during SSL/TLS security parameters negotiation, including
# protocol version negotiation, cipher suites selection, peer authentication
# and key exchange mechanisms.
#
# Disabled algorithms will not be negotiated for SSL/TLS connections, even
# if they are enabled explicitly in an application.
#
# For PKI-based peer authentication and key exchange mechanisms, this list
# of disabled algorithms will also be checked during certification path
# building and validation, including algorithms used in certificates, as
# well as revocation information such as CRLs and signed OCSP Responses.
# This is in addition to the jdk.certpath.disabledAlgorithms property above.
#
# See the specification of "jdk.certpath.disabledAlgorithms" for the
# syntax of the disabled algorithm string.
#
# Note: This property is currently used by Oracle's JSSE implementation.
# It is not guaranteed to be examined and used by other implementations.
#
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
#
# TK-143 Disable no algorithms so that unit tests are able to exercise the
# behavior of the system when the end user explicitly configures deprecated
# algorithms like SSLv3.
jdk.tls.disabledAlgorithms=
\ No newline at end of file
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %-5p [%t] [%c{2}] %m%n</pattern>
</encoder>
</appender>
<logger name="org.eclipse.jetty" level="warn"/>
<logger name="org.apache.http" level="warn"/>
<root level="warn">
<appender-ref ref="STDOUT" />
</root>
</configuration>
-----BEGIN CERTIFICATE-----
MIIEtzCCAp+gAwIBAgIBATANBgkqhkiG9w0BAQsFADAfMR0wGwYDVQQDDBRQdXBw
ZXQgQ0E6IGxvY2FsaG9zdDAeFw0xNDAzMjQyMTA2NDNaFw0xOTAzMjUyMTA2NDNa
MB8xHTAbBgNVBAMMFFB1cHBldCBDQTogbG9jYWxob3N0MIICIjANBgkqhkiG9w0B
AQEFAAOCAg8AMIICCgKCAgEAjFXy0dLKBEm9pG9f7x51sdD6HiQHA0kfGbRzNbSx
6psusOO7W3y5xvetpwnd5w+6uLHeNjysHKf4oq70foP3N34cFkEqPfizlYig1aBN
Wjq5tVDUQ/wdFuSvxzDVrTWRX5GUebqyyD8VRHcYON1FgeaZacpY7btmdG3kIWq/
Owb8Q4L7DRFJt3aePZ/QGiaTuxQD+CTVY1Wof/i4gGWJeDY3+WHv9b7TlUIU9Mw0
upaS2HuzlC/Xf0iFpr2CbEpYtXfZHS00uQ8ai0/BLrm1ro+D+Qx+4LWPBuEPPRzL
9hO85g3iJbSxgjEytfWE/yvnWZB5AeZKpDD45VfoK41yu53YWVuiLNoisjBTP33I
6d2ufmpmdBU4q+3wfOAd2IkxPNZVYnKvDCul5PP6PoNtxdSV9tDCU19F4hxTb2E6
/BUJQHlvReWNx/E+YAqnW/OFFeRKML8ot4vccAV1FKoVdVOMhih9D5BiYvxf+3PI
CSPvteYE0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BAQCKPpWBiM09HRBlS4WbOOM+BZCd
+15VO4bC+j8y/4R2TKUVTlRQW0aFwS6wiNBpSHsh20LESI9vlabOG2X7kJCc17QS
LswdMmu7YF5HRgW1OeJhUkywbqeZJGdD0uBBKZy0zuygBVJQDyXLI0GukSjJITW9
j6k6EKDLM5JMmydKih27ObJ1ztDRiGVZaQBX4XqEFxW8AFRIFm3c4Tvz9bxZbC87
fKwayKfc5ClVa/8eQJLvLLWJ1fnb8YyAUYXFUMXfv3AN5cu+Y/KmbIY/6CYd77y8
RQaRtpg14BH7su8Ynjzr0TRB88O6XXFMf59sa5qTCx8Q88JwdrygQcc2jccI
-----END RSA PRIVATE KEY-----
## Making requests with clojure clients
clj-http-client allows you to make requests in two ways with clojure clients: with and without a persistent HTTP client.
## `create-client`
clj-http-client allows you to create a persistent synchronous or asynchronous HTTP client using the
`create-client` function from the corresponding namespace.
The `create-client` function takes one argument, a map called `options`. The available options
for configuring the client are detailed below.
### Base Options
The following are the base set of options supported by the `create-client` functions.
* `:force-redirects`: used to set whether or not the client should follow
redirects on POST or PUT requests. Defaults to false.
* `:follow-redirects`: used to set whether or not the client should follow
redirects in general. Defaults to true. If set to false, will override
the :force-redirects setting.
* `:connect-timeout-milliseconds`: maximum number of milliseconds that the
client will wait for a connection to be established. A value of 0 is
interpreted as infinite. A negative value for or the absence of this option
is interpreted as undefined (system default).
* `:socket-timeout-milliseconds`: maximum number of milliseconds that the
client will allow for no data to be available on the socket before closing the
underlying connection, 'SO_TIMEOUT' in socket terms. A timeout of zero is
interpreted as an infinite timeout. A negative value for or the absence of
this setting is interpreted as undefined (system default).
* `:ssl-protocols`: an array used to set the list of SSL protocols that the client
could select from when talking to the server. Defaults to 'TLSv1',
'TLSv1.1', and 'TLSv1.2'.
* `:cipher-suites`: an array used to set the cipher suites that the client could
select from when talking to the server. Defaults to the complete
set of suites supported by the underlying language runtime.
* `:metric-registry`: a Dropwizard `MetricRegistry` to register http metrics
to. If provided, metrics will automatically be registered for all requests
made by the client. See the [metrics documentation](./metrics.md) for more
info.
* `:server-id`: a string for the name of the server the request is being made
from. If specified, used in the namespace for metrics:
`puppetlabs.<server-id>.http-client.experimental`.
* `:metric-prefix`: a string for the prefix for metrics. If specified, metric
namespace is `<metric-prefix>.http-client.experimental`. If both
`metric-prefix` and `server-id` are specified, `metric-prefix` takes
precendence.
### SSL Options
The following options are SSL specific, and only one of the following combinations is permitted.
* `:ssl-context`: an instance of [SSLContext](http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLContext.html)
OR
* `:ssl-cert`: path to a PEM file containing the client cert
* `:ssl-key`: path to a PEM file containing the client private key
* `:ssl-ca-cert`: path to a PEM file containing the CA cert
OR
* `:ssl-ca-cert`: path to a PEM file containing the CA cert
### Making requests with a persistent client
The `create-client` functions return a client
with the following protocol:
```clj
(defprotocol HTTPClient
(get [this url] [this url opts])
(head [this url] [this url opts])
(post [this url] [this url opts])
(put [this url] [this url opts])
(delete [this url] [this url opts])
(trace [this url] [this url opts])
(options [this url] [this url opts])
(patch [this url] [this url opts])
(close [this]))
```
Each function will execute the corresponding HTTP request, with the exception of `close`, which
will close the client.
Each request function takes one argument, `url`, which is the URL against which you want to make
your HTTP request. Each request function also has a two-arity version with an extra parameter, `options`,
which is a map containing options for the HTTP request. These options are as follows:
* `:headers`: optional; a map of headers. By default an 'accept-language' header
with a value of `puppetlabs.core.i18n/user-locale` will be added to the
request.
* `:body`: optional; may be a String or any type supported by clojure's reader
* `:compress-request-body`: optional; used to control any additional compression
which the client can apply to the request body before it is sent to the target
server. Defaults to `:none`. Supported values are:
* `:gzip` which will compress the request body as gzip
* `:none` which will not apply any additional compression to the request body
* `:decompress-body`: optional; if `true`, an 'accept-encoding' header with a value of
'gzip, deflate' will be added to the request, and the response will be
automatically decompressed if it contains a recognized 'content-encoding'
header. Defaults to `true`.
* `:as`: optional; used to control the data type of the response body. Defaults to `:stream`. Supported values
are:
* `:text` which will return a `String`
* `:stream` which will return an `InputStream`
* `:unbuffered-stream` which is a variant of `:stream` that will buffer as little data as possible
* `:query-params`: optional; used to set the query parameters of an http request. This should be
a map, where each key and each value is a String.
* `:metric-id`: optional; a vector of keywords or strings. A metric will be created for
each element in the vector, with each appending to the previous.
For example, say you want to make a GET request with
query parameter `abc` with value `def` to the URL `http://localhost:8080/test`. If you wanted to use a
persistent synchronous client, you could make the request and print the body of the response like so:
```clj
(let [client (sync/create-client {})
response (get client "http://localhost:8080/test" {:query-params {"abc" "def"}})]
(println (:body response))
```
If you wanted to use an asynchronous client, you could make the request and print the body of the response like so:
```clj
(let [client (async/create-client {})
response (get client "http://localhost:8080/test" {:query-params {"abc" "def"}})]
(println (:body @response)))
```
### Closing a persistent client
The `close` function takes no arguments. This function closes the client, and causes
all resources associated with it to be cleaned up. This function must be called by the caller when
they are done making requests with the client, as no implicit cleanup of the associated resources
is done when the client is garbage collected. Once a client is closed, it can no longer be used to
make any requests.
## Making a Request without a persistent client
In addition to allowing you to create a persistent client with the `create-client` function, the
puppetlabs.http.client.sync namespace provides the following simple request functions that can be
called without a client:
```clj
(get [url] [url opts])
(head [url] [url opts])
(post [url] [url opts])
(put [url] [url opts])
(delete [url] [url opts])
(trace [url] [url opts])
(options [url] [url opts])
(patch [url] [url opts])
(request [req])
```
These functions will, for every request, create a new client, make a new request with that client, and then
close the client once the response is received. Each of these functions (barring `request`) take one argument,
`url`, which is the URL to which you want to make the request, and can optionally take a second argument, `options`.
`options` is a map of options to configure both the client and the request, and as such takes the union of all options
accepted by the `create-client` function and all options accepted by the request functions for a persistent
client.
For example, say you want to make a GET request to the URL `http://localhost:8080/test` with query parameter
`abc` with value `def`, and you do not want redirects to be followed. In that case, you could do the following
to make the request and print the body of the response:
```clj
(let [response (get "http://localhost:8080/test" {:follow-redirects false
:query-params {"abc" "def"}})]
(println (:body response)))
```
A `request` function is also provided, which allows you to make a request of any type.
`request` takes one argument, `req`, which is a map of options. It takes the same options as the simple request
functions, but also takes the following required options:
* `:url`: the URL against which to make the request. This should be a string.
* `:method`: the HTTP method (:get, :head, :post, :put, :delete, :trace, :options, :patch)
## Making requests with the Java client
Similarly to the way it is done in clojure code, clj-http-client allows you to make requests
in two ways using Java: with and without a persistent client.
## `createClient(ClientOptions clientOptions)`
clj-http-client allows you to create a persistent synchronous or asynchronous HTTP client using the static
`createClient()` method in the [`Async`](../src/java/com/puppetlabs/http/client/Async.java) and
[`Sync`](../src/java/com/puppetlabs/http/client/Sync.java) classes
This method takes one argument, `clientOptions`, which is an instance of the
[`ClientOptions`](../src/java/com/puppetlabs/http/client/ClientOptions.java) class, details on which can
be found in its javadoc strings, linked above.
### Making requests with a persistent client
The `createClient()` method returns an object implementing the [`SyncHttpClient`](../src/java/com/puppetlabs/http/client/SyncHttpClient.java)
interface in the case of `Sync`, and the [`AsyncHttpClient`](../src/java/com/puppetlabs/http/client/AsyncHttpClient.java) interface
in the case of `Async`. Information on the various methods available is detailed in the javadoc strings for the corresponding
interfaces, which are linked above. The various request methods provided by these interfaces can take
a [`RequestOptions`](../src/java/com/puppetlabs/http/client/RequestOptions.java) object, information on
which can be found in that class' javadoc strings, linked above.
For example, say you want to make a GET request
against the URL `http://localhost:8080/test` with query parameter `abc` with value `def`. To make the request
and print the body of the response with a persistent synchronous client, you could do the following:
```java
ClientOptions options = new ClientOptions();
SyncHttpClient client = Sync.createClient(options);
Response response = client.get(new URI("http://localhost:8080/test?abc=def"));
System.out.println(response.getBody());
```
If instead you wanted to use an asynchronous client, you could do the following:
```java
ClientOptions options = new ClientOptions();
AsyncHttpClient client = Async.createClient(options);
Promise<Response> response = client.get(new URI("http://localhost:8080/test?abc=def"));
System.out.println(response.deref().getBody());
```
### Closing the client
Each persistent client provides a `close` method, which can be used to close the client. This method will close
the client and clean up all resources associated with it. It must be called by the caller when finished using the
client to make requests, as there is no implicit cleanup of the associated resources when the client is garbage
collected. Once the client is closed, it can no longer be used to make requests.
## Making a Request without a persistent client
In addition to allowing you to create a persistent client with the `createClient()` method, the
[`Sync`](../src/java/com/puppetlabs/http/client/Sync.java) class contains a number of simple request methods
that allow for requests to be made without a persistent client. These are detailed in `Sync.java`'s
javadoc strings, linked above. Many of the provided request methods take a
[`SimpleRequestOptions`](../src/java/com/puppetlabs/http/client/SimpleRequestOptions.java) object. Information
on this class can be found in its javadoc strings, linked above.
As an example, say you wanted to make a request to the URL `http://localhost:8080/test` without a persistent client.
You want the query parameter `abc` with value `def`, and you don't want redirects to be followed. In that case, you
would do the following to print the body of the response:
```java
SimpleRequestOptions options = new SimpleRequestOptions(new URI("http://localhost:8080/test?abc=def"));
options = options.setFollowRedirects(false);
Response response = Sync.get(options);
System.out.println(response.getBody());
```
\ No newline at end of file
# Metrics
Both the Java client and the Clojure client have [Dropwizard
Metrics](http://metrics.dropwizard.io/3.1.0/) support - they both accept as an
option a `MetricRegistry` to which they will register http metrics for each
request, as well as metrics for any metric-ids specified in the request
options. This support is experimental - names of metrics and the exact API may
change.
For using metrics with either the Java client or the Clojure client you must
already have created a Dropwizard `MetricRegistry`.
- [Metric namespace](#metric-namespace)
- [Types of metrics](#types-of-metrics)
- [Getting back metrics](#getting-back-metrics)
- [Clojure API](#clojure-api)
- [Creating a client with metrics](#creating-a-client-with-metrics)
- [Setting a metric-id](#setting-a-metric-id)
- [Filtering metrics](#filtering-metrics)
- [Filtering by URL](#filtering-by-url)
- [Filtering by URL and method](#filtering-by-url-and-method)
- [Filtering by metric-id](#filtering-by-metric-id)
- [Java API](#java-api)
- [Creating a client with metrics](#creating-a-client-with-metrics-1)
- [Setting a metric-id](#setting-a-metric-id-1)
- [Filtering metrics](#filtering-metrics-1)
- [Filtering by URL](#filtering-by-url-1)
- [Filtering by URL and method](#filtering-by-url-and-method-1)
- [Filtering by metric-id](#filtering-by-metric-id-1)
## Metric namespace
By default, http metrics are prefixed with the namespace
`puppetlabs.http-client.experimental`. This namespace can be customized with two
client options, `server-id` and `metric-prefix`.
When `server-id` is set, the metric namespace becomes
`puppetlabs.<server-id>.http-client.experimental`.
When `metric-prefix` is set, the metric namespace becomes
`<metric-prefix>.http-client.experimental`.
If both `server-id` and `metric-prefix` are set, `metric-prefix` wins out and
a warning message is logged.
For a Clojure client, the `get-client-metric-namespace` protocol method can
be used to get back the metric namespace set for the client.
For a Java client, the `getMetricNamespace` method can be used to get back the
configured metric namespace.
## Types of metrics
There are two types of metrics: *full response* and *initial response*. Full
response metrics stop when all bytes of the response have been read by the
client. Initial response metrics stop when the first byte of the response has
been received by the client. Full response metrics are suffixed with
`full-response`. Initial response metric support has not yet been
implementedare suffixed with `full-response`. Initial response metric support
has not yet been implemented.
There are three categories of metrics: `url` metrics, `url-and-method`
metrics, and `metric-id` metrics. `url` and `url-and-method` metrics are
created automatically for each request; `metric-id` metrics are only created
for requests that have a `metric-id` request option specified.
Each http request will have a metric name created for its url (stripped of
query strings and url fragments), as well as for the url + method name. `url`
metrics have `with-url` after the prefix, followed by the url.
`url-and-method` metrics have `with-url-and-method` after the prefix, followed
by the url and then the capitalized HTTP method.
So, for example, a `GET` request to `http://foobar.com` would create a metric
`puppetlabs.http-client.experimental.with-url.http://foobar.com.full-response`
and a metric
`puppetlabs.http-client.experimental.with-url-and-method.http://foobar.com.GET.full-response`.
It is also possible to give a request a `metric-id`. The `metric-id` is an
array of strings. For each element in the array, a metric name will be
created, appending to the previous elements. `metric-id` metrics have
`with-metric-id` after the metric prefix, followed by the metric-id.
So, for example, for a metric-id `["foo", "bar", "baz"]`, the metrics
`puppetlabs.http-client.experimental.with-metric-id.foo.full-response`,
`puppetlabs.http-client.experimental.with-metric-id.foo.bar.full-response`,
and
`puppetlabs.http-client.experimental.with-metric-id.foo.bar.baz.full-response`
would be created.
## Getting back metrics
Both the Clojure API and the Java API have functions to get back from a
`MetricRegistry` either the `Timer` objects or a selection of metric data, and
to filter this information based on url, url and method, or metric-id.
There are three different `Timer` objects: `UrlClientTimer` (which includes a
field for the url and `getUrl` method), `UrlAndMethodClientTimer` (which
includes a field for the url and a field for the method and accompanying
`getUrl` and `getMethod` methods), and `MetricIdClientTimer` (which includes a
field for the metric-id and accompanying `getMetricId` method). Each of these
timers also has an `isCategory` method that returns whether the timer is or is
not the provided `MetricCategory`.
Both the Clojure and Java APIs also include functions that return a list of
metrics data. This metrics data includes the `metric-name`, `count`, `mean`
(in ms), and `aggregate` (computed as `count * mean`) for each metric. In
addition, for `url` metrics the accompanying metrics data includes the `url`,
for `url-and-method` metrics it includes the `url` and `method`, and for
`metric-id` metrics it includes the `metric-id`.
The Java API returns `ClientMetricData` objects - of which there are three
types - `UrlClientMetricData`, `UrlAndMethodClientMetricData`, and
`MetricIdClientMetricData`. The Clojure API returns maps with keys for this
information.
Both APIs have functions for returning all metrics/metric data, for returning
all metrics/metrics data from a specific category, and for filtering
metrics/metrics data within a category.
## Clojure API
### Creating a client with metrics
To use metrics with the Clojure client, pass a `MetricRegistry` to it as part
of the options map:
```clojure
(async/create-client {:metric-registry (MetricRegistry.)})
```
(the same works with the `sync` client).
In [Trapperkeeper](https://github.com/puppetlabs/trapperkeeper) applications,
creating and managing a `MetricRegistry` can be done easily with
[trapperkeeper-metrics](https://github.com/puppetlabs/trapperkeeper-metrics):
```clojure
(defservice my-trapperkeeper-service
MyService
[[:MetricsService get-metrics-registry]]
(init [this context]
(let [registry (get-metrics-registry)
client (async/create-client {:metric-registry registry})]
...)))
```
Any client that is created with a `MetricRegistry` will automatically have
`url` and `url-and-method` metrics registered.
`get-client-metric-registry` protocol function can be called on a client to
get the `MetricRegistry` from it.
### Setting a metric-id
In addition to the `url` and `url-and-method` metrics, it is possible to set a
`metric-id` for a request that will create additional metrics.
For the Clojure API, a `metric-id` is a vector of keywords or strings. Either
is supported by the API, however, if special characters are needed, use
strings. Note than even when specified as a vector of keywords in the request
option, the metric-id will be returned as a vector of strings in the metrics
data.
To set a `metric-id` for a request, include it as an option in the request
options map.
```clojure
(common/get client "https://foobar.com" {:metric-id [:foo :bar :baz]})
(common/get client "https://foobar.com" {:metric-id ["f/o/o"]})
```
### Filtering metrics
To get all `Timer` objects registered for a `MetricRegistry`, use the
`get-client-metrics` function in the `metrics` namespace. This takes the
`MetricRegistry` as an argument and returns a map with three keys: `:url`
`:url-and-method`, and `:metric-id`. Under each of these keys is a sequence of
`Timer` objects of the corresponding type. If there are no timers of a certain
type, the sequence will be empty. The output of this function conforms to the
`common/AllTimers` schema.
Example:
```clojure
(common/get client "http://test.com" {:metric-id [:foo :bar :baz]})
...
(metrics/get-client-metrics metric-registry)
=>
{:url [#object[com.puppetlabs.http.client.metrics.UrlClientTimer
0x66cf1f05
"com.puppetlabs.http.client.metrics.UrlClientTimer@66cf1f05"]]
:url-and-method [#object[com.puppetlabs.http.client.metrics.UrlAndMethodClientTimer
0x6fe5444c
"com.puppetlabs.http.client.metrics.UrlAndMethodClientTimer@6fe5444c"]]
:metric-id [#object[com.puppetlabs.http.client.metrics.MetricIdClientTimer
0x690c10c5
"com.puppetlabs.http.client.metrics.MetricIdClientTimer@690c10c5"]
#object[com.puppetlabs.http.client.metrics.MetricIdClientTimer
0xb7aca2e
"com.puppetlabs.http.client.metrics.MetricIdClientTimer@b7aca2e"]
#object[com.puppetlabs.http.client.metrics.MetricIdClientTimer
0x4ef82829
"com.puppetlabs.http.client.metrics.MetricIdClientTimer@4ef82829"]]}
```
To get metric data for all `Timer`s registered on a `MetricRegistry`, use the
`get-client-metrics-data` function. This takes the `MetricRegistry` and returns
a map with `:url`, `:url-and-method`, and `:metric-id` as keys. Under each of
these keys is a sequence of maps, each map containing metrics data (see
[Getting back metrics](#Getting-back-metrics) above, conforming to the
`common/AllMetricsData` schema.
Example:
```clojure
(common/get client "http://test.com" {:metric-id [:foo :bar :baz]})
...
(metrics/get-client-metrics-data metric-registry)
=>
{:url ({:count 1
:mean 553
:aggregate 553
:metric-name "puppetlabs.http-client.experimental.with-url.http://test.com.full-response"
:url "http://test.com"})
:url-and-method ({:count 1
:mean 554
:aggregate 554
:metric-name "puppetlabs.http-client.experimental.with-url-and-method.http://test.com.GET.full-response"
:url "http://test.com"
:method "GET"})
:metric-id ({:count 1
:mean 554
:aggregate 554
:metric-name "puppetlabs.http-client.experimental.with-metric-id.foo.bar.baz.full-response"
:metric-id ["foo" "bar" "baz"]}
{:count 1
:mean 554
:aggregate 554
:metric-name "puppetlabs.http-client.experimental.with-metric-id.foo.bar.full-response"
:metric-id ["foo" "bar"]}
{:count 1
:mean 554
:aggregate 554
:metric-name "puppetlabs.http-client.experimental.with-metric-id.foo.full-response"
:metric-id ["foo"]})}
```
#### Filtering by URL
To get URL metrics and metrics data, use the `get-client-metrics-by-url`
function and `get-client-metrics-data-by-url` in the `metrics` namespace.
Both of these take as arguments the `MetricRegistry` and a string url. If no
url is provided, return all url metrics/metrics data in a sequence. If no
metrics are registered for that url, return an empty sequence.
Example:
```clojure
(common/get client "http://test.com" {:metric-id [:foo :bar :baz]})
...
(metrics/get-client-metrics-data-by-url metric-registry "http://test.com")
=>
({:count 1
:mean 553
:aggregate 553
:metric-name "puppetlabs.http-client.experimental.with-url.http://test.com.full-response"
:url "http://test.com"})
(metrics/get-client-metrics-data-by-url metric-registry "http://not-a-matching-url.com")
=> ()
```
#### Filtering by URL and method
To get URL and method metrics and metrics data, use the
`get-client-metrics-by-url-and-method` and
`get-client-metrics-data-by-url-and-method` functions in the `metrics`
namespace.
Both of these take as arguments the `MetricRegistry`, a string url, and a
keyword HTTP method. If no url and method is provided, return all url
metrics/metrics data in a sequence. If no metrics are registered for that url
and method, return an empty sequence.
Example:
```clojure
(common/get client "http://test.com" {:metric-id [:foo :bar :baz]})
...
(metrics/get-client-metrics-data-by-url-and-method metric-registry "http://test.com" :get)
=>
({:count 1
:mean 554
:aggregate 554
:metric-name "puppetlabs.http-client.experimental.with-url-and-method.http://test.com.GET.full-response"
:url "http://test.com"
:method "GET"})
:method "GET"})
(metrics/get-client-metrics-data-by-url-and-method metric-registry "http://test.com" :post)
=> ()
```
#### Filtering by metric-id
To get metric-id metrics and metrics data, use the
`get-client-metrics-by-metric-id` and `get-client-metrics-data-by-metric-id`
functions in the `metrics` namespace.
Both of these take as arguments the `MetricRegistry` and a metric-id - as a
vector of keywords or strings (if special characters are needed, use strings).
If no metric-id is provided, will return all metric-id metrics. If no metrics
are registered for that metric-id, returns an empty list.
Example:
```clojure
(common/get client "http://test.com" {:metric-id [:foo :bar :baz]})
...
(metrics/get-client-metrics-data-by-metric-id metric-registry [:foo])
=>
({:count 1
:mean 554
:aggregate 554
:metric-name "puppetlabs.http-client.experimental.with-metric-id.foo.full-response"
:metric-id ["foo"]})
(metrics/get-client-metrics-data-by-metric-id metric-registry [:foo :bar])
=>
({:count 1
:mean 554
:aggregate 554
:metric-name "puppetlabs.http-client.experimental.with-metric-id.foo.bar.full-response"
:metric-id ["foo" "bar"]})
(metrics/get-client-metrics-data-by-metric-id metric-registry [:foo :nope])
=> ()
```
## Java API
### Creating a client with metrics
To use metrics with the Java client, call `setMetricRegistry()` on the
`ClientOptions` before supplying them to create the client.
```java
MetricRegistry registry = new MetricRegistry();
ClientOptions options = new ClientOptions();
AsyncHttpClient client = Async.createClient(options);
```
(the same works with the `SyncHttpClient`).
Any client that is created with a `MetricRegistry` will automatically have
`url` and `url-and-method` metrics registered.
`getMetricRegistry()` can be called on a client to get the `MetricRegistry`
from it.
### Setting a metric-id
In addition to the `url` and `url-and-method` metrics, it is possible to set a
`metric-id` for a request that will create additional metrics.
A `metric-id` is an array of strings.
To set a `metric-id` for a request, use the `.setMetricId` method on the
`RequestOptions` class.
```java
RequestOptions options = new RequestOptions("https://foobar.com");
options.setMetricId(["foo", "bar", "baz"]);
client.get(options);
```
`getMetricId()` can be called on `RequestOptions` to get back the `metric-id`.
### Filtering metrics
To get all `Timer` objects registered for a `MetricRegistry`, use the
`getClientMetrics()` method in the `Metrics` class. This takes the
`MetricRegistry` as an argument and returns a `ClientTimerContainer` object.
The `ClientTimerContainer` object has three fields - `urlTimers`,
`urlAndMethodTimers`, and `metricIdTimers`. The list of `URLClientTimers` can
be retrieved from the `ClientTimerContainer` with the `getUrlTimers()` method.
A list of `URlAndMethodClientTimers` can be retrieved with the
`getUrlAndMethod()` method. A list of `MetricIdClientTimer`s can be retrieved
with the `getMetricIdTimers()` method.
To get all `MetricData` objects, representing data for each `Metric`
registered for a `MetricRegistry`, use the `getClientMetricsData()` methods in
the `Metric` class. This takes the `MetricRegistry` as an argument and returns
a `ClientMetricDataContainer` object. This object has a field for each type of
metric data - `urlData`, `urlAndMethodData`, and `metricIdData`. Each field
has an associated getter returning a list of the appropriate data object -
`UrlClientMetricData`, `UrlAndMethodClientMetricData`, and
`MetricIdClientMetricData`.
#### Filtering by URL
To get URL metrics and metrics data, use the `getClientMetricsByUrl()` and
`getClientMetricsDataByUrl()` methods in the `Metric` class.
Both of these take as arguments the `MetricRegistry` and a string url. If no
url is provided, return all url metrics. If no metrics are registered for that
url, return an empty list.
`getClientMetricsByUrl()` returns a list of `UrlClientTimer` objects.
`getClientMetricsDataByUrl` returns a list of `UrlClientMetricData` objects.
#### Filtering by URL and method
To get URL and method metrics and metrics data, use the
`getClientMetricsByUrlAndMethod()` and `getClientMetricsDataByUrlAndMethod()`
methods in the `Metric` class.
Both of these take as arguments the `MetricRegistry`, a string url, and a
string HTTP method. If no url or method is provided, will return all
url-and-method metrics. If no metrics are registered for that url and method,
returns an empty list.
`getClientMetricsByUrlAndMethod()` returns a list of `UrlAndMethodClientTimer`
objects. `getClientMetricsDataByUrlAndMethod` returns a list of
`UrlAndMethodClientMetricData` objects.
#### Filtering by metric-id
To get metric-id metrics and metrics data, use the
`getClientMetricsByMetricId()` and `getClientMetricsDataByMetricId()` methods
in the `Metric` class.
Both of these take as arguments the `MetricRegistry` and a metric-id - as an
array of strings. If no metric-id is provided, will return all metric-id
metrics. If no metrics are registered for that metric-id, returns an empty
list.
`getClientMetricsByMetricId()` returns a list of `MetricIdClientTimer`
objects. `getClientMetricsDataByMetricId()` returns a list of
`MetricIdClientMetricData` objects.
#!/bin/bash
set -e
lein2 test :all
#!/usr/bin/env bash
set -e
set -x
git fetch --tags
lein test
echo "Tests passed!"
lein release
echo "Release plugin successful, pushing changes to git"
git push origin --tags HEAD:$BRANCH
echo "git push successful."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment