-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Endpoint.ipv6 field with supporting changes to MySQL and UI
This adds `Endpoint.ipv6` as a fixed-width byte array (16 bytes). This formalizes `Endpoint.ipv4 == 0` implying there's no ipv4 address. In thrift, this remains a byte array (String) at field 4. In json, this is normal string formatting. * normal java utilities are used for codec (Inet6Address) In the UI, the ipv6 address is preferred and bracketed when present. Ex. [2001:db8:0:0:0:0:0:c002]:8080 In MySQL, this is mapped to a `BINARY(16)` field named `zipkin_annotations.endpoint_ipv6`. When this column is missing a warning like below is printed: ``` Jul 11, 2016 4:08:53 PM zipkin.storage.mysql.HasIpv6 compute WARNING: zipkin_annotations.ipv6 doesn't exist, so Endpoint.ipv6 is not supported. Execute: alter table zipkin_annotations add `endpoint_ipv6` BINARY(16) ``` Fixes #306
- Loading branch information
Adrian Cole
committed
Jul 11, 2016
1 parent
9ad7f59
commit 0fad8fd
Showing
23 changed files
with
474 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ | ||
"traceId": "83c138a4ee0f3de9", | ||
"name": "get", | ||
"id": "d673d7abe80d2f3f", | ||
"parentId": "83c138a4ee0f3de9", | ||
"timestamp": 1461750491274000, | ||
"duration": 51000, | ||
"annotations": [ | ||
{ | ||
"timestamp": 1461750491274000, | ||
"value": "cs", | ||
"endpoint": { | ||
"serviceName": "zipkin-web", | ||
"ipv6": "2001:db8::c001" | ||
} | ||
}, | ||
{ | ||
"timestamp": 1461750491274000, | ||
"value": "ws", | ||
"endpoint": { | ||
"serviceName": "zipkin-web", | ||
"ipv6": "2001:db8::c001" | ||
} | ||
}, | ||
{ | ||
"timestamp": 1461750491298000, | ||
"value": "sr", | ||
"endpoint": { | ||
"serviceName": "zipkin-query", | ||
"ipv6": "2001:db8::c002", | ||
"port": 9411 | ||
} | ||
}, | ||
{ | ||
"timestamp": 1461750491302000, | ||
"value": "ss", | ||
"endpoint": { | ||
"serviceName": "zipkin-query", | ||
"ipv6": "2001:db8::c002", | ||
"port": 9411 | ||
} | ||
}, | ||
{ | ||
"timestamp": 1461750491325000, | ||
"value": "cr", | ||
"endpoint": { | ||
"serviceName": "zipkin-web", | ||
"ipv6": "2001:db8::c001" | ||
} | ||
}, | ||
{ | ||
"timestamp": 1461750491325000, | ||
"value": "wr", | ||
"endpoint": { | ||
"serviceName": "zipkin-web", | ||
"ipv6": "2001:db8::c001" | ||
} | ||
} | ||
], | ||
"binaryAnnotations": [ | ||
{ | ||
"key": "http.path", | ||
"value": "/api/v1/traces", | ||
"endpoint": { | ||
"serviceName": "zipkin-query", | ||
"ipv6": "2001:db8::c002" | ||
} | ||
}, | ||
{ | ||
"key": "srv/finagle.version", | ||
"value": "6.34.0", | ||
"endpoint": { | ||
"serviceName": "zipkin-query", | ||
"ipv6": "2001:db8::c002" | ||
} | ||
}, | ||
{ | ||
"key": "sa", | ||
"value": true, | ||
"endpoint": { | ||
"serviceName": "zipkin-query", | ||
"ipv6": "2001:db8::c002", | ||
"port": 9411 | ||
} | ||
}, | ||
{ | ||
"key": "ca", | ||
"value": true, | ||
"endpoint": { | ||
"serviceName": "zipkin-query", | ||
"ipv6": "2001:db8::c002", | ||
"port": 42291 | ||
} | ||
}, | ||
{ | ||
"key": "http.uri", | ||
"value": "/api/v1/traces", | ||
"endpoint": { | ||
"serviceName": "zipkin-web", | ||
"ipv6": "2001:db8::c001" | ||
} | ||
}, | ||
{ | ||
"key": "clnt/finagle.version", | ||
"value": "6.34.0", | ||
"endpoint": { | ||
"serviceName": "zipkin-web", | ||
"ipv6": "2001:db8::c001" | ||
} | ||
}, | ||
{ | ||
"key": "sa", | ||
"value": true, | ||
"endpoint": { | ||
"serviceName": "zipkin-query", | ||
"ipv6": "2001:db8::c002", | ||
"port": 9411 | ||
} | ||
}, | ||
{ | ||
"key": "ca", | ||
"value": true, | ||
"endpoint": { | ||
"serviceName": "zipkin-web", | ||
"ipv6": "2001:db8::c001", | ||
"port": 42291 | ||
} | ||
} | ||
] | ||
} |
59 changes: 59 additions & 0 deletions
59
zipkin-storage/mysql/src/main/java/zipkin/storage/mysql/HasIpv6.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright 2015-2016 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package zipkin.storage.mysql; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.sql.DataSource; | ||
import org.jooq.DSLContext; | ||
import org.jooq.exception.DataAccessException; | ||
import zipkin.internal.Lazy; | ||
|
||
import static zipkin.storage.mysql.internal.generated.tables.ZipkinAnnotations.ZIPKIN_ANNOTATIONS; | ||
|
||
final class HasIpv6 extends Lazy<Boolean> { | ||
private static final Logger LOG = Logger.getLogger(HasIpv6.class.getName()); | ||
|
||
final DataSource datasource; | ||
final DSLContexts context; | ||
|
||
HasIpv6(DataSource datasource, DSLContexts context) { | ||
this.datasource = datasource; | ||
this.context = context; | ||
} | ||
|
||
@Override protected Boolean compute() { | ||
try (Connection conn = datasource.getConnection()) { | ||
DSLContext dsl = context.get(conn); | ||
dsl.select(ZIPKIN_ANNOTATIONS.ENDPOINT_IPV6).from(ZIPKIN_ANNOTATIONS).limit(1).fetchAny(); | ||
return true; | ||
} catch (DataAccessException e) { | ||
if (e.sqlState().equals("42S22")) { | ||
LOG.warning("zipkin_annotations.ipv6 doesn't exist, so Endpoint.ipv6 is not supported. " + | ||
"Execute: alter table zipkin_annotations add `endpoint_ipv6` BINARY(16)"); | ||
return false; | ||
} | ||
problemReading(e); | ||
} catch (SQLException | RuntimeException e) { | ||
problemReading(e); | ||
} | ||
return false; | ||
} | ||
|
||
static void problemReading(Exception e) { | ||
LOG.log(Level.WARNING, "problem reading zipkin_annotations.ipv6", e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.