Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHOENIX-5215 remove SYSTEM.TRACING_STATS related code #1721

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
17 changes: 14 additions & 3 deletions bin/phoenix_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@
import sys
import phoenix_utils

# Since sandbox is used exclusively for development and debugging, it is easiest to
# unconditionally enable tracing
def set_sandbox_tracing():
global sandbox_trace_opts
sandbox_trace_opts = os.environ.get("PHOENIX_TRACE_OPTS")
if sandbox_trace_opts is None or phoenix_trace_opts == "":
sandbox_trace_opts = " -javaagent:" + phoenix_utils.opentelemetry_agent_jar + " -Dotel.metrics.exporter=none -Dotel.instrumentation.jdbc.enabled=false"
return ""

phoenix_utils.setPath()
set_sandbox_tracing()

base_dir = os.path.join(phoenix_utils.current_dir, '..')
phoenix_target_dir = os.path.join(base_dir, 'phoenix-core', 'target')
Expand All @@ -44,9 +54,10 @@
with open(cp_file_path, 'r') as cp_file:
cp_components.append(cp_file.read())

java_cmd = ("java $PHOENIX_OPTS -Dlog4j2.configurationFile=file:%s " +
"-cp %s org.apache.phoenix.Sandbox") % (
logging_config, ":".join(cp_components))
java_cmd = ("java -Dlog4j2.configurationFile=file:%s " +
' ' + sandbox_trace_opts + ' -Dotel.service.name="phoenix-sandbox" ' +
"-cp %s org.apache.phoenix.Sandbox") % (
logging_config, ":".join(cp_components))

proc = subprocess.Popen(java_cmd, shell=True)
try:
Expand Down
39 changes: 35 additions & 4 deletions bin/phoenix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@ def setPath():
LOGGING_JAR_PATTERN2 = "log4j-api*.jar"
LOGGING_JAR_PATTERN3 = "log4j-1.2-api*.jar"
SQLLINE_WITH_DEPS_PATTERN = "sqlline-*-jar-with-dependencies.jar"

OPENTELEMETRY_AGENT_PATTERN = "opentelemetry-javaagent*.jar"
OPENTELEMETRY_AGENT_EXTENSION_PATTERN = "phoenix-opentelemetry-trace-sampler-*[!s].jar"

OVERRIDE_SLF4J_BACKEND = "OVERRIDE_SLF4J_BACKEND_JAR_LOCATION"
OVERRIDE_LOGGING = "OVERRIDE_LOGGING_JAR_LOCATION"
OVERRIDE_SQLLINE = "OVERRIDE_SQLLINE_JAR_LOCATION"
OVERRIDE_OPENTELEMETRY_AGENT = "OVERRIDE_OPENTELEMETRY_AGENT_JAR_LOCATION"
OVERRIDE_OPENTELEMETRY_AGENT_EXTENSION = "OVERRIDE_OPENTELEMETRY_AGENT_EXTENSION_JAR_LOCATION"

# Backward support old env variable PHOENIX_LIB_DIR replaced by PHOENIX_CLASS_PATH
global phoenix_class_path
Expand Down Expand Up @@ -185,12 +188,34 @@ def setPath():
global logging_jar
logging_jar = os.environ.get(OVERRIDE_LOGGING)
if logging_jar is None or logging_jar == "":
logging_jar = findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN, os.path.join(current_dir, "..","lib"))
logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN2, os.path.join(current_dir, "..","lib"))
logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN3, os.path.join(current_dir, "..","lib"))
logging_jar = findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN, os.path.join(current_dir, "..", "lib"))
logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN2, os.path.join(current_dir, "..", "lib"))
logging_jar += ":"+findFileInPathWithoutRecursion(LOGGING_JAR_PATTERN3, os.path.join(current_dir, "..", "lib"))

global opentelemetry_agent_jar
opentelemetry_agent_jar = os.environ.get(OVERRIDE_OPENTELEMETRY_AGENT)
if opentelemetry_agent_jar is None or opentelemetry_agent_jar == "":
opentelemetry_agent_jar = findFileInPathWithoutRecursion(OPENTELEMETRY_AGENT_PATTERN, os.path.join(current_dir, "..", "lib/tracing"))

global opentelemetry_agent_extension_jar
opentelemetry_agent_extension_jar = os.environ.get(OVERRIDE_OPENTELEMETRY_AGENT_EXTENSION)
if opentelemetry_agent_extension_jar is None or opentelemetry_agent_extension_jar == "":
opentelemetry_agent_extension_jar = findFileInPathWithoutRecursion(OPENTELEMETRY_AGENT_EXTENSION_PATTERN, os.path.join(current_dir, "..", "lib/tracing"))
if opentelemetry_agent_extension_jar is None or opentelemetry_agent_extension_jar == "":
opentelemetry_agent_extension_jar = findFileInPathWithoutRecursion(OPENTELEMETRY_AGENT_EXTENSION_PATTERN, os.path.join(current_dir, "..", "phoenix-opentelemetry-trace-sampler", "target"))
return ""


def set_tracing():
global phoenix_trace_opts
phoenix_trace_opts = os.environ.get("PHOENIX_TRACE_OPTS")
if phoenix_trace_opts is None or phoenix_trace_opts == "":
phoenix_trace_opts = " -javaagent:" + opentelemetry_agent_jar + \
" -Dotel.javaagent.extensions=" + opentelemetry_agent_extension_jar + \
" -Dotel.metrics.exporter=none -Dotel.instrumentation.jdbc.enabled=false -Dotel.traces.sampler=phoenix_hintable_sampler "
return ""


def shell_quote(args):
"""
Return the platform specific shell quoted string. Handles Windows and *nix platforms.
Expand All @@ -212,6 +237,9 @@ def common_sqlline_args(parser):
parser.add_argument('-fc', '--fastconnect',
help='Fetch all schemas on initial connection',
action="store_true")
parser.add_argument('--trace', help='Load and set up Opentelemetry agent',
action="store_true")
parser.add_argument('--traceratio', help='Default trace ratio')

if __name__ == "__main__":
setPath()
Expand All @@ -226,3 +254,6 @@ def common_sqlline_args(parser):
print("sqlline_with_deps_jar:", sqlline_with_deps_jar)
print("slf4j_backend_jar:", slf4j_backend_jar)
print("logging_jar:", logging_jar)
print("opentelemetry_agent_jar:", opentelemetry_agent_jar)
print("opentelemetry_agent_extension_jar:", opentelemetry_agent_extension_jar)

18 changes: 11 additions & 7 deletions bin/sqlline.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def kill_child():
atexit.register(kill_child)

phoenix_utils.setPath()
phoenix_utils.set_tracing()

parser = argparse.ArgumentParser(description='Launches the Apache Phoenix Client.')
# Positional argument 'zookeepers' is optional. The PhoenixDriver will automatically populate
Expand Down Expand Up @@ -123,6 +124,8 @@ def kill_child():
else:
disable_jna = ""

x = ( 'a' 'b')

java_cmd = java + ' $PHOENIX_OPTS ' + \
' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + \
phoenix_utils.hadoop_conf + os.pathsep + \
Expand All @@ -132,13 +135,14 @@ def kill_child():
phoenix_utils.phoenix_client_embedded_jar + \
'" -Dlog4j2.configurationFile=file:' + os.path.join(phoenix_utils.current_dir, "log4j2.properties") + \
disable_jna + \
" sqlline.SqlLine -d org.apache.phoenix.jdbc.PhoenixDriver" + \
(not args.noconnect and " -u " + phoenix_utils.shell_quote([jdbc_url]) or "") + \
" -n none -p none --color=" + \
(args.color and "true" or "false") + \
" --fastConnect=" + (args.fastconnect and "true" or "false") + \
" --verbose=" + (args.verbose and "true" or "false") + \
" --incremental=false --isolation=TRANSACTION_READ_COMMITTED " + sqlfile
((phoenix_utils.phoenix_trace_opts + ' -Dotel.service.name="phoenix-sqlline" ') if args.trace else "" ) + \
("" if args.traceratio is None else "-Dotel.traces.sampler.arg=" + args.traceratio) + \
" sqlline.SqlLine -d org.apache.phoenix.jdbc.PhoenixDriver " + \
("" if args.noconnect else (" -u " + phoenix_utils.shell_quote([jdbc_url]))) + \
" -n none -p none --color=" + ("true" if args.color else "false") + \
" --fastConnect=" + ("true" if args.fastconnect else "false") + \
" --verbose=" + ( "true" if args.verbose else "false") + \
" --incremental=false --isolation=TRANSACTION_READ_COMMITTED " + sqlfile

if args.verbose_command:
print("Executing java command: " + java_cmd)
Expand Down
30 changes: 22 additions & 8 deletions phoenix-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,38 @@
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-pherf</artifactId>
<artifactId>phoenix-opentelemetry-trace-sampler</artifactId>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-tracing-webapp</artifactId>
<artifactId>phoenix-pherf</artifactId>
</dependency>
<dependency>
<groupId>sqlline</groupId>
<artifactId>sqlline</artifactId>
<version>${sqlline.version}</version>
<classifier>jar-with-dependencies</classifier>
</dependency>

<dependency>
<groupId>io.opentelemetry.javaagent</groupId>
<artifactId>opentelemetry-javaagent</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</dependency>
</dependencies>

<profiles>
Expand Down Expand Up @@ -206,11 +225,6 @@
<artifactId>phoenix-shaded-guava</artifactId>
<version>${phoenix.thirdparty.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-tracing-webapp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-hbase-compat-2.4.0</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@
<include>org.apache.logging.log4j:log4j-1.2-api</include>
</includes>
</dependencySet>
<dependencySet>
<unpack>false</unpack>
<outputDirectory>/lib/tracing</outputDirectory>
<includes>
<include>io.opentelemetry.javaagent:opentelemetry-javaagent</include>
</includes>
</dependencySet>
</dependencySets>
</component>
9 changes: 9 additions & 0 deletions phoenix-assembly/src/build/components/all-common-jars.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,14 @@
<include>phoenix-pherf.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../phoenix-opentelemetry-trace-sampler/target</directory>
<!-- Should we copy this to the root dir like the other phoenix JARs ? -->
<outputDirectory>/lib/tracing/</outputDirectory>
<includes>
<!-- Would a versionless sampler JAR makes sense ? -->
<include>phoenix-opentelemetry-trace-sampler-${project.version}.jar</include>
</includes>
</fileSet>
</fileSets>
</component>
4 changes: 4 additions & 0 deletions phoenix-client-parent/phoenix-client-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
<artifactId>phoenix-hbase-compat-${hbase.compat.version}</artifactId>
<optional>false</optional>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-opentelemetry-trace-sampler</artifactId>
</dependency>
<!-- Exclude servlet and Jetty. We don't need it, and it causes problems with minicluster -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down
2 changes: 2 additions & 0 deletions phoenix-client-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
<pattern>io/</pattern>
<shadedPattern>${shaded.package}.io.</shadedPattern>
<excludes>
<!-- Must interoperate with opentelemetry-javaagent -->
<exclude>io.opentelemetry/**</exclude>
<!-- Exclude config keys for Hadoop that look like package names -->
<exclude>io/compression/**</exclude>
<exclude>io/mapfile/**</exclude>
Expand Down
31 changes: 27 additions & 4 deletions phoenix-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@
<outputDirectory>${project.basedir}/../lib</outputDirectory>
</configuration>
</execution>
<execution>
<id>copy-otel-agent-for-sqlline</id>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>io.opentelemetry.javaagent</groupId>
<artifactId>opentelemetry-javaagent</artifactId>
</artifactItem>
</artifactItems>
<outputDirectory>${project.basedir}/../lib/tracing</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down Expand Up @@ -500,10 +515,6 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.htrace</groupId>
<artifactId>htrace-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -569,6 +580,18 @@
<groupId>org.hdrhistogram</groupId>
<artifactId>HdrHistogram</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-context</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-semconv</artifactId>
</dependency>

<!-- Other test dependencies -->
<dependency>
Expand Down
Loading