Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

28 changes: 15 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,26 @@ name: build

on:
push:
branches: [ 3.x ]
branches: [ master ]
pull_request:
branches: [ 3.x ]
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn clean install -DskipTests -B -V
&& sh ./check_format.sh
&& mvn clean test
- name: Codecov
uses: codecov/codecov-action@v1
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn clean install -DskipTests -B -V
&& sh ./check_format.sh
&& mvn clean test
- name: Codecov
uses: codecov/codecov-action@v1
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ bak
*.iws
.DS_Store
nb-configuration.xml
coverage-report
logs
*.log
pom.xml.versionsBackup

pom.xml.versionsBackup
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## SOFATracer

[![Build Status](https://github.com/sofastack/sofa-tracer/workflows/build/badge.svg?branch=3.x)](https://github.com/sofastack/sofa-tracer/workflows/build/badge.svg?branch=3.x)
[![Coverage Status](https://coveralls.io/repos/github/alipay/sofa-tracer/badge.svg?branch=master)](https://coveralls.io/github/alipay/sofa-tracer?branch=master)
[![Build Status](https://github.com/sofastack/sofa-tracer/workflows/build/badge.svg?branch=master)](https://github.com/sofastack/sofa-tracer/workflows/build/badge.svg?branch=master)
[![Coverage Status](https://codecov.io/gh/sofastack/sofa-tracer/branch/master/graph/badge.svg)](https://codecov.io/gh/sofastack/sofa-tracer/branch/master)
![license](https://img.shields.io/badge/license-Apache--2.0-green.svg)
[![Maven](https://img.shields.io/github/release/alipay/sofa-tracer.svg)](https://github.com/alipay/sofa-tracer/releases)

Expand Down
31 changes: 0 additions & 31 deletions appveyor.yml

This file was deleted.

2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "pom.xml"
43 changes: 22 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>tracer-all-parent</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<packaging>pom</packaging>
<name>tracer-all-parent</name>
<description>Alipay SOFATracer Log Implemented by OpenTracing</description>
Expand Down Expand Up @@ -51,8 +51,6 @@
<main.user.dir>${user.dir}</main.user.dir>
<maven.staging.plugin>1.6.7</maven.staging.plugin>
<maven.gpg.pluign>1.5</maven.gpg.pluign>
<coveralls.maven.plugin>3.1.0</coveralls.maven.plugin>
<cobertura.maven.plugin>2.6</cobertura.maven.plugin>
</properties>

<licenses>
Expand Down Expand Up @@ -275,7 +273,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -404,26 +402,29 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${coveralls.maven.plugin}</version>
<configuration>
<sourceEncoding>${project.encoding}</sourceEncoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.maven.plugin}</version>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<encoding>${project.encoding}</encoding>
<aggregate>true</aggregate>
<formats>
<format>xml</format>
<format>html</format>
</formats>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>test</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-datasource-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void doReportStat(SofaTracerSpan sofaTracerSpan) {
tagsWithStr.get(DataSourceTracerKeys.DATABASE_NAME),
tagsWithStr.get(DataSourceTracerKeys.SQL) }));
//result
String resultCode = SofaTracerConstant.RESULT_CODE_SUCCESS.equals(tagsWithStr
String resultCode = SofaTracerConstant.RESULT_SUCCESS.equals(tagsWithStr
.get(CommonSpanTags.RESULT_CODE)) ? SofaTracerConstant.STAT_FLAG_SUCCESS
: SofaTracerConstant.STAT_FLAG_FAILS;
statKey.setResult(resultCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*/
package com.alipay.sofa.tracer.plugins.datasource.utils;

import com.alipay.common.tracer.core.appender.self.SelfLog;
import com.alipay.common.tracer.core.utils.AssertUtils;
import com.alipay.common.tracer.core.utils.StringUtils;
import com.alipay.sofa.common.code.LogCode2Description;
import com.alipay.sofa.tracer.plugins.datasource.tracer.Endpoint;

import java.lang.reflect.Method;
Expand All @@ -26,6 +28,8 @@
import java.util.Collections;
import java.util.List;

import static com.alipay.common.tracer.core.constants.SofaTracerConstant.SPACE_ID;

/**
* @author shusong.yss
* @author qilong.zql
Expand All @@ -52,6 +56,9 @@ public class DataSourceUtils {

public static final String ORACLE_PREFIX_THIN = "jdbc:oracle:thin:";

public static final String POSTGRE_PREFIX_THIN = "jdbc:postgresql://";


public static final int ORACLE_DEFAULT_PORT = 1521;

public static boolean isDruidDataSource(Object dataSource) {
Expand Down Expand Up @@ -172,25 +179,55 @@ public static boolean isTargetDataSource(String className, Object dataSource) {

public static List<Endpoint> getEndpointsFromConnectionURL(final String connectionURL) {
String currentUri = StringUtils.EMPTY_STRING;
List<Endpoint> endpoints = null;
if (StringUtils.isNotBlank(connectionURL) && connectionURL.startsWith(ORACLE_PREFIX_THIN)) {
currentUri = connectionURL.substring(ORACLE_PREFIX_THIN.length());
// parse endpoints by tns name.
endpoints = parseEndpointByTnsName(currentUri);
if (endpoints == null || endpoints.size() == 0 || null == endpoints.get(0)
|| StringUtils.isBlank(endpoints.get(0).getHost())) {
List<Endpoint> endpoints = Collections.emptyList();
try {
//首先jdbc:oracle:thin: 特殊解析
if (StringUtils.isNotBlank(connectionURL) && connectionURL.startsWith(ORACLE_PREFIX_THIN)) {

currentUri = connectionURL.substring(ORACLE_PREFIX_THIN.length());
// parse endpoints by tns name.
endpoints = parseEndpointByTnsName(currentUri);
}else if(StringUtils.isNotBlank(connectionURL) && connectionURL.startsWith(POSTGRE_PREFIX_THIN) && connectionURL.contains(",")){
//pg数据库 读写分离的配资
currentUri = connectionURL.substring(POSTGRE_PREFIX_THIN.length());
endpoints = parseEndpointByPgMulti(currentUri);
}
//普通解析 兜底
if (endpoints.size() == 0 || null == endpoints.get(0) || StringUtils.isBlank(endpoints.get(0).getHost())) {
// easy tns or others db url be resolve. it's a single endpoint.
Endpoint singleEndpoint = getEndpointFromConnectionURL(connectionURL);
if (StringUtils.isBlank(singleEndpoint.getHost()) || 0 == singleEndpoint.getPort()) {
throw new IllegalArgumentException("check your connectionURL: " + connectionURL);
}
endpoints = Collections.singletonList(singleEndpoint);
}
return endpoints;
}catch (Exception e){
//链接配置样式多,捕获异常,不影响启动
SelfLog.error(LogCode2Description.convert(SPACE_ID, "01-00015"),e);
}
return endpoints;
}

private static List<Endpoint> parseEndpointByPgMulti(String currentUri) {
List<Endpoint> endpoints = new ArrayList<>();
String[] urls = currentUri.split(",");
for (String url : urls) {
int hostEnd = url.indexOf(":");
String host = url.substring(0, hostEnd);
int portEnd = url.indexOf('/');
if (portEnd == -1) {
portEnd = url.length();
}
Integer port = Integer.parseInt(url.substring(hostEnd + 1, portEnd));
Endpoint endpoint = new Endpoint();
endpoint.setHost(host);
endpoint.setPort(port);
endpoints.add(endpoint);
}
return Collections.emptyList();
return endpoints;
}


private static List<Endpoint> parseEndpointByTnsName(final String url) {
final String upperCaseUrl = url.toUpperCase();
int beginIndex = upperCaseUrl.indexOf("DESCRIPTION");
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-dubbo-2.6.x-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-dubbo-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-flexible-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-httpclient-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-kafkamq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-mongodb-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-okhttp-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-rabbitmq-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion sofa-tracer-plugins/sofa-tracer-redis-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>tracer-all-parent</artifactId>
<groupId>com.alipay.sofa</groupId>
<version>3.1.0</version>
<version>3.1.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Loading