├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .settings.xml ├── .travis.yml ├── LICENSE ├── README.md ├── RELEASE.md ├── header.txt ├── mvnw ├── mvnw.cmd ├── opentracing-aws-sdk-1 ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── opentracing │ │ └── contrib │ │ └── aws │ │ ├── SpanDecorator.java │ │ └── TracingRequestHandler.java │ └── test │ ├── java │ └── io │ │ └── opentracing │ │ └── contrib │ │ └── aws │ │ └── TracingRequestHandlerTest.java │ └── resources │ └── libs │ ├── libsqlite4java-linux-amd64.so │ ├── libsqlite4java-linux-i386.so │ ├── libsqlite4java-osx.dylib │ ├── sqlite4java-win32-x64.dll │ └── sqlite4java-win32-x86.dll ├── opentracing-aws-sdk-2 ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── opentracing │ │ └── contrib │ │ └── aws2 │ │ └── TracingExecutionInterceptor.java │ └── test │ ├── java │ └── io │ │ └── opentracing │ │ └── contrib │ │ └── aws2 │ │ └── Aws2Test.java │ └── resources │ └── libs │ ├── libsqlite4java-linux-amd64.so │ ├── libsqlite4java-linux-i386.so │ ├── libsqlite4java-osx.dylib │ ├── sqlite4java-win32-x64.dll │ └── sqlite4java-win32-x86.dll ├── pom.xml └── travis └── publish.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | target/ 4 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip -------------------------------------------------------------------------------- /.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 21 | 22 | 23 | sonatype 24 | ${env.SONATYPE_USER} 25 | ${env.SONATYPE_PASSWORD} 26 | 27 | 28 | bintray 29 | ${env.BINTRAY_USER} 30 | ${env.BINTRAY_KEY} 31 | 32 | 33 | jfrog-snapshots 34 | ${env.BINTRAY_USER} 35 | ${env.BINTRAY_KEY} 36 | 37 | 38 | github.com 39 | ${env.GH_USER} 40 | ${env.GH_TOKEN} 41 | 42 | 43 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | 4 | language: java 5 | jdk: 6 | - oraclejdk8 7 | 8 | cache: 9 | directories: 10 | - $HOME/.m2/repository 11 | 12 | before_install: 13 | # allocate commits to CI, not the owner of the deploy key 14 | - git config user.name "opentracingci" 15 | - git config user.email "opentracingci+opentracing@googlegroups.com" 16 | 17 | # setup https authentication credentials, used by ./mvnw release:prepare 18 | - git config credential.helper "store --file=.git/credentials" 19 | - echo "https://$GH_TOKEN:@github.com" > .git/credentials 20 | 21 | install: 22 | # Override default travis to use the maven wrapper 23 | - ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 24 | 25 | script: 26 | - ./travis/publish.sh 27 | 28 | branches: 29 | except: 30 | - /^[0-9]/ 31 | 32 | after_success: 33 | - mvn jacoco:report coveralls:report 34 | 35 | env: 36 | global: 37 | # Ex. travis encrypt BINTRAY_USER=your_github_account 38 | - secure: "XZd6y7YV7MkQIebrZr4+8+QLemCSVdr0pteRjBlwYf4y0eSN0LBe+436Evfw3XSKtYMn4ffdHhldellEwS5+dbngM5yZSGo9mzfTR8y2FRMmWyJRMS4Kkx+nMEev0ig/w5JQwX6I31MgQcJt5qq/jPmEew90eHhjlM7eo1PMO3B7qnpoDeGPM44/G2oNnAOKSWdqohpT8U0Qg4B8E1HJr0v61UcZ6Ed0yO46SdAzTLRuXEkBEo+qkWCwewTcvKH8sB/8mKDH9fms2pqqFu3CamsOnHm1TBG07YADTd5Pi0MH8p2V2HcnMxmuZnQuFHzVi+3SHcOqr257CJLPqHZMlmeai4fZWodKt87kKI7QF5KXss41Z34XxzAEz+6PEWQUBK+pHIYqRxeUvoI2NGctFB+uo/5U+mRd4X45SIbJ2b0GuBvYf+COsYlzbR35vibrkN+tsuFtkIEFi92agKoWeCJIRxDMyKa6/jkYslaIqgWYPO/pL3Gw3zESKjkETUVpPS+7C/+1TqHxHpXYrTwKDT9tXOxuo1iJ1SG8mjzjklKEIesUocLwkKJXjWdN1x9dI313p4i0XyrXT0zWPB2PTR/Nnu5fHkNGXyT+coyyQruuPzX27ZQo8u5fkPRu2xEHqiEwDzh3vVNDN4yR9pSXYMSXSU26vZqZXx4v727qS8E=" 39 | # Ex. travis encrypt BINTRAY_KEY=xxx-https://bintray.com/profile/edit-xxx --add 40 | - secure: "Y3I23WWrVsMXsfHHcMujf4LZWZT3qa1GMI7ddYLzDsNUD2INMa1W1fU8eXJ2V1uLmt22exQCrh5I7nATlI8S85qL8Liam8QrIFmYJdDTuV9kwmEpZT4t4oqp/TibdhPDGtqDIupj2ft7eOQFU/uYUAnG4FgBClT0zFWokr/rUr8KQEJqL3Fzsi+moyPUFGw250C8GZBOb51fA/+0n33OPUXJi/hVRixsS6TE+jGqzbNbAwsHbbE9E2znEoxcngB3FbzydFIQxdkM7FRtCiuBVWmDy5XuqftxA9wECI1pJn4DjTD4Tvm6cPhngabEy3gUH9Z+JaWWmgyhZT0kn/R5j53WjkJ1R+yvZ1rY/gnztc3buEBgJr1AUci3OrA2YwglJNpA/7nq6eQkztwMZ9Pkwe11PjY9899IA+PMzQ+3/5NdWG13ZkQEYR7/Wb9a3pPo5WJLaIFSjMfawhluU79/y+qz+rZ3QBp0pzscCvZICujR3umHVRzw9rY4fmSYSFXB++RIPa0quVWfEv2pX2fGn7viUbBG5/CWos3SWekBx8aW7wSRaW+Nflf+K+FHmi7L2ZcbWjNJEQdx4AZRkPd0SF0uREW5h5KP9fyN5tXaBPufe4+afj3iruajetYq2nZPoR9ZhBbG0vEFujv2Cx8NLGdVSSdRRWLSnlyVW7feLpQ=" 41 | # Ex. travis encrypt GH_TOKEN=XXX-https://github.com/settings/tokens-XXX --add 42 | - secure: "rKaR7fmJEzteucbZVhyiFgtae4opfMGbdwTX1LD8c8tJRLzEvfn7BDod9Eos7guBz6d75842gi3aGGX3V/yeFtxK8y3F+nEm1YXv45TnAgHznuamsQvzjiRyAMRp8bHqj3H/L9E2gu8Ix9FMDxiW86HJ3gGdRr1THmTNipdX2LOYyb64Xen4pIkzsE4XtseCG1xPtlNYp/uFe+IkjBgXiDHKoUR4vNlnck9rL3/MdnTo0Xw571wyesuU1b/REvbCPE//eTFDKDDJmc0Yq9y6u4IovrP0cti58tHUSu+tXseGyKsclcrgLxwdjZxoYxJJuCtioEnkjjqbunPz1XKUan8qdhCj0BNPNFY88KnH3wBkajL9xoAQ0XyKgRgk4jxGX5Co1yntjo5W6m/HLKtyC6Z3cHU2rfwqzC7/elT1sGPwHRSyGMPmPNUnuXGAFBVSA4voK8169gAUjkbV30v/y8L77R2mSLUS0svLYNXMWVpOzSy14iaOwVkRAfp/G35QFjyPBsmZhbwztAW1pyD+KPpbWQaT3qfosnKy0K/vhOiLm1v9X0mgFpHzZR3d+G5vV7CfQhtZRqjk7U5Fb6wdpSPjuZCxmtkwgLLqVgQRyxapxKilRhKOFPEJfURyilrXMZwI85x/BKQm7lkO0OJwvG/+YxDVXUSyxO7x1Y/t3MI=" 43 | # Ex. travis encrypt SONATYPE_USER=your_sonatype_account 44 | - secure: "Xa6pTz7zPkB5qTC9+I4MzbyaTrvyEz6AbKSb6Pv5Z1mUlC2vexY1FqembciUS0jV64kjXrVGTqcN9+9NLoxmPW0WESf8ivpVLcZP0JcFvg4+Qmmq4ngzX5CNovtmELjwxMHyqzUg0jRU8j00jv9CUc5lYnvjgoAECfFTQRw62dn3fnfFuwsRP42zk2AKmhvo8jzXpmsvymhPHN4DxAqGjzN1UYc/TpIhY3h1IZXH2GeV95tSLXuIYyuVMGnUb6E7A6SLWu3GT7bZK//fvZdS9TYe8HMZ6qXHKmmkPsoGNnHWekpjMtVWaKaw8STjUsjoJx8ztzdSn15e5H64eoL91OH98BcqcFyaZSLE4RCRvMpmBeQZ37EEvh2PIQqUockS1GV9E2pY5w97jeK6JPGr07aeyKPsxlVLvuHHD9ejrKOECXlP9afafUZBpersL15uwiCDM/+EPlEkvJZFxICOM4MNtv7OE05GyrXmoBtf6NL9++byZ43wDE0J1Z8ibW8RfnvHqBFhvpN8o4DA48uXLabcbHPTr5CchVzaRVVRgnxsQl0+b2i7QvgY1JYJqHF3qXh9B7rvV+fLiRL8eWD1WsSnYbeA88ZkAEqI7bcV0FhJbZUpsY4qQkyhm4EqsXliQxeeqTdy6UXg2MINQZg5y7jzESH5LHUT37FotEZUGds=" 45 | # Ex. travis encrypt SONATYPE_PASSWORD=your_sonatype_password 46 | - secure: "QD5/9xpA/zt6RkSsPXygxgVTjrgERUo4fyFrr73IBT2kbiZMnAOH0ZpSNV74XUpE0mNp8CNozHenuIri7UfFhx3SCQva4ktack4l42hKck4uqD0PpDQNnfjGC3NzKLfqI7Qmef0L5jPHDCSzTcqzWASVw8F80wTADuYbRP+pptTWRgOOpehpzofwUkhvASW3pXCcPIbj8qYSd1iIWwarUd9rlb/c2zKQTbQQPGd04eeC1Isq8/L8/fG9q2eSDRJBZz1gCbOdB2v+dT9/nRRjyOT5wd6lWCdmQn5zUcs9mgrUIG0pE54eNudMaO/QfPSYRE4WvC2zVRiTtFEYmEznSTlnrnKn1l0Agd+c49MS+ZqPLewzN8mDcZGGgirilOk9Z1fQ8z/z6792w+3ZmbK4BKTkvNluKni6LARPFnAG3KPt1YZ9NldJpGqWJiMUlVyXicvveNTXzxM9pv4jRaumgksjZ7OXTRn00IE9zs+8BX403Oakns4DUS+N9tpjSPEthE3Lx5/f6B5cjOK/aWmB4RwGNzDLeu0i1jLyCgdRbPhpfXxHcfknGKhvHdnXN+oOB/2nGJsV2fYkVc8IQYp9SgyqG9O3if257sNY4zBZoSYASl2Zx1AkI4lqkGLkg2YOdsgqx6iiHFj2v24kIJp6N7HuowV6KKO0+iUfyuM9qag=" 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![Released Version][maven-img]][maven] [![Apache-2.0 license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 2 | 3 | # OpenTracing AWS Client Instrumentation 4 | OpenTracing instrumentation for AWS clients. 5 | 6 | ## Installation 7 | 8 | ### AWS SDK 1 9 | pom.xml 10 | ```xml 11 | 12 | io.opentracing.contrib 13 | opentracing-aws-sdk-1 14 | VERSION 15 | 16 | ``` 17 | 18 | ### AWS SDK 2 19 | pom.xml 20 | ```xml 21 | 22 | io.opentracing.contrib 23 | opentracing-aws-sdk-2 24 | VERSION 25 | 26 | ``` 27 | 28 | ## Usage 29 | 30 | ```java 31 | // Instantiate tracer 32 | Tracer tracer = ... 33 | ``` 34 | 35 | ### AWS SDK 1 36 | 37 | ```java 38 | // Build AWS client with TracingRequestHandler e.g. 39 | AmazonS3 s3Client = AmazonS3ClientBuilder.standard() 40 | .withRegion(Regions.US_WEST_2) 41 | .withRequestHandlers(new TracingRequestHandler(tracer)) 42 | .build(); 43 | 44 | ``` 45 | 46 | ### AWS SDK 2 47 | ```java 48 | // Build AWS client with TracingExecutionInterceptor e.g. 49 | S3Client s3Client = S3Client.builder().overrideConfiguration( 50 | builder -> builder.addExecutionInterceptor(new TracingExecutionInterceptor(tracer))) 51 | .build(); 52 | ``` 53 | 54 | ## License 55 | 56 | [Apache 2.0 License](./LICENSE). 57 | 58 | [ci-img]: https://travis-ci.org/opentracing-contrib/java-aws-sdk.svg?branch=master 59 | [ci]: https://travis-ci.org/opentracing-contrib/java-aws-sdk 60 | [cov-img]: https://coveralls.io/repos/github/opentracing-contrib/java-aws-sdk/badge.svg?branch=master 61 | [cov]: https://coveralls.io/github/opentracing-contrib/java-aws-sdk?branch=master 62 | [maven-img]: https://img.shields.io/maven-central/v/io.opentracing.contrib/opentracing-aws-sdk-1.svg 63 | [maven]: http://search.maven.org/#search%7Cga%7C1%7Copentracing-aws-sdk-1 64 | 65 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # OpenTracing Release Process 2 | 3 | This repo uses semantic versions. Please keep this in mind when choosing version numbers. 4 | 5 | For the up-to-date release process, please refer the 6 | [release process from the OpenTracing Java API](https://github.com/opentracing/opentracing-java/blob/master/RELEASE.md). -------------------------------------------------------------------------------- /header.txt: -------------------------------------------------------------------------------- 1 | Copyright ${project.inceptionYear} The OpenTracing Authors 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 4 | in compliance with the License. You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software distributed under the License 9 | is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 10 | or implied. See the License for the specific language governing permissions and limitations under 11 | the License. 12 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ]; then 38 | 39 | if [ -f /etc/mavenrc ]; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ]; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false 51 | darwin=false 52 | mingw=false 53 | case "$(uname)" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true ;; 56 | Darwin*) 57 | darwin=true 58 | # 59 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 60 | # for the new JDKs provided by Oracle. 61 | # 62 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ]; then 63 | # 64 | # Apple JDKs 65 | # 66 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 67 | fi 68 | 69 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ]; then 70 | # 71 | # Apple JDKs 72 | # 73 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 74 | fi 75 | 76 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ]; then 77 | # 78 | # Oracle JDKs 79 | # 80 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 81 | fi 82 | 83 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 84 | # 85 | # Apple JDKs 86 | # 87 | export JAVA_HOME=$(/usr/libexec/java_home) 88 | fi 89 | ;; 90 | esac 91 | 92 | if [ -z "$JAVA_HOME" ]; then 93 | if [ -r /etc/gentoo-release ]; then 94 | JAVA_HOME=$(java-config --jre-home) 95 | fi 96 | fi 97 | 98 | if [ -z "$M2_HOME" ]; then 99 | ## resolve links - $0 may be a link to maven's home 100 | PRG="$0" 101 | 102 | # need this for relative symlinks 103 | while [ -h "$PRG" ]; do 104 | ls=$(ls -ld "$PRG") 105 | link=$(expr "$ls" : '.*-> \(.*\)$') 106 | if expr "$link" : '/.*' >/dev/null; then 107 | PRG="$link" 108 | else 109 | PRG="$(dirname "$PRG")/$link" 110 | fi 111 | done 112 | 113 | saveddir=$(pwd) 114 | 115 | M2_HOME=$(dirname "$PRG")/.. 116 | 117 | # make it fully qualified 118 | M2_HOME=$(cd "$M2_HOME" && pwd) 119 | 120 | cd "$saveddir" 121 | # echo Using m2 at $M2_HOME 122 | fi 123 | 124 | # For Cygwin, ensure paths are in UNIX format before anything is touched 125 | if $cygwin; then 126 | [ -n "$M2_HOME" ] && 127 | M2_HOME=$(cygpath --unix "$M2_HOME") 128 | [ -n "$JAVA_HOME" ] && 129 | JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 130 | [ -n "$CLASSPATH" ] && 131 | CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 132 | fi 133 | 134 | # For Migwn, ensure paths are in UNIX format before anything is touched 135 | if $mingw; then 136 | [ -n "$M2_HOME" ] && 137 | M2_HOME="$( ( 138 | cd "$M2_HOME" 139 | pwd 140 | ))" 141 | [ -n "$JAVA_HOME" ] && 142 | JAVA_HOME="$( ( 143 | cd "$JAVA_HOME" 144 | pwd 145 | ))" 146 | # TODO classpath? 147 | fi 148 | 149 | if [ -z "$JAVA_HOME" ]; then 150 | javaExecutable="$(which javac)" 151 | if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then 152 | # readlink(1) is not available as standard on Solaris 10. 153 | readLink=$(which readlink) 154 | if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then 155 | if $darwin; then 156 | javaHome="$(dirname \"$javaExecutable\")" 157 | javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" 158 | else 159 | javaExecutable="$(readlink -f \"$javaExecutable\")" 160 | fi 161 | javaHome="$(dirname \"$javaExecutable\")" 162 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 163 | JAVA_HOME="$javaHome" 164 | export JAVA_HOME 165 | fi 166 | fi 167 | fi 168 | 169 | if [ -z "$JAVACMD" ]; then 170 | if [ -n "$JAVA_HOME" ]; then 171 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 172 | # IBM's JDK on AIX uses strange locations for the executables 173 | JAVACMD="$JAVA_HOME/jre/sh/java" 174 | else 175 | JAVACMD="$JAVA_HOME/bin/java" 176 | fi 177 | else 178 | JAVACMD="$(which java)" 179 | fi 180 | fi 181 | 182 | if [ ! -x "$JAVACMD" ]; then 183 | echo "Error: JAVA_HOME is not defined correctly." >&2 184 | echo " We cannot execute $JAVACMD" >&2 185 | exit 1 186 | fi 187 | 188 | if [ -z "$JAVA_HOME" ]; then 189 | echo "Warning: JAVA_HOME environment variable is not set." 190 | fi 191 | 192 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 193 | 194 | # traverses directory structure from process work directory to filesystem root 195 | # first directory with .mvn subdirectory is considered project base directory 196 | find_maven_basedir() { 197 | local basedir=$(pwd) 198 | local wdir=$(pwd) 199 | while [ "$wdir" != '/' ]; do 200 | if [ -d "$wdir"/.mvn ]; then 201 | basedir=$wdir 202 | break 203 | fi 204 | wdir=$( 205 | cd "$wdir/.." 206 | pwd 207 | ) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' <"$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # For Cygwin, switch paths to Windows format before running java 223 | if $cygwin; then 224 | [ -n "$M2_HOME" ] && 225 | M2_HOME=$(cygpath --path --windows "$M2_HOME") 226 | [ -n "$JAVA_HOME" ] && 227 | JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 228 | [ -n "$CLASSPATH" ] && 229 | CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 230 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 231 | MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 232 | fi 233 | 234 | # Provide a "standardized" way to retrieve the CLI args that will 235 | # work with both Windows and non-Windows executions. 236 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 237 | export MAVEN_CMD_LINE_ARGS 238 | 239 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 240 | 241 | # avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in $@ 242 | exec "$JAVACMD" \ 243 | $MAVEN_OPTS \ 244 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 245 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 246 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 247 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %* 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | # avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in %* 125 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 126 | if ERRORLEVEL 1 goto error 127 | goto end 128 | 129 | :error 130 | set ERROR_CODE=1 131 | 132 | :end 133 | @endlocal & set ERROR_CODE=%ERROR_CODE% 134 | 135 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 136 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 137 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 138 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 139 | :skipRcPost 140 | 141 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 142 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 143 | 144 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 145 | 146 | exit /B %ERROR_CODE% 147 | -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 4.0.0 19 | 20 | io.opentracing.contrib 21 | opentracing-aws-sdk-parent 22 | 0.1.6-SNAPSHOT 23 | 24 | opentracing-aws-sdk-1 25 | 26 | OpenTracing Instrumentation for AWS SDK 1 27 | OpenTracing Instrumentation for AWS SDK 1 28 | 29 | 30 | 31 | com.amazonaws 32 | aws-java-sdk-core 33 | 1.11.729 34 | provided 35 | 36 | 37 | 38 | io.opentracing 39 | opentracing-api 40 | 41 | 42 | 43 | io.opentracing 44 | opentracing-mock 45 | test 46 | 47 | 48 | 49 | junit 50 | junit 51 | test 52 | 53 | 54 | 55 | com.amazonaws 56 | DynamoDBLocal 57 | test 58 | 59 | 60 | com.amazonaws 61 | aws-java-sdk-core 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/main/java/io/opentracing/contrib/aws/SpanDecorator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 The OpenTracing Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package io.opentracing.contrib.aws; 15 | 16 | 17 | import com.amazonaws.Request; 18 | import com.amazonaws.Response; 19 | import io.opentracing.Span; 20 | import io.opentracing.tag.Tags; 21 | import java.io.PrintWriter; 22 | import java.io.StringWriter; 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | 26 | class SpanDecorator { 27 | 28 | static final String COMPONENT_NAME = "java-aws-sdk"; 29 | 30 | static void onRequest(Request request, Span span) { 31 | Tags.COMPONENT.set(span, COMPONENT_NAME); 32 | Tags.HTTP_METHOD.set(span, request.getHttpMethod().name()); 33 | Tags.HTTP_URL.set(span, request.getEndpoint().toString()); 34 | Tags.PEER_SERVICE.set(span, request.getServiceName()); 35 | } 36 | 37 | static void onResponse(Response response, Span span) { 38 | Tags.HTTP_STATUS.set(span, response.getHttpResponse().getStatusCode()); 39 | } 40 | 41 | static void onError(Throwable throwable, Span span) { 42 | Tags.ERROR.set(span, Boolean.TRUE); 43 | span.log(errorLogs(throwable)); 44 | } 45 | 46 | private static Map errorLogs(Throwable throwable) { 47 | Map errorLogs = new HashMap<>(4); 48 | errorLogs.put("event", Tags.ERROR.getKey()); 49 | errorLogs.put("error.kind", throwable.getClass().getName()); 50 | errorLogs.put("error.object", throwable); 51 | 52 | errorLogs.put("message", throwable.getMessage()); 53 | 54 | StringWriter sw = new StringWriter(); 55 | throwable.printStackTrace(new PrintWriter(sw)); 56 | errorLogs.put("stack", sw.toString()); 57 | 58 | return errorLogs; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/main/java/io/opentracing/contrib/aws/TracingRequestHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 The OpenTracing Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package io.opentracing.contrib.aws; 15 | 16 | 17 | import com.amazonaws.Request; 18 | import com.amazonaws.Response; 19 | import com.amazonaws.handlers.HandlerContextKey; 20 | import com.amazonaws.handlers.RequestHandler2; 21 | import io.opentracing.Span; 22 | import io.opentracing.SpanContext; 23 | import io.opentracing.Tracer; 24 | import io.opentracing.tag.Tags; 25 | 26 | /** 27 | * Tracing Request Handler 28 | */ 29 | public class TracingRequestHandler extends RequestHandler2 { 30 | 31 | private final HandlerContextKey contextKey = new HandlerContextKey<>("span"); 32 | private final SpanContext parentContext; // for Async Client 33 | private final Tracer tracer; 34 | 35 | public TracingRequestHandler(Tracer tracer) { 36 | this.parentContext = null; 37 | this.tracer = tracer; 38 | } 39 | 40 | /** 41 | * In case of Async Client: beforeRequest runs in separate thread therefore we need to inject 42 | * parent context to build chain 43 | * 44 | * @param parentContext parent context 45 | */ 46 | public TracingRequestHandler(SpanContext parentContext, Tracer tracer) { 47 | this.parentContext = parentContext; 48 | this.tracer = tracer; 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | @Override 55 | public void beforeRequest(Request request) { 56 | Tracer.SpanBuilder spanBuilder = tracer 57 | .buildSpan(request.getOriginalRequest().getClass().getSimpleName()) 58 | .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT); 59 | 60 | if (parentContext != null) { 61 | spanBuilder.asChildOf(parentContext); 62 | } 63 | 64 | Span span = spanBuilder.start(); 65 | SpanDecorator.onRequest(request, span); 66 | 67 | request.addHandlerContext(contextKey, span); 68 | } 69 | 70 | /** 71 | * {@inheritDoc} 72 | */ 73 | @Override 74 | public void afterResponse(Request request, Response response) { 75 | Span span = request.getHandlerContext(contextKey); 76 | SpanDecorator.onResponse(response, span); 77 | span.finish(); 78 | } 79 | 80 | /** 81 | * {@inheritDoc} 82 | */ 83 | @Override 84 | public void afterError(Request request, Response response, Exception e) { 85 | Span span = request.getHandlerContext(contextKey); 86 | SpanDecorator.onError(e, span); 87 | span.finish(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/test/java/io/opentracing/contrib/aws/TracingRequestHandlerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 The OpenTracing Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package io.opentracing.contrib.aws; 15 | 16 | import static org.junit.Assert.assertEquals; 17 | import static org.junit.Assert.assertNotEquals; 18 | import static org.junit.Assert.assertNull; 19 | 20 | import com.amazonaws.auth.AWSStaticCredentialsProvider; 21 | import com.amazonaws.auth.BasicAWSCredentials; 22 | import com.amazonaws.client.builder.AwsClientBuilder; 23 | import com.amazonaws.handlers.AsyncHandler; 24 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; 25 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync; 26 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClientBuilder; 27 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder; 28 | import com.amazonaws.services.dynamodbv2.local.main.ServerRunner; 29 | import com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer; 30 | import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; 31 | import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; 32 | import com.amazonaws.services.dynamodbv2.model.CreateTableResult; 33 | import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; 34 | import com.amazonaws.services.dynamodbv2.model.KeyType; 35 | import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; 36 | import io.opentracing.Scope; 37 | import io.opentracing.mock.MockSpan; 38 | import io.opentracing.mock.MockTracer; 39 | import io.opentracing.tag.Tags; 40 | import java.util.List; 41 | import java.util.concurrent.Future; 42 | import java.util.concurrent.TimeUnit; 43 | import org.junit.After; 44 | import org.junit.Before; 45 | import org.junit.Test; 46 | 47 | 48 | public class TracingRequestHandlerTest { 49 | 50 | private static final MockTracer mockTracer = new MockTracer(); 51 | private DynamoDBProxyServer server; 52 | 53 | @Before 54 | public void before() throws Exception { 55 | System.getProperties().setProperty("sqlite4java.library.path", "src/test/resources/libs"); 56 | mockTracer.reset(); 57 | 58 | final String[] localArgs = {"-inMemory", "-port", "8000"}; 59 | server = ServerRunner.createServerFromCommandLineArgs(localArgs); 60 | server.start(); 61 | } 62 | 63 | @After 64 | public void after() throws Exception { 65 | server.stop(); 66 | } 67 | 68 | @Test 69 | public void with_error() { 70 | AmazonDynamoDB dbClient = buildClient(); 71 | createTable(dbClient, "table-1"); 72 | createTable(dbClient, "table-1"); 73 | 74 | List spans = mockTracer.finishedSpans(); 75 | assertEquals(2, spans.size()); 76 | 77 | assertEquals(1, spans.get(1).logEntries().size()); 78 | assertEquals(true, spans.get(1).tags().get(Tags.ERROR.getKey())); 79 | 80 | assertNull(mockTracer.activeSpan()); 81 | } 82 | 83 | @Test 84 | public void two_requests() { 85 | AmazonDynamoDB dbClient = buildClient(); 86 | createTable(dbClient, "twoRequests-1"); 87 | createTable(dbClient, "twoRequests-2"); 88 | 89 | List spans = mockTracer.finishedSpans(); 90 | assertEquals(2, spans.size()); 91 | 92 | checkSpans(spans); 93 | assertNotEquals(spans.get(0).context().traceId(), spans.get(1).context().traceId()); 94 | 95 | assertNull(mockTracer.activeSpan()); 96 | } 97 | 98 | @Test 99 | public void two_requests_with_parent() { 100 | AmazonDynamoDB dbClient = buildClient(); 101 | 102 | final MockSpan parent = mockTracer.buildSpan("parent-sync").start(); 103 | try (Scope ignore = mockTracer.activateSpan(parent)) { 104 | createTable(dbClient, "with-parent-1"); 105 | createTable(dbClient, "with-parent-2"); 106 | } 107 | parent.finish(); 108 | 109 | List spans = mockTracer.finishedSpans(); 110 | assertEquals(3, spans.size()); 111 | 112 | for (MockSpan span : spans) { 113 | if (parent.operationName().equals(span.operationName())) { 114 | continue; 115 | } 116 | assertEquals(parent.context().traceId(), span.context().traceId()); 117 | assertEquals(parent.context().spanId(), span.parentId()); 118 | } 119 | 120 | assertNull(mockTracer.activeSpan()); 121 | } 122 | 123 | /** 124 | * In case of async requests parent-child relation is not created. There is no way to fix that 125 | * except explicitly set parent context in TracingRequestHandler 126 | */ 127 | @Test 128 | public void async_requests_with_parent() throws Exception { 129 | AmazonDynamoDBAsync dbClient = buildAsyncClient(); 130 | 131 | final MockSpan parent = mockTracer.buildSpan("parent-sync").start(); 132 | try (Scope ignore = mockTracer.activateSpan(parent)) { 133 | Future createTableResultFuture = createTableAsync(dbClient, 134 | "with-async-parent-1"); 135 | Future createTableResultFuture2 = createTableAsync(dbClient, 136 | "with-async-parent-2"); 137 | 138 | createTableResultFuture.get(10, TimeUnit.SECONDS); 139 | createTableResultFuture2.get(10, TimeUnit.SECONDS); 140 | 141 | createTableAsync(dbClient, "with-async-parent-3").get(10, TimeUnit.SECONDS); 142 | } 143 | parent.finish(); 144 | 145 | List spans = mockTracer.finishedSpans(); 146 | assertEquals(4, spans.size()); 147 | 148 | for (MockSpan span : spans) { 149 | if (parent.operationName().equals(span.operationName())) { 150 | continue; 151 | } 152 | assertNotEquals(parent.context().traceId(), span.context().traceId()); 153 | assertNotEquals(parent.context().spanId(), span.parentId()); 154 | } 155 | } 156 | 157 | @Test 158 | public void two_async_requests() throws Exception { 159 | AmazonDynamoDBAsync dbClient = buildAsyncClient(); 160 | 161 | Future createTableResultFuture = createTableAsync(dbClient, 162 | "twoAsyncRequests-1"); 163 | Future createTableResultFuture2 = createTableAsync(dbClient, 164 | "twoAsyncRequests-2"); 165 | 166 | CreateTableResult result = createTableResultFuture.get(10, TimeUnit.SECONDS); 167 | assertEquals("twoAsyncRequests-1", result.getTableDescription().getTableName()); 168 | 169 | CreateTableResult result2 = createTableResultFuture2.get(10, TimeUnit.SECONDS); 170 | assertEquals("twoAsyncRequests-2", result2.getTableDescription().getTableName()); 171 | 172 | List spans = mockTracer.finishedSpans(); 173 | assertEquals(2, spans.size()); 174 | 175 | checkSpans(spans); 176 | assertNotEquals(spans.get(0).context().traceId(), spans.get(1).context().traceId()); 177 | assertNull(mockTracer.activeSpan()); 178 | } 179 | 180 | private void checkSpans(List mockSpans) { 181 | for (MockSpan mockSpan : mockSpans) { 182 | assertEquals(Tags.SPAN_KIND_CLIENT, mockSpan.tags().get(Tags.SPAN_KIND.getKey())); 183 | assertEquals(SpanDecorator.COMPONENT_NAME, mockSpan.tags().get(Tags.COMPONENT.getKey())); 184 | assertNull(mockSpan.tags().get(Tags.ERROR.getKey())); 185 | assertEquals(0, mockSpan.logEntries().size()); 186 | assertEquals(0, mockSpan.generatedErrors().size()); 187 | assertEquals("AmazonDynamoDBv2", mockSpan.tags().get(Tags.PEER_SERVICE.getKey())); 188 | String operationName = mockSpan.operationName(); 189 | assertEquals("CreateTableRequest", operationName); 190 | } 191 | } 192 | 193 | private AmazonDynamoDB buildClient() { 194 | AwsClientBuilder.EndpointConfiguration endpointConfiguration = 195 | new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2"); 196 | 197 | BasicAWSCredentials awsCreds = new BasicAWSCredentials("access_key_id", "secret_key_id"); 198 | 199 | return AmazonDynamoDBClientBuilder.standard() 200 | .withEndpointConfiguration(endpointConfiguration) 201 | .withCredentials(new AWSStaticCredentialsProvider(awsCreds)) 202 | .withRequestHandlers(new TracingRequestHandler(mockTracer)).build(); 203 | } 204 | 205 | private AmazonDynamoDBAsync buildAsyncClient() { 206 | AwsClientBuilder.EndpointConfiguration endpointConfiguration = 207 | new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2"); 208 | 209 | BasicAWSCredentials awsCreds = new BasicAWSCredentials("access_key_id", "secret_key_id"); 210 | 211 | return AmazonDynamoDBAsyncClientBuilder.standard() 212 | .withEndpointConfiguration(endpointConfiguration) 213 | .withCredentials(new AWSStaticCredentialsProvider(awsCreds)) 214 | .withRequestHandlers(new TracingRequestHandler(mockTracer)).build(); 215 | } 216 | 217 | private void createTable(AmazonDynamoDB dbClient, String tableName) { 218 | String partitionKeyName = tableName + "Id"; 219 | 220 | try { 221 | CreateTableRequest createTableRequest = new CreateTableRequest() 222 | .withTableName(tableName) 223 | .withKeySchema(new KeySchemaElement() 224 | .withAttributeName(partitionKeyName) 225 | .withKeyType(KeyType.HASH)) 226 | .withAttributeDefinitions(new AttributeDefinition() 227 | .withAttributeName(partitionKeyName).withAttributeType("S")) 228 | .withProvisionedThroughput(new ProvisionedThroughput() 229 | .withReadCapacityUnits(10L) 230 | .withWriteCapacityUnits(5L)); 231 | 232 | dbClient.createTable(createTableRequest); 233 | } catch (Exception e) { 234 | e.printStackTrace(); 235 | } 236 | } 237 | 238 | private Future createTableAsync(AmazonDynamoDBAsync dbClient, 239 | String tableName) { 240 | String partitionKeyName = tableName + "Id"; 241 | 242 | CreateTableRequest createTableRequest = new CreateTableRequest() 243 | .withTableName(tableName) 244 | .withKeySchema(new KeySchemaElement() 245 | .withAttributeName(partitionKeyName) 246 | .withKeyType(KeyType.HASH)) 247 | .withAttributeDefinitions(new AttributeDefinition() 248 | .withAttributeName(partitionKeyName).withAttributeType("S")) 249 | .withProvisionedThroughput(new ProvisionedThroughput() 250 | .withReadCapacityUnits(10L) 251 | .withWriteCapacityUnits(5L)); 252 | 253 | return dbClient.createTableAsync(createTableRequest, 254 | new AsyncHandler() { 255 | @Override 256 | public void onError(Exception exception) { 257 | exception.printStackTrace(); 258 | } 259 | 260 | @Override 261 | public void onSuccess(CreateTableRequest request, CreateTableResult createTableResult) { 262 | 263 | } 264 | }); 265 | } 266 | } -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/test/resources/libs/libsqlite4java-linux-amd64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-1/src/test/resources/libs/libsqlite4java-linux-amd64.so -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/test/resources/libs/libsqlite4java-linux-i386.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-1/src/test/resources/libs/libsqlite4java-linux-i386.so -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/test/resources/libs/libsqlite4java-osx.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-1/src/test/resources/libs/libsqlite4java-osx.dylib -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/test/resources/libs/sqlite4java-win32-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-1/src/test/resources/libs/sqlite4java-win32-x64.dll -------------------------------------------------------------------------------- /opentracing-aws-sdk-1/src/test/resources/libs/sqlite4java-win32-x86.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-1/src/test/resources/libs/sqlite4java-win32-x86.dll -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 4.0.0 19 | 20 | io.opentracing.contrib 21 | opentracing-aws-sdk-parent 22 | 0.1.6-SNAPSHOT 23 | 24 | opentracing-aws-sdk-2 25 | 26 | OpenTracing Instrumentation for AWS SDK 2 27 | OpenTracing Instrumentation for AWS SDK 2 28 | 29 | 30 | 2.10.71 31 | 32 | 33 | 34 | 35 | software.amazon.awssdk 36 | sdk-core 37 | ${aws.version} 38 | provided 39 | 40 | 41 | 42 | io.opentracing 43 | opentracing-api 44 | 45 | 46 | 47 | io.opentracing 48 | opentracing-mock 49 | test 50 | 51 | 52 | 53 | junit 54 | junit 55 | test 56 | 57 | 58 | org.assertj 59 | assertj-core 60 | test 61 | 62 | 63 | com.amazonaws 64 | DynamoDBLocal 65 | test 66 | 67 | 68 | software.amazon.awssdk 69 | dynamodb 70 | ${aws.version} 71 | test 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/src/main/java/io/opentracing/contrib/aws2/TracingExecutionInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 The OpenTracing Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package io.opentracing.contrib.aws2; 15 | 16 | import io.opentracing.Span; 17 | import io.opentracing.Tracer; 18 | import io.opentracing.tag.Tags; 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | import software.amazon.awssdk.core.interceptor.Context.AfterExecution; 22 | import software.amazon.awssdk.core.interceptor.Context.AfterMarshalling; 23 | import software.amazon.awssdk.core.interceptor.Context.BeforeExecution; 24 | import software.amazon.awssdk.core.interceptor.Context.FailedExecution; 25 | import software.amazon.awssdk.core.interceptor.ExecutionAttribute; 26 | import software.amazon.awssdk.core.interceptor.ExecutionAttributes; 27 | import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; 28 | import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; 29 | import software.amazon.awssdk.http.SdkHttpRequest; 30 | 31 | public class TracingExecutionInterceptor implements ExecutionInterceptor { 32 | private static final String COMPONENT_NAME = "java-aws-sdk"; 33 | private static final ExecutionAttribute SPAN_ATTRIBUTE = new ExecutionAttribute<>( 34 | "ot-span"); 35 | private final Tracer tracer; 36 | 37 | public TracingExecutionInterceptor(Tracer tracer) { 38 | this.tracer = tracer; 39 | } 40 | 41 | @Override 42 | public void beforeExecution(BeforeExecution context, ExecutionAttributes executionAttributes) { 43 | final Span span = tracer.buildSpan(context.request().getClass().getSimpleName()) 44 | .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) 45 | .withTag(Tags.PEER_SERVICE, 46 | executionAttributes.getAttribute(SdkExecutionAttribute.SERVICE_NAME)) 47 | .withTag(Tags.COMPONENT, COMPONENT_NAME).start(); 48 | 49 | executionAttributes.putAttribute(SPAN_ATTRIBUTE, span); 50 | } 51 | 52 | @Override 53 | public void afterMarshalling(final AfterMarshalling context, 54 | final ExecutionAttributes executionAttributes) { 55 | final Span span = executionAttributes.getAttribute(SPAN_ATTRIBUTE); 56 | final SdkHttpRequest httpRequest = context.httpRequest(); 57 | 58 | span.setTag(Tags.HTTP_METHOD, httpRequest.method().name()); 59 | span.setTag(Tags.HTTP_URL, httpRequest.getUri().toString()); 60 | span.setTag(Tags.PEER_HOSTNAME, httpRequest.host()); 61 | if (httpRequest.port() > 0) { 62 | span.setTag(Tags.PEER_PORT, httpRequest.port()); 63 | } 64 | } 65 | 66 | @Override 67 | public void afterExecution(final AfterExecution context, 68 | final ExecutionAttributes executionAttributes) { 69 | final Span span = executionAttributes.getAttribute(SPAN_ATTRIBUTE); 70 | if (span == null) { 71 | return; 72 | } 73 | 74 | executionAttributes.putAttribute(SPAN_ATTRIBUTE, null); 75 | span.setTag(Tags.HTTP_STATUS, context.httpResponse().statusCode()); 76 | span.finish(); 77 | } 78 | 79 | @Override 80 | public void onExecutionFailure(final FailedExecution context, 81 | final ExecutionAttributes executionAttributes) { 82 | final Span span = executionAttributes.getAttribute(SPAN_ATTRIBUTE); 83 | if (span == null) { 84 | return; 85 | } 86 | 87 | executionAttributes.putAttribute(SPAN_ATTRIBUTE, null); 88 | Tags.ERROR.set(span, Boolean.TRUE); 89 | span.log(errorLogs(context.exception())); 90 | span.finish(); 91 | } 92 | 93 | private static Map errorLogs(final Throwable ex) { 94 | Map errorLogs = new HashMap<>(2); 95 | errorLogs.put("event", Tags.ERROR.getKey()); 96 | errorLogs.put("error.object", ex); 97 | return errorLogs; 98 | } 99 | } -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/src/test/java/io/opentracing/contrib/aws2/Aws2Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 The OpenTracing Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package io.opentracing.contrib.aws2; 15 | 16 | 17 | import static org.assertj.core.api.Assertions.assertThat; 18 | import static org.junit.Assert.assertEquals; 19 | import static org.junit.Assert.assertNull; 20 | 21 | import com.amazonaws.services.dynamodbv2.local.main.ServerRunner; 22 | import com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer; 23 | import io.opentracing.Scope; 24 | import io.opentracing.mock.MockSpan; 25 | import io.opentracing.mock.MockTracer; 26 | import java.net.URI; 27 | import java.time.Duration; 28 | import java.util.List; 29 | import java.util.concurrent.CompletableFuture; 30 | import java.util.concurrent.ThreadLocalRandom; 31 | import java.util.concurrent.TimeUnit; 32 | import org.junit.After; 33 | import org.junit.Before; 34 | import org.junit.Test; 35 | import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; 36 | import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; 37 | import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; 38 | import software.amazon.awssdk.regions.Region; 39 | import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient; 40 | import software.amazon.awssdk.services.dynamodb.DynamoDbClient; 41 | import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition; 42 | import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest; 43 | import software.amazon.awssdk.services.dynamodb.model.CreateTableResponse; 44 | import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement; 45 | import software.amazon.awssdk.services.dynamodb.model.KeyType; 46 | import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput; 47 | 48 | public class Aws2Test { 49 | private static final MockTracer tracer = new MockTracer(); 50 | private DynamoDBProxyServer server; 51 | 52 | @Before 53 | public void before() throws Exception { 54 | System.getProperties().setProperty("sqlite4java.library.path", "src/test/resources/libs"); 55 | System.getProperties().setProperty("aws.region", "us-west-2"); 56 | tracer.reset(); 57 | 58 | final String[] localArgs = {"-inMemory", "-port", "8000"}; 59 | server = ServerRunner.createServerFromCommandLineArgs(localArgs); 60 | server.start(); 61 | } 62 | 63 | @After 64 | public void after() throws Exception { 65 | server.stop(); 66 | } 67 | 68 | @Test 69 | public void testSyncClient() { 70 | final DynamoDbClient dbClient = buildClient(); 71 | createTable(dbClient, "table-" + ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE)); 72 | 73 | final List spans = tracer.finishedSpans(); 74 | assertEquals(1, spans.size()); 75 | assertEquals("CreateTableRequest", spans.get(0).operationName()); 76 | 77 | assertNull(tracer.activeSpan()); 78 | } 79 | 80 | @Test 81 | public void twoRequestsWithParent() { 82 | final DynamoDbClient dbClient = buildClient(); 83 | 84 | final MockSpan parent = tracer.buildSpan("parent-sync").start(); 85 | try (Scope ignore = tracer.activateSpan(parent)) { 86 | createTable(dbClient, 87 | "with-parent-1-" + ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE)); 88 | createTable(dbClient, 89 | "with-parent-2-" + ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE)); 90 | } 91 | parent.finish(); 92 | 93 | List spans = tracer.finishedSpans(); 94 | assertEquals(3, spans.size()); 95 | 96 | for (MockSpan span : spans) { 97 | if (parent.operationName().equals(span.operationName())) { 98 | continue; 99 | } 100 | assertEquals(parent.context().traceId(), span.context().traceId()); 101 | assertEquals(parent.context().spanId(), span.parentId()); 102 | } 103 | 104 | assertNull(tracer.activeSpan()); 105 | } 106 | 107 | @Test 108 | public void testAsyncClient() throws Exception { 109 | final DynamoDbAsyncClient dbClient = buildAsyncClient(); 110 | final String tableName = 111 | "asyncRequest-" + ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE); 112 | final CompletableFuture createTableResultFuture = createTableAsync( 113 | dbClient, tableName); 114 | final CreateTableResponse result = createTableResultFuture.get(10, TimeUnit.SECONDS); 115 | assertThat(result.tableDescription().tableName()).isEqualTo(tableName); 116 | 117 | final List spans = tracer.finishedSpans(); 118 | assertEquals(1, spans.size()); 119 | assertEquals("CreateTableRequest", spans.get(0).operationName()); 120 | 121 | assertNull(tracer.activeSpan()); 122 | } 123 | 124 | private static DynamoDbClient buildClient() { 125 | final AwsSessionCredentials awsCreds = AwsSessionCredentials 126 | .create("access_key_id", "secret_key_id", "session_token"); 127 | return DynamoDbClient 128 | .builder() 129 | .endpointOverride(URI.create("http://localhost:8000")) 130 | .region(Region.US_WEST_2) 131 | .credentialsProvider(StaticCredentialsProvider.create(awsCreds)) 132 | .overrideConfiguration( 133 | ClientOverrideConfiguration.builder().apiCallTimeout(Duration.ofSeconds(1)).build()) 134 | .overrideConfiguration( 135 | builder -> builder.addExecutionInterceptor(new TracingExecutionInterceptor( 136 | tracer))) 137 | .build(); 138 | } 139 | 140 | private static DynamoDbAsyncClient buildAsyncClient() { 141 | final AwsSessionCredentials awsCreds = AwsSessionCredentials 142 | .create("access_key_id", "secret_key_id", "session_token"); 143 | final DynamoDbAsyncClient build = DynamoDbAsyncClient 144 | .builder() 145 | .endpointOverride(URI.create("http://localhost:8000")) 146 | .region(Region.US_WEST_2) 147 | .credentialsProvider(StaticCredentialsProvider.create(awsCreds)) 148 | .overrideConfiguration(ClientOverrideConfiguration.builder() 149 | .apiCallTimeout(Duration.ofSeconds(1)).build()) 150 | .overrideConfiguration( 151 | builder -> builder.addExecutionInterceptor(new TracingExecutionInterceptor(tracer))) 152 | .build(); 153 | return build; 154 | } 155 | 156 | private static void createTable(final DynamoDbClient dbClient, final String tableName) { 157 | final String partitionKeyName = tableName + "Id"; 158 | final CreateTableRequest createTableRequest = CreateTableRequest.builder() 159 | .tableName(tableName) 160 | .keySchema(KeySchemaElement.builder().attributeName(partitionKeyName).keyType(KeyType.HASH) 161 | .build()) 162 | .attributeDefinitions( 163 | AttributeDefinition.builder().attributeName(partitionKeyName).attributeType("S") 164 | .build()) 165 | .provisionedThroughput( 166 | ProvisionedThroughput.builder().readCapacityUnits(10L).writeCapacityUnits(5L).build()) 167 | .build(); 168 | 169 | dbClient.createTable(createTableRequest); 170 | } 171 | 172 | private static CompletableFuture createTableAsync( 173 | final DynamoDbAsyncClient dbClient, final String tableName) { 174 | final String partitionKeyName = tableName + "Id"; 175 | final CreateTableRequest createTableRequest = CreateTableRequest 176 | .builder() 177 | .tableName(tableName).keySchema( 178 | KeySchemaElement.builder().attributeName(partitionKeyName).keyType(KeyType.HASH) 179 | .build()) 180 | .attributeDefinitions( 181 | AttributeDefinition.builder().attributeName(partitionKeyName).attributeType("S") 182 | .build()) 183 | .provisionedThroughput( 184 | ProvisionedThroughput.builder().readCapacityUnits(10L).writeCapacityUnits(5L).build()) 185 | .build(); 186 | 187 | return dbClient.createTable(createTableRequest); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/src/test/resources/libs/libsqlite4java-linux-amd64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-2/src/test/resources/libs/libsqlite4java-linux-amd64.so -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/src/test/resources/libs/libsqlite4java-linux-i386.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-2/src/test/resources/libs/libsqlite4java-linux-i386.so -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/src/test/resources/libs/libsqlite4java-osx.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-2/src/test/resources/libs/libsqlite4java-osx.dylib -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/src/test/resources/libs/sqlite4java-win32-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-2/src/test/resources/libs/sqlite4java-win32-x64.dll -------------------------------------------------------------------------------- /opentracing-aws-sdk-2/src/test/resources/libs/sqlite4java-win32-x86.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opentracing-contrib/java-aws-sdk/d96d49491ea2948312c69df56143868e18bbf527/opentracing-aws-sdk-2/src/test/resources/libs/sqlite4java-win32-x86.dll -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 4.0.0 19 | io.opentracing.contrib 20 | opentracing-aws-sdk-parent 21 | 0.1.6-SNAPSHOT 22 | pom 23 | 24 | ${project.groupId}:${project.artifactId} 25 | OpenTracing Instrumentation for AWS SDK 26 | https://github.com/opentracing-contrib/java-aws-sdk 27 | 2017-2019 28 | 29 | 30 | http://github.com/opentracing-contrib/java-aws-sdk 31 | scm:git:https://github.com/opentracing-contrib/java-aws-sdk.git 32 | scm:git:https://github.com/opentracing-contrib/java-aws-sdk.git 33 | 34 | HEAD 35 | 36 | 37 | 38 | 39 | The Apache Software License, Version 2.0 40 | http://www.apache.org/licenses/LICENSE-2.0.txt 41 | repo 42 | 43 | 44 | 45 | 46 | 47 | malafeev 48 | Sergei Malafeev 49 | sergeymalafeev@gmail.com 50 | 51 | 52 | 53 | 54 | GitHub 55 | https://github.com/opentracing-contrib/java-aws-sdk/issues 56 | 57 | 58 | 59 | 1.8 60 | UTF-8 61 | UTF-8 62 | 63 | 0.33.0 64 | 4.3.0 65 | 0.8.5 66 | 67 | 68 | 69 | opentracing-aws-sdk-1 70 | opentracing-aws-sdk-2 71 | 72 | 73 | 74 | 75 | 76 | io.opentracing 77 | opentracing-api 78 | ${opentracing.version} 79 | 80 | 81 | io.opentracing 82 | opentracing-mock 83 | ${opentracing.version} 84 | test 85 | 86 | 87 | junit 88 | junit 89 | 4.12 90 | test 91 | 92 | 93 | org.assertj 94 | assertj-core 95 | 3.14.0 96 | test 97 | 98 | 99 | com.amazonaws 100 | DynamoDBLocal 101 | 1.11.475 102 | test 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | org.apache.maven.plugins 111 | maven-compiler-plugin 112 | 3.8.1 113 | 114 | ${java.version} 115 | ${java.version} 116 | 117 | 118 | 119 | org.apache.maven.plugins 120 | maven-release-plugin 121 | 2.5.3 122 | 123 | false 124 | release 125 | true 126 | @{project.version} 127 | 128 | 129 | 130 | com.mycila 131 | license-maven-plugin 132 | 3.0 133 | 134 | 135 | SLASHSTAR_STYLE 136 | 137 |
header.txt
138 | true 139 | 140 | LICENSE 141 | mvnw 142 | mvnw.cmd 143 | .mvn/wrapper/maven-wrapper.properties 144 | src/test/resources/libs/** 145 | .coveralls.yml 146 | 147 |
148 | 149 | 150 | 151 | check 152 | 153 | compile 154 | 155 | 156 |
157 | 158 | org.eluder.coveralls 159 | coveralls-maven-plugin 160 | ${coveralls-maven-plugin.version} 161 | 162 | 163 | org.jacoco 164 | jacoco-maven-plugin 165 | ${jacoco-maven-plugin.version} 166 | 167 | 168 | prepare-agent 169 | 170 | prepare-agent 171 | 172 | 173 | 174 | 175 |
176 |
177 | 178 | 179 | 180 | bintray 181 | https://api.bintray.com/maven/opentracing/maven/opentracing-aws-sdk/;publish=1 182 | 183 | 184 | jfrog-snapshots 185 | http://oss.jfrog.org/artifactory/oss-snapshot-local 186 | 187 | 188 | 189 | 190 | 191 | release 192 | 193 | 194 | 195 | 196 | org.apache.maven.plugins 197 | maven-source-plugin 198 | 3.2.0 199 | 200 | 201 | attach-sources 202 | 203 | jar 204 | 205 | 206 | 207 | 208 | 209 | 210 | org.apache.maven.plugins 211 | maven-javadoc-plugin 212 | 3.1.1 213 | 214 | false 215 | 216 | 217 | 218 | attach-javadocs 219 | 220 | jar 221 | 222 | package 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | dynamodblocal 234 | AWS DynamoDB Local Release Repository 235 | https://s3-us-west-2.amazonaws.com/dynamodb-local/release 236 | 237 | 238 | 239 |
240 | -------------------------------------------------------------------------------- /travis/publish.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017-2019 The OpenTracing Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | # in compliance with the License. You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software distributed under the License 10 | # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | # or implied. See the License for the specific language governing permissions and limitations under 12 | # the License. 13 | # 14 | 15 | set -euo pipefail 16 | set -x 17 | 18 | build_started_by_tag() { 19 | if [ "${TRAVIS_TAG}" == "" ]; then 20 | echo "[Publishing] This build was not started by a tag, publishing snapshot" 21 | return 1 22 | else 23 | echo "[Publishing] This build was started by the tag ${TRAVIS_TAG}, publishing release" 24 | return 0 25 | fi 26 | } 27 | 28 | is_pull_request() { 29 | if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then 30 | echo "[Not Publishing] This is a Pull Request" 31 | return 0 32 | else 33 | echo "[Publishing] This is not a Pull Request" 34 | return 1 35 | fi 36 | } 37 | 38 | is_travis_branch_master_or_release() { 39 | if [[ "${TRAVIS_BRANCH}" == "master" || "${TRAVIS_BRANCH}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 40 | echo "[Publishing] Travis branch is ${TRAVIS_BRANCH}" 41 | return 0 42 | else 43 | echo "[Not Publishing] Travis branch is not master or v0.0.0" 44 | return 1 45 | fi 46 | } 47 | 48 | check_travis_branch_equals_travis_tag() { 49 | #Weird comparison comparing branch to tag because when you 'git push --tags' 50 | #the branch somehow becomes the tag value 51 | #github issue: https://github.com/travis-ci/travis-ci/issues/1675 52 | if [ "${TRAVIS_BRANCH}" != "${TRAVIS_TAG}" ]; then 53 | echo "Travis branch does not equal Travis tag, which it should, bailing out." 54 | echo " github issue: https://github.com/travis-ci/travis-ci/issues/1675" 55 | exit 1 56 | else 57 | echo "[Publishing] Branch (${TRAVIS_BRANCH}) same as Tag (${TRAVIS_TAG})" 58 | fi 59 | } 60 | 61 | check_release_tag() { 62 | tag="${TRAVIS_TAG}" 63 | if [[ "$tag" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\-RC[[:digit:]]+)?$ ]]; then 64 | echo "Build started by version tag $tag. During the release process tags like this" 65 | echo "are created by the 'release' Maven plugin. Nothing to do here." 66 | exit 0 67 | elif [[ ! "$tag" =~ ^release-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\-RC[[:digit:]]+)?$ ]]; then 68 | echo "You must specify a tag of the format 'release-0.0.0' or 'release-0.0.0-RC0' to release this project." 69 | echo "The provided tag ${tag} doesn't match that. Aborting." 70 | exit 1 71 | fi 72 | } 73 | 74 | is_release_commit() { 75 | project_version=$(./mvnw help:evaluate -N -Dexpression=project.version | sed -n '/^[0-9]/p') 76 | if [[ "$project_version" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\-RC[[:digit:]]+)?$ ]]; then 77 | echo "Build started by release commit $project_version. Will synchronize to maven central." 78 | return 0 79 | else 80 | return 1 81 | fi 82 | } 83 | 84 | release_version() { 85 | echo "${TRAVIS_TAG}" | sed 's/^release-//' 86 | } 87 | 88 | safe_checkout_remote_branch() { 89 | # We need to be on a branch for release:perform to be able to create commits, 90 | # and we want that branch to be master or v0.0.0 (for RCs). which has been checked before. 91 | # But we also want to make sure that we build and release exactly the tagged version, 92 | # so we verify that the remote branch is where our tag is. 93 | checkoutBranch=master 94 | if [[ "${TRAVIS_BRANCH}" =~ ^release-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\-RC[[:digit:]]+$ ]]; then 95 | checkoutBranch=v$(release_version | sed 's/-RC[[:digit:]]\+//') 96 | fi 97 | git checkout -B "${checkoutBranch}" 98 | git fetch origin "${checkoutBranch}":origin/"${checkoutBranch}" 99 | commit_local="$(git show --pretty='format:%H' ${checkoutBranch})" 100 | commit_remote="$(git show --pretty='format:%H' origin/${checkoutBranch})" 101 | if [ "$commit_local" != "$commit_remote" ]; then 102 | echo "${checkoutBranch} on remote 'origin' has commits since the version under release, aborting" 103 | exit 1 104 | fi 105 | } 106 | 107 | #---------------------- 108 | # MAIN 109 | #---------------------- 110 | 111 | if ! is_pull_request && build_started_by_tag; then 112 | check_travis_branch_equals_travis_tag 113 | check_release_tag 114 | fi 115 | 116 | ./mvnw install -nsu 117 | 118 | # If we are on a pull request, our only job is to run tests, which happened above via ./mvnw install 119 | if is_pull_request; then 120 | true 121 | # If we are on master, we will deploy the latest snapshot or release version 122 | # - If a release commit fails to deploy for a transient reason, delete the broken version from bintray and click rebuild 123 | elif is_travis_branch_master_or_release; then 124 | ./mvnw --batch-mode -s ./.settings.xml -Prelease -nsu -DskipTests deploy 125 | 126 | # If we are on a release tag, the following will update any version references and push a version tag for deployment. 127 | elif build_started_by_tag; then 128 | safe_checkout_remote_branch 129 | ./mvnw --batch-mode -s ./.settings.xml -Prelease -nsu -DreleaseVersion="$(release_version)" -Darguments="-DskipTests" release:prepare 130 | fi 131 | --------------------------------------------------------------------------------