├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .settings.xml
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── RELEASE.md
├── config
└── checkstyle
│ └── checkstyle.xml
├── header.txt
├── mvnw
├── mvnw.cmd
├── opentracing-spring-jaeger-cloud-starter
└── pom.xml
├── opentracing-spring-jaeger-starter
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── io
│ │ │ └── opentracing
│ │ │ └── contrib
│ │ │ └── java
│ │ │ └── spring
│ │ │ └── jaeger
│ │ │ └── starter
│ │ │ ├── JaegerAutoConfiguration.java
│ │ │ ├── JaegerConfigurationProperties.java
│ │ │ ├── ReporterAppender.java
│ │ │ ├── TracerBuilderCustomizer.java
│ │ │ └── customizers
│ │ │ ├── B3CodecTracerBuilderCustomizer.java
│ │ │ ├── ExpandExceptionLogsTracerBuilderCustomizer.java
│ │ │ ├── HigherBitTracerBuilderCustomizer.java
│ │ │ └── TraceContextCodecTracerBuilderCustomizer.java
│ └── resources
│ │ └── META-INF
│ │ └── spring.factories
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── java
│ └── spring
│ └── jaeger
│ └── starter
│ ├── AbstractSenderSpringTest.java
│ ├── AbstractTracerSpringTest.java
│ ├── JaegerConfigurationPropertiesTagsTest.java
│ ├── basic
│ ├── JaegerTracerBackoffSpringTest.java
│ ├── JaegerTracerDisabledSpringTest.java
│ ├── JaegerTracerExplicitlyEnabledSpringTest.java
│ ├── JaegerTracerHttpSenderConfiguredSpringTest.java
│ ├── JaegerTracerImplicitlyEnabledSpringTest.java
│ ├── JaegerTracerNoSenderConfiguredSpringTest.java
│ ├── JaegerTracerServiceNameNotSetSpringTest.java
│ ├── JaegerTracerServiceNameSetExplicitTest.java
│ ├── JaegerTracerServiceNameSetExplicitWithPropsTest.java
│ ├── JaegerTracerServiceNameSetSpringTest.java
│ └── JaegerTracerServiceNameSetWithoutOpentracingPrefixTest.java
│ └── customizer
│ ├── JaegerTracerB3CustomerizerDisabledSpringTest.java
│ ├── JaegerTracerB3CustomerizerEnabledSpringTest.java
│ ├── JaegerTracerB3CustomizerCustomSpringTest.java
│ ├── JaegerTracerExpandExceptionLogsDisabledSpringTest.java
│ ├── JaegerTracerExpandExceptionLogsEnabledSpringTest.java
│ ├── JaegerTracerHigherBitCustomizerDisabledSpringTest.java
│ ├── JaegerTracerHigherBitCustomizerEnabledSpringTest.java
│ ├── JaegerTracerTraceContextCustomerizerDisabledSpringTest.java
│ ├── JaegerTracerTraceContextCustomerizerEnabledSpringTest.java
│ ├── JaegerTracerTraceContextCustomizerCustomSpringTest.java
│ └── MultipleCustomizersEnabledSpringTest.java
├── opentracing-spring-jaeger-web-starter-it
├── pom.xml
└── src
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── java
│ └── spring
│ └── web
│ └── jaeger
│ └── starter
│ └── it
│ ├── DemoSpringBootWebApplication.java
│ └── JaegerIntegrationTest.java
├── opentracing-spring-jaeger-web-starter
└── pom.xml
├── pom.xml
└── travis
└── publish.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | !.mvn/wrapper/maven-wrapper.jar
16 | *.war
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 | target
22 |
23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24 | hs_err_pid*
25 |
26 | # Eclipse
27 | .project
28 | .classpath
29 | .settings
30 |
31 | .gitkeep
32 | .editorconfig
33 |
34 | # Intellij Idea
35 | *.iml
36 | .idea/
37 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentracing-contrib/java-spring-jaeger/f0a5191dbd7a6aeef3e9786655e16086593c1ba0/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-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 |
44 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | dist: trusty
3 |
4 | language: java
5 | jdk:
6 | - oraclejdk8
7 |
8 | services:
9 | - docker
10 |
11 | cache:
12 | directories:
13 | - $HOME/.m2/repository
14 |
15 | before_install:
16 | # allocate commits to CI, not the owner of the deploy key
17 | - git config user.name "opentracingci"
18 | - git config user.email "opentracingci+opentracing@googlegroups.com"
19 | # setup https authentication credentials, used by ./mvnw release:prepare
20 | - git config credential.helper "store --file=.git/credentials"
21 | - echo "https://$GH_TOKEN:@github.com" > .git/credentials
22 |
23 | install:
24 | # Override default travis to use the maven wrapper
25 | - ./mvnw clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
26 |
27 | script:
28 | - ./travis/publish.sh
29 |
30 | branches:
31 | except:
32 | - /^[0-9]/
33 |
34 | env:
35 | global:
36 | # Ex. travis encrypt -r org/repo BINTRAY_USER=your_github_account
37 | - secure: "wO8CBpnZNy0/5LTXn2VLx+VrXU/wt0QLjuqm9OXdfNM8mmCpvK+kdQmYae/CXcU1ciETlQgQsKYYc5ZHrVTE+bcKR1CQqUB0/WsnO3QnvgPk1W5/LXB40as8XBYpqGGOMuJOAm9vYLJhJ1YBbDqsnMTh1w8kSf50+TGwgWEMFu/Pk9+Tr33mg5CxoMmeH2zJF912l47yM7LWUWXTZeTc5lVQuipBAHDN5kt30m1Uola4fIevvpoGhqVk0avy8Tt5ackZai9t1UBdE/jtLcoFIqLCTdDsAJUhGgO9oh5/lWnLCC6QaM3XK3FWixKXOJJ5jBgwfrYwtK2sZrXdUy8PM1htKSudu57g3IFWvkD1xbMrocC69Sutd22QkQBXmeRAj6DylaT8w5CgXga0hXdoNmLCk5Wj9yosktL2J9qptII5tvWc+WW3IBjXSIxZMIfmaaEmVLSDR93meegEeK53aUHgLyrZ5Ys3xKhXIOU7lGOUOvrA8kg3XhR5l511q1PSs1+ddQkcctUUOrdtDDQi2OmCD3fIupQIiT7yuRN9gOU7bV0CNvYLATKOwUOiKuM0T2ZtaeCveUqj6DwN3g7Enb7XP7ZqN6g/pwP0y+zUSfESpJEAisaBofMQrrj5Pw9uAqGYRCMC7Io0sZi83cF1WyVfTT72CYYxg+GNnywZMuA="
38 | # Ex. travis encrypt -r org/repo BINTRAY_KEY=xxx-https://bintray.com/profile/edit-xxx --add
39 | - secure: "js6uopwOoSVcPp9bPAffGpjy4IT8XT5D+DONGA6Ezg8vjBeIAPdzu81AjyN/0ekIEkggdNaNssx8ZWDzw2qnAelrz/Sc9hGecIzlCNODok1jb76uKmbxf802hiWGuxjV1LCH4OB/MfOl2MiI4NPKHc+GPR17+lup+Bm73EOijWgIOTbNIwL81N6+vM2YqOGICXefg/WFSOBFj4vnJN8qDrPIScpn7RWPQkS3Rb1pzB7jL52gRU6jo5fv/awqj3dfvqZStNojbWY1EQBRRf/yRRi4OwQ28H+jN4XsTco7qNduk0O1RW1o0GPxez4gQHPU+Bg0UkfDbcjl+Opwz+ge/zUZoYfCMs4lFRDLWfQgj9KQTuY4UdRN1Eosfo2+TOBXlmNL+UZ4LtEJVu1PsNdOxogesGEyqRCMxeOrmQhtOaR/hiidudVq8pv7i2KsJ3UUC7Fkxoupc3u9LTl2EQwy4pshtIJXMNYEfF0C0i7u/TvPMgpbsOXJIGE36o3b+a73Vk+cZ+EsOqFPoAaQTtyZGz/2y40/nPJ0hhtlAKNj1fhyC72EXJrR9XjyEfawPO8CPXxgpzHXVp9RO1pprKO3ly2DTAVK1w8qyShAacKbS8HTqJA9acCwOuSa/QAnigWihTh4cUyUBe8asv1ri9uneUiscfxQfCIB9a6KLBTiiPg="
40 | # Ex. travis encrypt -r org/repo GH_TOKEN=XXX-https://github.com/settings/tokens-XXX --add
41 | - secure: "HdwghZgzn35a0O5+wmLE40pvnNn3s2g5IjVHrlvUhTIRKgQk0Mx9zQttkGloi57FYgVfXSApbzdbL7wrmYf4NMyN7F0ul8FmBjtiZHIIdknF5lnT3yMc5BDQLTyuL8xtGQCrOC191eWlAU/mwq0D6OXy6LvOLUPF0IJrcT+EkTglDJt8OirGSyWplkl3BDyUGtRMI3cR+Yn9sRwEjhSfDzzOFS7Nxdv73QPXtzl8Xspe0rdpaAVrs5iVq7Ewna0f3fbCr2wSvluZwkJXmN9rfJgkAL6qnJ6QjzzF5wxZgybhvHStDmFcHPNQuyiP2vhAk5usCYW1Hy/BrR70HiufxtZPg34yBsSUkUPVW/UEtcZq740859WMSbsmSZrsqfHpxb0zh+qMzkIFwyOEnEWt7535VY47Wx6Fq5e+a06omuh7+0FazieCH+KZ0hNwMgePtANGrZSRdbWtDdJ5GydyJjWZQ5H/AWJ6rX4M7mjxT5apPqYhtMem/ariGbrwTQWACM85XERaJgUHK8n3ZbHFGGKtKq0fw0aDQ/Cl5V/3z5tsDCKq7IzQod1tgizQMFeLuaWbb3jZGVRN7H1CAjREpdq2/3yeahor1gRh6rjECGsN1fyXb7ZY3CY+rHg1x9hMLW7JYLd+ltTCrdNpCxBMQCsxe+RscciquKM2/B6F3Oc="
42 | # Ex. travis encrypt -r org/repo SONATYPE_USER=your_sonatype_account
43 | - secure: "mPIOMTVWnEcFTqWV0z7Gn5uHTNV3LZw6NfMRkMk4wUxive+NNzIHlr/JluissfRSYRRlDF5LbsGsrrsn8zBhU9qi4Hnz62FxWHLa5R4s8l7XYSB/nmQKExlE1FhjLl7/6eXbys3yDXhzFfthcNwJuVrFxvwq4Ryig6QYyKE9Wiy9zWL7SYz9FFWvd3aySDs3/wQZ916kYDs/Zw96yBNeev5tcIdcTAxDR3k4j78QXQO90t2syVja4xRpnCalMUF8hRmKKKSQ1ME08ezFDPOaYyPNmaj3gKGE5iGp4FVxjc2IPc4lBmSwmHVQrLqwMFH7cvE4eYgn4TwUEMWqf4ilTOzqZdYKIm6s7QMDlIg0BMXK8a0cTB6+M1fMSWlgFNW3IywpqjTjfcNTJCzAunB7Qy7ghRcBZupSNynyQOMPBJ6WCnuGLEcbPBeAzBTdfITlsj5e3vDj0vh8Nn3uHMLJkJ4GBdcAxhNPTF+pEZ8BDrmAzzgPpqXDjEfzDoLhDEwgfpu93qTLxutpHOBa4Okn/CtxSqohpGlRYTjDrDbID3nNXuzXfc7ecazXwf7UZXgJEsm9VjdcQ31JT+vAYsNrWDUVj5To59bywSj7z/u+fQjWdY9dFUyJFrslkXRbWZ8WaDq3b0FMfjPTC+TQG3uCdNNU0uJgyawY+g3TFMNuMdI="
44 | # Ex. travis encrypt -r org/repo SONATYPE_PASSWORD=your_sonatype_password
45 | - secure: "rtw3FONoh9iXgQNlzL6RA977IWhL3138zop6lECSIqB+Kzck7rs4epf8bVmg8U3PbOXK1oQOubDKuhwtpyRHgkP17EAmqCnbpB8+YlfRqTUmqmT4MQ0e4TsAO6QxVZjulFLbAtGQXsvX0ilkBAZQpmXrWVtTCPzhP3puCSbjCVg2QJDlbD3/1fa3mpu3zPJaFXoT4x9i0dMWzaJnAOFytajzUBSvUBEdgKrEZHnqDQxBWWl/EMh+PxYFN+mNm/0kiHadl4ptSDSIDizHofdwF99Qnd1auh660n0kkESSgRoLsRBj3hmwPTJPzayYnpwd+AYOsWvC/2ivqVbhXyOTzDAjc9Yhl2HWn2hgtLEGrc5FUFQN1aKV/H/ahgKOw4lLOy4L1JzOrgKR3qICgUfnypsnZiB6nil+l/upvARm8m1mDrc0gaAZ4QwomjmF4pk6IagWzoNmbpqx38KK5TSio6PhWY+eU1ytDDAc/MBN3eHdTCsEZSmmCmxK3TcM+cXqdw0f0p1UX/0kw/3gM4Hnzau0L+heeI/hTB0+zY6KZYmkZ4OmtlL4o7kLMJ9M1FlZVlJUUmVG7/07DTqdTRAybvyHpJoWBKxnfyfA3/9cs2Lpi0fTwn8xqth81/RPX3Cjqql4m6QUbnl63wGGgPTeZ+eRIUlKTN9EZy4hdE285q0="
46 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Changes by Version
2 | ==================
3 |
4 | 2.0.0 (2019-05-06)
5 | -------------------
6 | - Bump to OpenTracing 0.32
7 |
8 |
9 | 1.0.0 (2018-11-30)
10 | -------------------
11 | - Use Spring Boot 2.1.x
12 |
13 |
14 | 0.2.2 (2018-10-10)
15 | -------------------
16 |
17 | - Bump jaeger version
18 | - Bump opentracing-spring-web version (#22)
19 | - Set opentracing-spring-cloud-starter.version to 0.2.0 (#21)
20 | - Set 'metrics' object on the Tracer itself. (#19)
21 |
22 |
23 | 0.2.1 (2018-08-21)
24 | -------------------
25 |
26 | - Support expanding exception logs
27 |
28 | 0.2.0 (2018-07-17)
29 | -------------------
30 |
31 | - Update to jaeger-client 0.30.x
32 |
33 | 0.1.5 (2018-07-05)
34 | -------------------
35 |
36 | - Add a new starter that combines jaeger and opentracing java spring cloud
37 |
38 |
39 | 0.1.4 (2018-06-20)
40 | -------------------
41 |
42 | - Run jaeger configuration before Noop tracer producer
43 |
44 | 0.1.3 (2018-06-18)
45 | -------------------
46 |
47 | - Add a new starter that combines jaeger and opentracing web
48 |
49 |
50 | 0.1.2 (2018-06-18)
51 | -------------------
52 |
53 | Skipped due to maven release issue
54 |
55 |
56 | 0.1.1 (2018-06-04)
57 | -------------------
58 |
59 | - Exclude integration tests from maven deploy / release
60 |
61 | 0.1.0 (2018-06-04)
62 | -------------------
63 |
64 | - Add basic Jaeger Tracer auto-configuration functionality
65 |
--------------------------------------------------------------------------------
/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] [![Released Version][maven-img]][maven]
2 |
3 | ## Dependencies
4 |
5 | The `opentracing-spring-jaeger-starter` simply contains the code needed to provide a Jaeger implementation of the OpenTracing's `io.opentracing.Tracer`
6 | interface.
7 |
8 | For a project to be able to actually instrument a Spring stack, one or more of the purpose built starters (like `io.opentracing.contrib:opentracing-spring-web-starter` or `io.opentracing.contrib:opentracing-spring-cloud-starter`)
9 | would also have to be included in the POM.
10 |
11 | The `opentracing-spring-jaeger-web-starter` starter is convenience starter that includes both `opentracing-spring-jaeger-starter` and `opentracing-spring-web-starter`
12 | This means that by including it, simple web Spring Boot microservices include all the necessary dependencies to instrument Web requests / responses and send traces to Jaeger.
13 |
14 | The `opentracing-spring-jaeger-cloud-starter` starter is convenience starter that includes both `opentracing-spring-jaeger-starter` and `opentracing-spring-cloud-starter`
15 | This means that by including it, all parts of the Spring Cloud stack supported by Opentracing will be instrumented
16 |
17 |
18 | ## Library versions
19 |
20 | Versions 1.x.y of the library are meant to target Spring Boot 2.x while versions 0.x.y are meant to be used with Spring Boot 1.5
21 |
22 | ## Configuration
23 |
24 | ```xml
25 |
26 | io.opentracing.contrib
27 | opentracing-spring-jaeger-web-starter
28 |
29 | ```
30 |
31 | or
32 |
33 | ```xml
34 |
35 | io.opentracing.contrib
36 | opentracing-spring-jaeger-cloud-starter
37 |
38 | ```
39 |
40 | Either dependency will ensure that Spring Boot will auto configure a Jaeger implementation of OpenTracing's `Tracer` when the application starts.
41 |
42 | If no settings are changed, spans will be reported to the UDP port `6831` of `localhost`.
43 | The simplest way to change this behavior is to set the following properties:
44 |
45 | ```
46 | opentracing.jaeger.udp-sender.host=jaegerhost
47 | opentracing.jaeger.udp-sender.port=portNumber
48 | ```
49 |
50 | for the UDP sender, or use an HTTP sender by setting the following property:
51 |
52 | `opentracing.jaeger.http-sender.url = http://jaegerhost:portNumber/api/traces`
53 |
54 |
55 | ## Configuration options
56 |
57 | All the available configuration options can be seen in [JaegerConfigurationProperties](opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.java).
58 | The prefix to be used for these properties is `opentracing.jaeger`.
59 | Furthermore, the service name is configured via the standard Spring Cloud `spring.application.name` property.
60 |
61 | Beware to use the correct syntax for properties that are camel-case in `JaegerConfigurationProperties`.
62 |
63 | * For properties / yaml files use `-`. For example `opentracing.jaeger.log-spans=true`
64 | * For environment variables use `_`. For example `OPENTRACING_JAEGER_LOG_SPANS`
65 |
66 | ## Defaults
67 |
68 | If no configuration options are changed and the user does not manually provide any of the beans that the
69 | auto-configuration process provides, the following defaults are used:
70 |
71 | * `unknown-spring-boot` Will be used as the service-name if no value has been specified to the property `spring.application.name` or `opentracing.jaeger.service-name` (which has the highest priority).
72 | * `CompositeReporter` is provided which contains the following delegates:
73 | - `LoggingReporter` for reporting spans to the console
74 | - `RemoteReporter` that contains a `UdpSender` that sends spans to `localhost:6831`
75 | * `ConstSampler` with the value of `true`. This means that every trace will be sampled
76 | * `NoopMetricsFactory` is used - effectively meaning that no metrics will be collected
77 |
78 | ## Senders
79 |
80 | Configuring senders is as simple as setting a couple necessary properties
81 |
82 | ### HTTP Sender
83 |
84 | `opentracing.jaeger.http-sender.url = http://jaegerhost:portNumber/api/traces`
85 |
86 | It's possible to configure authentication on the HTTP sender by specifying an username and password:
87 |
88 | `opentracing.jaeger.http-sender.username = username`
89 | `opentracing.jaeger.http-sender.password = password`
90 |
91 | Or by specifying a bearer token:
92 |
93 | `opentracing.jaeger.http-sender.authtoken = token`
94 |
95 |
96 | Note that when an HTTP Sender is defined, the UDP sender is not used, even if it has been configured
97 |
98 | ### UDP Sender
99 |
100 | `opentracing.jaeger.udp-sender.host=jaegerhost`
101 | `opentracing.jaeger.udp-sender.port=portNumber`
102 |
103 | ## Common cases
104 |
105 | ### Set service name
106 |
107 | Set `spring.application.name` to the desired name
108 |
109 | ### Log Spans
110 |
111 | By default spans are logged to the console. This can be disabled by setting:
112 |
113 | `opentracing.jaeger.log-spans = false`
114 |
115 | ### Additional reporters
116 |
117 | By defining a bean of type `ReporterAppender`, the code has the chance to add any Reporter without
118 | having to forgo what the auto-configuration provides
119 |
120 | ### Sampling
121 |
122 | * Const sampler
123 |
124 | `opentracing.jaeger.const-sampler.decision = true | false`
125 |
126 | * Probabilistic sampler
127 |
128 | `opentracing.jaeger.probabilistic-sampler.sampling-rate = value`
129 |
130 | Where `value` is between `0.0` (no sampling) and `1.0` (sampling of every request)
131 |
132 | * Rate-limiting sampler
133 |
134 | `opentracing.jaeger.rate-limiting-sampler.max-traces-per-second = value`
135 |
136 | Configures that traces are sampled with a certain constant rate. For example, when sampler.param=2.0 it will sample requests with the rate of 2 traces per second.
137 |
138 | * Remote sampler
139 |
140 | Remote sampler consults Jaeger agent for the appropriate sampling strategy to use in the current service. This allows controlling the sampling strategies in the services from a central configuration in Jaeger backend.
141 | It can be configured like so:
142 |
143 | `opentracing.jaeger.remote-controlled-sampler.host-port=localhost:5778`
144 |
145 |
146 | The samplers above are mutually exclusive.
147 |
148 | A custom sampler could of course be provided by declaring a bean of type `io.jaegertracing.samplers.Sampler`
149 |
150 | ### Propagate headers in B3 format (for compatibility with Zipkin collectors)
151 |
152 | `opentracing.jaeger.enable-b3-propagation = true`
153 |
154 | ### Propagate headers in W3C Trace Context format
155 |
156 | `opentracing.jaeger.enable-w3c-propagation = true`
157 |
158 | ## Advanced cases
159 |
160 | ### Manual bean provisioning
161 |
162 | Any of the following beans can be provided by the application (by adding configuring them as bean with `@Bean` for example)
163 | and will be used to by the Tracer instead of the auto-configured beans.
164 |
165 | * `io.jaegertracing.samplers.Sampler`
166 | * `io.jaegertracing.metrics.MetricsFactory`
167 |
168 | ### io.jaegertracing.Tracer.Builder customization
169 |
170 | If arbitrary customizations need to be performed on `Tracer.Builder` but you don't want to forgo the rest of the auto-configuration
171 | features, `TracerBuilderCustomizer` comes in handy. It allows the developer to invoke any method of `Tracer.Builder` (with the exception of `build`)
172 | before the auto-configuration code invokes the `build` method.
173 | Examples of this type of customization can be seen in the `B3CodecTracerBuilderCustomizer` and `ExpandExceptionLogsTracerBuilderCustomizer` classes.
174 |
175 | ## Caution
176 |
177 | ### Beware of the default sampler in production
178 |
179 | In a high traffic environment, the default sampler that is configured is very unsafe since it samples every request.
180 | It is therefore highly recommended to explicitly configure on of the other options in a production environment
181 |
182 | ## Development
183 | Maven checkstyle plugin is used to maintain consistent code style based on [Google Style Guides](https://github.com/google/styleguide)
184 |
185 | ```shell
186 | ./mvnw clean install
187 | ```
188 |
189 | ## Tips and tricks
190 |
191 | ### Completely disable tracing
192 |
193 | There are times when it might be desirable to completely disable tracing (for example in a testing environment).
194 | Due to the multiple (auto)configurations that come into play, this is not as simple as setting `opentracing.jaeger.enabled` to `false`.
195 |
196 | When one of the starters of this project is included, then `io.opentracing.contrib:opentracing-spring-tracer-configuration-starter` is also included since it performs some necessary plumbing.
197 | However, when `opentracing.jaeger.enabled` is set to `false`, then the aforementioned dependency provides a default `Tracer` implementation that needs the `JAEGER_SERVICE_NAME` environment variable (see [this](https://github.com/jaegertracing/jaeger-client-java/blob/master/jaeger-core/README.md)).
198 |
199 | One simple way around this would be to do the add the following Spring configuration:
200 |
201 | ```java
202 | @ConditionalOnProperty(value = "opentracing.jaeger.enabled", havingValue = "false", matchIfMissing = false)
203 | @Configuration
204 | public class MyTracerConfiguration {
205 |
206 | @Bean
207 | public io.opentracing.Tracer jaegerTracer() {
208 | return io.opentracing.noop.NoopTracerFactory.create();
209 | }
210 | }
211 | ```
212 |
213 | In the code above we are activating a `io.opentracing.Tracer` iff `opentracing.jaeger.enabled` is set to `false`. This tracer
214 | is necessary to keep the various Spring configurations happy but has been configured to not sample any requests, therefore
215 | effectively disabling tracing.
216 |
217 | ### Trace id not propagated via the Feign client
218 |
219 | If you are using Feign, in some cases it might be necessary to explicitely expose the Feign client in the Spring configuration, in order to get the `uber-trace-id` propagated. This can be done easily by adding the following into one of your configuration classes:
220 |
221 | ```
222 | @Bean
223 | public Client feignClient() {
224 | return new Client.Default(null, null);
225 | }
226 | ```
227 |
228 | ## Release
229 | Follow instructions in [RELEASE](RELEASE.md)
230 |
231 | [ci-img]: https://travis-ci.org/opentracing-contrib/java-spring-jaeger.svg?branch=master
232 | [ci]: https://travis-ci.org/opentracing-contrib/java-spring-jaeger
233 | [maven-img]: https://img.shields.io/maven-central/v/io.opentracing.contrib/opentracing-spring-jaeger-starter.svg?maxAge=3600
234 | [maven]: http://search.maven.org/#search%7Cga%7C1%7Copentracing-spring-jaeger-starter
235 |
236 | ## License
237 |
238 | [Apache 2.0 License](./LICENSE).
239 |
--------------------------------------------------------------------------------
/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).
7 |
--------------------------------------------------------------------------------
/config/checkstyle/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
49 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
62 |
63 |
64 |
65 |
66 |
67 |
69 |
70 |
71 |
72 |
73 |
74 |
76 |
77 |
78 |
79 |
80 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
90 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
134 |
135 |
136 |
138 |
139 |
140 |
141 |
143 |
144 |
145 |
146 |
148 |
149 |
150 |
151 |
153 |
154 |
155 |
156 |
157 |
159 |
160 |
161 |
162 |
164 |
165 |
166 |
167 |
169 |
170 |
171 |
172 |
174 |
175 |
176 |
177 |
179 |
181 |
183 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
231 |
232 |
233 |
234 |
236 |
237 |
246 |
247 |
248 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
--------------------------------------------------------------------------------
/header.txt:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} 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*) darwin=true
57 | #
58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look
59 | # for the new JDKs provided by Oracle.
60 | #
61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
62 | #
63 | # Apple JDKs
64 | #
65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
66 | fi
67 |
68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
69 | #
70 | # Apple JDKs
71 | #
72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
73 | fi
74 |
75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
76 | #
77 | # Oracle JDKs
78 | #
79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
80 | fi
81 |
82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
83 | #
84 | # Apple JDKs
85 | #
86 | export JAVA_HOME=`/usr/libexec/java_home`
87 | fi
88 | ;;
89 | esac
90 |
91 | if [ -z "$JAVA_HOME" ] ; then
92 | if [ -r /etc/gentoo-release ] ; then
93 | JAVA_HOME=`java-config --jre-home`
94 | fi
95 | fi
96 |
97 | if [ -z "$M2_HOME" ] ; then
98 | ## resolve links - $0 may be a link to maven's home
99 | PRG="$0"
100 |
101 | # need this for relative symlinks
102 | while [ -h "$PRG" ] ; do
103 | ls=`ls -ld "$PRG"`
104 | link=`expr "$ls" : '.*-> \(.*\)$'`
105 | if expr "$link" : '/.*' > /dev/null; then
106 | PRG="$link"
107 | else
108 | PRG="`dirname "$PRG"`/$link"
109 | fi
110 | done
111 |
112 | saveddir=`pwd`
113 |
114 | M2_HOME=`dirname "$PRG"`/..
115 |
116 | # make it fully qualified
117 | M2_HOME=`cd "$M2_HOME" && pwd`
118 |
119 | cd "$saveddir"
120 | # echo Using m2 at $M2_HOME
121 | fi
122 |
123 | # For Cygwin, ensure paths are in UNIX format before anything is touched
124 | if $cygwin ; then
125 | [ -n "$M2_HOME" ] &&
126 | M2_HOME=`cygpath --unix "$M2_HOME"`
127 | [ -n "$JAVA_HOME" ] &&
128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
129 | [ -n "$CLASSPATH" ] &&
130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
131 | fi
132 |
133 | # For Migwn, ensure paths are in UNIX format before anything is touched
134 | if $mingw ; then
135 | [ -n "$M2_HOME" ] &&
136 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
137 | [ -n "$JAVA_HOME" ] &&
138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
139 | # TODO classpath?
140 | fi
141 |
142 | if [ -z "$JAVA_HOME" ]; then
143 | javaExecutable="`which javac`"
144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
145 | # readlink(1) is not available as standard on Solaris 10.
146 | readLink=`which readlink`
147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
148 | if $darwin ; then
149 | javaHome="`dirname \"$javaExecutable\"`"
150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
151 | else
152 | javaExecutable="`readlink -f \"$javaExecutable\"`"
153 | fi
154 | javaHome="`dirname \"$javaExecutable\"`"
155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
156 | JAVA_HOME="$javaHome"
157 | export JAVA_HOME
158 | fi
159 | fi
160 | fi
161 |
162 | if [ -z "$JAVACMD" ] ; then
163 | if [ -n "$JAVA_HOME" ] ; then
164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
165 | # IBM's JDK on AIX uses strange locations for the executables
166 | JAVACMD="$JAVA_HOME/jre/sh/java"
167 | else
168 | JAVACMD="$JAVA_HOME/bin/java"
169 | fi
170 | else
171 | JAVACMD="`which java`"
172 | fi
173 | fi
174 |
175 | if [ ! -x "$JAVACMD" ] ; then
176 | echo "Error: JAVA_HOME is not defined correctly." >&2
177 | echo " We cannot execute $JAVACMD" >&2
178 | exit 1
179 | fi
180 |
181 | if [ -z "$JAVA_HOME" ] ; then
182 | echo "Warning: JAVA_HOME environment variable is not set."
183 | fi
184 |
185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
186 |
187 | # traverses directory structure from process work directory to filesystem root
188 | # first directory with .mvn subdirectory is considered project base directory
189 | find_maven_basedir() {
190 | local basedir=$(pwd)
191 | local wdir=$(pwd)
192 | while [ "$wdir" != '/' ] ; do
193 | if [ -d "$wdir"/.mvn ] ; then
194 | basedir=$wdir
195 | break
196 | fi
197 | wdir=$(cd "$wdir/.."; pwd)
198 | done
199 | echo "${basedir}"
200 | }
201 |
202 | # concatenates all lines of a file
203 | concat_lines() {
204 | if [ -f "$1" ]; then
205 | echo "$(tr -s '\n' ' ' < "$1")"
206 | fi
207 | }
208 |
209 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
210 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
211 |
212 | # For Cygwin, switch paths to Windows format before running java
213 | if $cygwin; then
214 | [ -n "$M2_HOME" ] &&
215 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
216 | [ -n "$JAVA_HOME" ] &&
217 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
218 | [ -n "$CLASSPATH" ] &&
219 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
220 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
221 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
222 | fi
223 |
224 | # Provide a "standardized" way to retrieve the CLI args that will
225 | # work with both Windows and non-Windows executions.
226 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
227 | export MAVEN_CMD_LINE_ARGS
228 |
229 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
230 |
231 | # avoid using MAVEN_CMD_LINE_ARGS below since that would loose parameter escaping in $@
232 | exec "$JAVACMD" \
233 | $MAVEN_OPTS \
234 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
235 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
236 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
237 |
--------------------------------------------------------------------------------
/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-spring-jaeger-cloud-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | 4.0.0
19 |
20 |
21 | io.opentracing.contrib
22 | opentracing-spring-jaeger-parent
23 | 3.3.4-SNAPSHOT
24 |
25 |
26 | opentracing-spring-jaeger-cloud-starter
27 |
28 |
29 | ${project.basedir}/..
30 | 0.5.9
31 |
32 |
33 |
34 |
35 | ${project.groupId}
36 | opentracing-spring-jaeger-starter
37 |
38 |
39 |
40 | io.opentracing.contrib
41 | opentracing-spring-cloud-starter
42 | ${opentracing-spring-cloud-starter.version}
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | 4.0.0
19 |
20 |
21 | io.opentracing.contrib
22 | opentracing-spring-jaeger-parent
23 | 3.3.4-SNAPSHOT
24 |
25 |
26 | opentracing-spring-jaeger-starter
27 |
28 |
29 | ${project.basedir}/..
30 |
31 |
32 |
33 |
34 | io.opentracing.contrib
35 | opentracing-spring-tracer-configuration-starter
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-autoconfigure
40 | true
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-configuration-processor
45 | true
46 |
47 |
48 | io.opentracing
49 | opentracing-api
50 |
51 |
52 | io.jaegertracing
53 | jaeger-client
54 |
55 |
56 |
57 | org.springframework.boot
58 | spring-boot-starter-test
59 | test
60 |
61 |
62 | org.springframework.boot
63 | spring-boot-starter-logging
64 | test
65 |
66 |
67 | org.springframework.boot
68 | spring-boot-starter-web
69 | test
70 |
71 |
72 | io.opentracing
73 | opentracing-mock
74 | test
75 |
76 |
77 | org.assertj
78 | assertj-core
79 | test
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2021 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.java.spring.jaeger.starter;
15 |
16 | import io.jaegertracing.internal.JaegerTracer;
17 | import io.jaegertracing.internal.metrics.Metrics;
18 | import io.jaegertracing.internal.metrics.NoopMetricsFactory;
19 | import io.jaegertracing.internal.reporters.CompositeReporter;
20 | import io.jaegertracing.internal.reporters.LoggingReporter;
21 | import io.jaegertracing.internal.samplers.ConstSampler;
22 | import io.jaegertracing.internal.samplers.HttpSamplingManager;
23 | import io.jaegertracing.internal.samplers.ProbabilisticSampler;
24 | import io.jaegertracing.internal.samplers.RateLimitingSampler;
25 | import io.jaegertracing.internal.samplers.RemoteControlledSampler;
26 | import io.jaegertracing.spi.MetricsFactory;
27 | import io.jaegertracing.spi.Reporter;
28 | import io.jaegertracing.spi.Sampler;
29 | import io.jaegertracing.spi.Sender;
30 | import io.opentracing.contrib.java.spring.jaeger.starter.JaegerConfigurationProperties.RemoteReporter;
31 | import io.opentracing.contrib.java.spring.jaeger.starter.customizers.B3CodecTracerBuilderCustomizer;
32 | import io.opentracing.contrib.java.spring.jaeger.starter.customizers.ExpandExceptionLogsTracerBuilderCustomizer;
33 | import io.opentracing.contrib.java.spring.jaeger.starter.customizers.HigherBitTracerBuilderCustomizer;
34 |
35 | import io.opentracing.contrib.java.spring.jaeger.starter.customizers.TraceContextCodecTracerBuilderCustomizer;
36 | import java.util.Collections;
37 | import java.util.LinkedList;
38 | import java.util.List;
39 |
40 | import org.apache.thrift.transport.TTransportException;
41 | import org.springframework.beans.factory.annotation.Autowired;
42 | import org.springframework.boot.autoconfigure.AutoConfigureBefore;
43 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
44 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
45 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
46 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
47 | import org.springframework.context.annotation.Bean;
48 | import org.springframework.context.annotation.Configuration;
49 | import org.springframework.util.StringUtils;
50 |
51 | /**
52 | * @author Gytis Trikleris
53 | */
54 | @Configuration
55 | @ConditionalOnClass(io.jaegertracing.internal.JaegerTracer.class)
56 | @ConditionalOnMissingBean(io.opentracing.Tracer.class)
57 | @ConditionalOnProperty(value = "opentracing.jaeger.enabled", havingValue = "true", matchIfMissing = true)
58 | @AutoConfigureBefore(io.opentracing.contrib.spring.tracer.configuration.TracerAutoConfiguration.class)
59 | @EnableConfigurationProperties(JaegerConfigurationProperties.class)
60 | public class JaegerAutoConfiguration {
61 |
62 | @Autowired(required = false)
63 | private List tracerCustomizers = Collections.emptyList();
64 |
65 | @Bean
66 | public io.opentracing.Tracer tracer(Sampler sampler,
67 | Reporter reporter,
68 | Metrics metrics,
69 | JaegerConfigurationProperties properties) {
70 |
71 | final JaegerTracer.Builder builder =
72 | new JaegerTracer.Builder(properties.getServiceName())
73 | .withReporter(reporter)
74 | .withSampler(sampler)
75 | .withTags(properties.determineTags())
76 | .withMetrics(metrics);
77 |
78 | tracerCustomizers.forEach(c -> c.customize(builder));
79 |
80 | return builder.build();
81 | }
82 |
83 | @ConditionalOnMissingBean
84 | @Bean
85 | public Reporter reporter(JaegerConfigurationProperties properties,
86 | Metrics metrics,
87 | @Autowired(required = false) ReporterAppender reporterAppender) throws TTransportException {
88 |
89 | List reporters = new LinkedList<>();
90 | RemoteReporter remoteReporter = properties.getRemoteReporter();
91 |
92 | JaegerConfigurationProperties.HttpSender httpSender = properties.getHttpSender();
93 | if (!StringUtils.isEmpty(httpSender.getUrl())) {
94 | reporters.add(getHttpReporter(metrics, remoteReporter, httpSender));
95 | } else {
96 | reporters.add(getUdpReporter(metrics, remoteReporter, properties.getUdpSender()));
97 | }
98 |
99 | if (properties.isLogSpans()) {
100 | reporters.add(new LoggingReporter());
101 | }
102 |
103 | if (reporterAppender != null) {
104 | reporterAppender.append(reporters);
105 | }
106 |
107 | return new CompositeReporter(reporters.toArray(new Reporter[reporters.size()]));
108 | }
109 |
110 | private Reporter getUdpReporter(Metrics metrics,
111 | RemoteReporter remoteReporter,
112 | JaegerConfigurationProperties.UdpSender udpSenderProperties) throws TTransportException {
113 | io.jaegertracing.thrift.internal.senders.UdpSender udpSender =
114 | new io.jaegertracing.thrift.internal.senders.UdpSender(
115 | udpSenderProperties.getHost(), udpSenderProperties.getPort(),
116 | udpSenderProperties.getMaxPacketSize());
117 |
118 | return createReporter(metrics, remoteReporter, udpSender);
119 | }
120 |
121 | private Reporter getHttpReporter(Metrics metrics,
122 | RemoteReporter remoteReporter,
123 | JaegerConfigurationProperties.HttpSender httpSenderProperties) throws TTransportException {
124 | io.jaegertracing.thrift.internal.senders.HttpSender.Builder builder =
125 | new io.jaegertracing.thrift.internal.senders.HttpSender.Builder(httpSenderProperties.getUrl());
126 | if (httpSenderProperties.getMaxPayload() != null) {
127 | builder = builder.withMaxPacketSize(httpSenderProperties.getMaxPayload());
128 | }
129 | if (!StringUtils.isEmpty(httpSenderProperties.getUsername())
130 | && !StringUtils.isEmpty(httpSenderProperties.getPassword())) {
131 | builder.withAuth(httpSenderProperties.getUsername(), httpSenderProperties.getPassword());
132 | } else if (!StringUtils.isEmpty(httpSenderProperties.getAuthToken())) {
133 | builder.withAuth(httpSenderProperties.getAuthToken());
134 | }
135 |
136 | return createReporter(metrics, remoteReporter, builder.build());
137 | }
138 |
139 | private Reporter createReporter(Metrics metrics,
140 | RemoteReporter remoteReporter, Sender udpSender) {
141 | io.jaegertracing.internal.reporters.RemoteReporter.Builder builder =
142 | new io.jaegertracing.internal.reporters.RemoteReporter.Builder()
143 | .withSender(udpSender)
144 | .withMetrics(metrics);
145 |
146 | if (remoteReporter.getFlushInterval() != null) {
147 | builder.withFlushInterval(remoteReporter.getFlushInterval());
148 | }
149 | if (remoteReporter.getMaxQueueSize() != null) {
150 | builder.withMaxQueueSize(remoteReporter.getMaxQueueSize());
151 | }
152 |
153 | return builder.build();
154 | }
155 |
156 | @ConditionalOnMissingBean
157 | @Bean
158 | public Metrics metrics(MetricsFactory metricsFactory) {
159 | return new Metrics(metricsFactory);
160 | }
161 |
162 | @ConditionalOnMissingBean
163 | @Bean
164 | public MetricsFactory metricsFactory() {
165 | return new NoopMetricsFactory();
166 | }
167 |
168 | /**
169 | * Decide on what Sampler to use based on the various configuration options in
170 | * JaegerConfigurationProperties Fallback to ConstSampler(true) when no Sampler is configured
171 | */
172 | @ConditionalOnMissingBean
173 | @Bean
174 | public Sampler sampler(JaegerConfigurationProperties properties, Metrics metrics) {
175 | if (properties.getConstSampler().getDecision() != null) {
176 | return new ConstSampler(properties.getConstSampler().getDecision());
177 | }
178 |
179 | if (properties.getProbabilisticSampler().getSamplingRate() != null) {
180 | return new ProbabilisticSampler(properties.getProbabilisticSampler().getSamplingRate());
181 | }
182 |
183 | if (properties.getRateLimitingSampler().getMaxTracesPerSecond() != null) {
184 | return new RateLimitingSampler(properties.getRateLimitingSampler().getMaxTracesPerSecond());
185 | }
186 |
187 | if (!StringUtils.isEmpty(properties.getRemoteControlledSampler().getHostPort())) {
188 | JaegerConfigurationProperties.RemoteControlledSampler samplerProperties
189 | = properties.getRemoteControlledSampler();
190 |
191 | String hostPort = samplerProperties.getHostPort();
192 |
193 | if (samplerProperties.getHost() != null && !samplerProperties.getHost().isEmpty()) {
194 | hostPort = samplerProperties.getHost() + ":" + samplerProperties.getPort();
195 | }
196 |
197 | return new RemoteControlledSampler.Builder(properties.getServiceName())
198 | .withSamplingManager(new HttpSamplingManager(hostPort))
199 | .withInitialSampler(
200 | new ProbabilisticSampler(samplerProperties.getSamplingRate()))
201 | .withMetrics(metrics)
202 | .build();
203 | }
204 |
205 | //fallback to sampling every trace
206 | return new ConstSampler(true);
207 | }
208 |
209 | @Configuration
210 | @ConditionalOnProperty(value = "opentracing.jaeger.enable-b3-propagation")
211 | public static class B3CodecConfiguration {
212 |
213 | @Bean
214 | public TracerBuilderCustomizer b3CodecJaegerTracerCustomizer() {
215 | return new B3CodecTracerBuilderCustomizer();
216 | }
217 | }
218 |
219 | @Configuration
220 | @ConditionalOnProperty(value = "opentracing.jaeger.enable-w3c-propagation")
221 | public static class TraceContextCodecConfiguration {
222 |
223 | @Bean
224 | public TracerBuilderCustomizer traceContextCodecJaegerTracerCustomizer() {
225 | return new TraceContextCodecTracerBuilderCustomizer();
226 | }
227 | }
228 |
229 | @Configuration
230 | @ConditionalOnProperty(value = "opentracing.jaeger.enable-128-bit-traces")
231 | public static class HigherBitTraceConfiguration {
232 | @Bean
233 | public TracerBuilderCustomizer higherBitJaegerTracerCustomizer() {
234 | return new HigherBitTracerBuilderCustomizer();
235 | }
236 | }
237 |
238 | @Configuration
239 | @ConditionalOnProperty(value = "opentracing.jaeger.expand-exception-logs")
240 | public static class ExpandExceptionLogsConfiguration {
241 |
242 | @Bean
243 | public TracerBuilderCustomizer expandExceptionLogsJaegerTracerCustomizer() {
244 | return new ExpandExceptionLogsTracerBuilderCustomizer();
245 | }
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/JaegerConfigurationProperties.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-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.java.spring.jaeger.starter;
15 |
16 | import io.jaegertracing.Configuration;
17 | import java.util.HashMap;
18 | import java.util.Map;
19 |
20 | import org.springframework.beans.factory.annotation.Value;
21 | import org.springframework.boot.context.properties.ConfigurationProperties;
22 | import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
23 |
24 | @ConfigurationProperties("opentracing.jaeger")
25 | public class JaegerConfigurationProperties {
26 |
27 | private final RemoteReporter remoteReporter = new RemoteReporter();
28 | private final HttpSender httpSender = new HttpSender();
29 | private final UdpSender udpSender = new UdpSender();
30 | private final ConstSampler constSampler = new ConstSampler();
31 | private final ProbabilisticSampler probabilisticSampler = new ProbabilisticSampler();
32 | private final RateLimitingSampler rateLimitingSampler = new RateLimitingSampler();
33 | private final RemoteControlledSampler remoteControlledSampler = new RemoteControlledSampler();
34 |
35 |
36 | /**
37 | * Enable Jaeger Tracer
38 | */
39 | private boolean enabled = true;
40 |
41 | /**
42 | * Service name to be used
43 | * Expect certain properties in order, falling back to 'unknown-spring-boot'.
44 | */
45 | @Value("${jaeger.service-name:${spring.application.name:unknown-spring-boot}}")
46 | private String serviceName;
47 |
48 | /**
49 | * Whether spans should be logged to the console
50 | */
51 | private boolean logSpans = true;
52 | /**
53 | * Enable the handling of B3 headers like "X-B3-TraceId" This setting should be used when it is
54 | * desired for Jaeger to be able to join traces started by other Zipkin instrumented applications
55 | */
56 | private boolean enableB3Propagation = false;
57 |
58 | /**
59 | * Enable the generation of 128 bit trace ids. Default is 64 bit.
60 | */
61 | private boolean enable128BitTraces = false;
62 |
63 | private boolean expandExceptionLogs = false;
64 |
65 | private Map tags = new HashMap<>();
66 |
67 | /**
68 | * If enabled, tags from the JAEGER_TAGS env variable will be included
69 | */
70 | private boolean includeJaegerEnvTags = false;
71 |
72 | public boolean isEnabled() {
73 | return enabled;
74 | }
75 |
76 | public void setEnabled(boolean enabled) {
77 | this.enabled = enabled;
78 | }
79 |
80 | public String getServiceName() {
81 | return serviceName;
82 | }
83 |
84 | public void setServiceName(String serviceName) {
85 | this.serviceName = serviceName;
86 | }
87 |
88 | public boolean isLogSpans() {
89 | return logSpans;
90 | }
91 |
92 | public void setLogSpans(boolean logSpans) {
93 | this.logSpans = logSpans;
94 | }
95 |
96 | public boolean isEnableB3Propagation() {
97 | return enableB3Propagation;
98 | }
99 |
100 | public void setEnableB3Propagation(boolean enableB3Propagation) {
101 | this.enableB3Propagation = enableB3Propagation;
102 | }
103 |
104 | public boolean isEnable128BitTraces() {
105 | return enable128BitTraces;
106 | }
107 |
108 | public void setEnable128BitTraces(boolean enable128BitTraces) {
109 | this.enable128BitTraces = enable128BitTraces;
110 | }
111 |
112 | public boolean isExpandExceptionLogs() {
113 | return expandExceptionLogs;
114 | }
115 |
116 | public void setExpandExceptionLogs(boolean expandExceptionLogs) {
117 | this.expandExceptionLogs = expandExceptionLogs;
118 | }
119 |
120 | public Map getTags() {
121 | return tags;
122 | }
123 |
124 | public void setTags(Map tags) {
125 | this.tags = tags;
126 | }
127 |
128 | public Map determineTags() {
129 | if (!includeJaegerEnvTags) {
130 | return tags;
131 | }
132 |
133 | final Map result = new HashMap<>(tags);
134 | result.putAll(tracerTagsFromEnv());
135 | return result;
136 | }
137 |
138 | // inspired by io.jaegertracing.Configuration#tracerTagsFromEnv
139 | private Map tracerTagsFromEnv() {
140 | final Map tracerTagMaps = new HashMap<>();
141 | final String tracerTags = getProperty(Configuration.JAEGER_TAGS);
142 | if (tracerTags != null) {
143 | final String[] tags = tracerTags.split("\\s*,\\s*");
144 | for (String tag : tags) {
145 | final String[] tagValue = tag.split("\\s*=\\s*");
146 | if (tagValue.length == 2) {
147 | tracerTagMaps.put(tagValue[0], tagValue[1]);
148 | }
149 | }
150 | }
151 | return tracerTagMaps;
152 | }
153 |
154 | /**
155 | * Retrieve a property name either from the Java system properties or Environment Variables
156 | */
157 | private String getProperty(String name) {
158 | return System.getProperty(name, System.getenv(name));
159 | }
160 |
161 | public boolean isIncludeJaegerEnvTags() {
162 | return includeJaegerEnvTags;
163 | }
164 |
165 | public void setIncludeJaegerEnvTags(boolean includeJaegerEnvTags) {
166 | this.includeJaegerEnvTags = includeJaegerEnvTags;
167 | }
168 |
169 | public HttpSender getHttpSender() {
170 | return httpSender;
171 | }
172 |
173 | public RemoteReporter getRemoteReporter() {
174 | return remoteReporter;
175 | }
176 |
177 | public UdpSender getUdpSender() {
178 | return udpSender;
179 | }
180 |
181 | public ConstSampler getConstSampler() {
182 | return constSampler;
183 | }
184 |
185 | public ProbabilisticSampler getProbabilisticSampler() {
186 | return probabilisticSampler;
187 | }
188 |
189 | public RateLimitingSampler getRateLimitingSampler() {
190 | return rateLimitingSampler;
191 | }
192 |
193 | public RemoteControlledSampler getRemoteControlledSampler() {
194 | return remoteControlledSampler;
195 | }
196 |
197 |
198 | public static class RemoteReporter {
199 |
200 | private Integer flushInterval;
201 |
202 | private Integer maxQueueSize;
203 |
204 | public Integer getFlushInterval() {
205 | return flushInterval;
206 | }
207 |
208 | public void setFlushInterval(Integer flushInterval) {
209 | this.flushInterval = flushInterval;
210 | }
211 |
212 | public Integer getMaxQueueSize() {
213 | return maxQueueSize;
214 | }
215 |
216 | public void setMaxQueueSize(Integer maxQueueSize) {
217 | this.maxQueueSize = maxQueueSize;
218 | }
219 | }
220 |
221 | /**
222 | * If the URL is set, then HttpSender is used regardless
223 | * of the configuration in UdpSender
224 | */
225 | public static class HttpSender {
226 |
227 | private String url;
228 |
229 | private Integer maxPayload = 0;
230 |
231 | private String username;
232 |
233 | private String password;
234 |
235 | private String authToken;
236 |
237 | public String getUrl() {
238 | return url;
239 | }
240 |
241 | public void setUrl(String url) {
242 | this.url = url;
243 | }
244 |
245 | public Integer getMaxPayload() {
246 | return maxPayload;
247 | }
248 |
249 | public void setMaxPayload(Integer maxPayload) {
250 | this.maxPayload = maxPayload;
251 | }
252 |
253 | public String getUsername() {
254 | return username;
255 | }
256 |
257 | public void setUsername(String username) {
258 | this.username = username;
259 | }
260 |
261 | public String getPassword() {
262 | return password;
263 | }
264 |
265 | public void setPassword(String password) {
266 | this.password = password;
267 | }
268 |
269 | public String getAuthToken() {
270 | return authToken;
271 | }
272 |
273 | public void setAuthToken(String authToken) {
274 | this.authToken = authToken;
275 | }
276 | }
277 |
278 | public static class UdpSender {
279 |
280 | private String host = "localhost";
281 |
282 | private int port = 6831;
283 |
284 | private int maxPacketSize = 0;
285 |
286 | public String getHost() {
287 | return host;
288 | }
289 |
290 | public void setHost(String host) {
291 | this.host = host;
292 | }
293 |
294 | public int getPort() {
295 | return port;
296 | }
297 |
298 | public void setPort(int port) {
299 | this.port = port;
300 | }
301 |
302 | public int getMaxPacketSize() {
303 | return maxPacketSize;
304 | }
305 |
306 | public void setMaxPacketSize(int maxPacketSize) {
307 | this.maxPacketSize = maxPacketSize;
308 | }
309 | }
310 |
311 | public static class ConstSampler {
312 |
313 | private Boolean decision;
314 |
315 | public Boolean getDecision() {
316 | return decision;
317 | }
318 |
319 | public void setDecision(Boolean decision) {
320 | this.decision = decision;
321 | }
322 | }
323 |
324 | public static class ProbabilisticSampler {
325 |
326 | private Double samplingRate;
327 |
328 | public Double getSamplingRate() {
329 | return samplingRate;
330 | }
331 |
332 | public void setSamplingRate(Double samplingRate) {
333 | this.samplingRate = samplingRate;
334 | }
335 | }
336 |
337 | public static class RateLimitingSampler {
338 |
339 | private Double maxTracesPerSecond;
340 |
341 | public Double getMaxTracesPerSecond() {
342 | return maxTracesPerSecond;
343 | }
344 |
345 | public void setMaxTracesPerSecond(Double maxTracesPerSecond) {
346 | this.maxTracesPerSecond = maxTracesPerSecond;
347 | }
348 | }
349 |
350 | public static class RemoteControlledSampler {
351 |
352 | /**
353 | * i.e. localhost:5778
354 | */
355 | private String hostPort;
356 |
357 | private String host;
358 |
359 | private int port = 5778;
360 |
361 | private Double samplingRate =
362 | io.jaegertracing.internal.samplers.ProbabilisticSampler.DEFAULT_SAMPLING_PROBABILITY;
363 |
364 |
365 | @DeprecatedConfigurationProperty(replacement = "Use host + port properties instead")
366 | public String getHostPort() {
367 | return hostPort;
368 | }
369 |
370 | public void setHostPort(String hostPort) {
371 | this.hostPort = hostPort;
372 | }
373 |
374 | public int getPort() {
375 | return port;
376 | }
377 |
378 | public void setPort(int port) {
379 | this.port = port;
380 | }
381 |
382 | public String getHost() {
383 | return host;
384 | }
385 |
386 | public void setHost(String host) {
387 | this.host = host;
388 | }
389 |
390 | public Double getSamplingRate() {
391 | return samplingRate;
392 | }
393 |
394 | public void setSamplingRate(Double samplingRate) {
395 | this.samplingRate = samplingRate;
396 | }
397 | }
398 | }
399 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/ReporterAppender.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 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.java.spring.jaeger.starter;
15 |
16 | import io.jaegertracing.spi.Reporter;
17 | import java.util.Collection;
18 |
19 | @FunctionalInterface
20 | public interface ReporterAppender {
21 |
22 | /**
23 | * Provides the ability to add custom Reporters other than the ones that are auto-configured based
24 | * on the configuration Implementation should only add reporters to the collection
25 | */
26 | void append(Collection reporters);
27 | }
28 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/TracerBuilderCustomizer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 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.java.spring.jaeger.starter;
15 |
16 | import io.jaegertracing.internal.JaegerTracer;
17 |
18 | @FunctionalInterface
19 | public interface TracerBuilderCustomizer {
20 |
21 | /**
22 | * Provides the ability to execute arbitrary operations on the builder The customizer should NOT
23 | * call the build method
24 | */
25 | void customize(JaegerTracer.Builder builder);
26 | }
27 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/customizers/B3CodecTracerBuilderCustomizer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-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.java.spring.jaeger.starter.customizers;
15 |
16 | import io.jaegertracing.internal.JaegerTracer;
17 | import io.jaegertracing.internal.propagation.B3TextMapCodec;
18 | import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer;
19 | import io.opentracing.propagation.Format;
20 |
21 | public class B3CodecTracerBuilderCustomizer implements TracerBuilderCustomizer {
22 |
23 | @Override
24 | public void customize(JaegerTracer.Builder builder) {
25 | B3TextMapCodec injector = new B3TextMapCodec.Builder().build();
26 |
27 | builder.registerInjector(Format.Builtin.HTTP_HEADERS, injector)
28 | .registerExtractor(Format.Builtin.HTTP_HEADERS, injector);
29 |
30 | builder.registerInjector(Format.Builtin.TEXT_MAP, injector)
31 | .registerExtractor(Format.Builtin.TEXT_MAP, injector);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/customizers/ExpandExceptionLogsTracerBuilderCustomizer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2020 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.java.spring.jaeger.starter.customizers;
15 |
16 | import io.jaegertracing.internal.JaegerTracer;
17 | import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer;
18 |
19 | public class ExpandExceptionLogsTracerBuilderCustomizer implements TracerBuilderCustomizer {
20 |
21 | @Override
22 | public void customize(JaegerTracer.Builder builder) {
23 | builder.withExpandExceptionLogs();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/customizers/HigherBitTracerBuilderCustomizer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-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.java.spring.jaeger.starter.customizers;
15 |
16 | import io.jaegertracing.internal.JaegerTracer;
17 | import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer;
18 |
19 | public class HigherBitTracerBuilderCustomizer implements TracerBuilderCustomizer {
20 | @Override
21 | public void customize(JaegerTracer.Builder builder) {
22 | builder.withTraceId128Bit();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/customizers/TraceContextCodecTracerBuilderCustomizer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2021 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.java.spring.jaeger.starter.customizers;
15 |
16 | import io.jaegertracing.internal.JaegerTracer.Builder;
17 | import io.jaegertracing.internal.propagation.TraceContextCodec;
18 | import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer;
19 | import io.opentracing.propagation.Format;
20 |
21 | public class TraceContextCodecTracerBuilderCustomizer implements TracerBuilderCustomizer {
22 |
23 | @Override
24 | public void customize(Builder builder) {
25 | TraceContextCodec injector = new TraceContextCodec.Builder().build();
26 |
27 | builder.registerInjector(Format.Builtin.HTTP_HEADERS, injector)
28 | .registerExtractor(Format.Builtin.HTTP_HEADERS, injector);
29 |
30 | builder.registerInjector(Format.Builtin.TEXT_MAP, injector)
31 | .registerExtractor(Format.Builtin.TEXT_MAP, injector);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2 | io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration
--------------------------------------------------------------------------------
/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/AbstractSenderSpringTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2018-2021 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.java.spring.jaeger.starter;
15 |
16 | import static org.assertj.core.api.Assertions.as;
17 | import static org.assertj.core.api.Assertions.assertThat;
18 |
19 | import io.jaegertracing.internal.reporters.CompositeReporter;
20 | import io.jaegertracing.internal.reporters.RemoteReporter;
21 | import io.jaegertracing.spi.Reporter;
22 | import org.assertj.core.api.Condition;
23 | import org.assertj.core.api.InstanceOfAssertFactories;
24 |
25 | public abstract class AbstractSenderSpringTest extends AbstractTracerSpringTest {
26 |
27 | protected void assertSenderClass(Class senderClass) {
28 | assertThat(getTracer())
29 | .extracting("reporter")
30 | .extracting("class", as(InstanceOfAssertFactories.CLASS))
31 | .isEqualTo(CompositeReporter.class);
32 |
33 | assertThat(getTracer())
34 | .extracting("reporter").isInstanceOfSatisfying(CompositeReporter.class, c -> {
35 | assertThat(c)
36 | .extracting("reporters", as(InstanceOfAssertFactories.list(Reporter.class)))
37 | .filteredOn(new Condition