Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make traces exist gem

- Added has-sampled.rb, which uses tracesExist
- Bumped zipkin-query to 0.1.0
-
Added tracesExist to thrift files and generated ruby code

Author: @jerryli9876
Fixes #105
URL: #105
  • Loading branch information...
commit 727bd005c12afb7ef2ea3e3c24461a706de41126 1 parent 6047e9d
@jerryli9876 jerryli9876 authored
View
2  zipkin-gems/zipkin-query/lib/zipkin-query/version.rb
@@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
module ZipkinQuery
- VERSION = "0.0.3"
+ VERSION = "0.1.0"
end
View
61 zipkin-gems/zipkin-query/vendor/gen-rb/zipkin-query/zipkin_query.rb
@@ -60,6 +60,22 @@ def recv_getTraceIdsByAnnotation()
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getTraceIdsByAnnotation failed: unknown result')
end
+ def tracesExist(trace_ids)
+ send_tracesExist(trace_ids)
+ return recv_tracesExist()
+ end
+
+ def send_tracesExist(trace_ids)
+ send_message('tracesExist', TracesExist_args, :trace_ids => trace_ids)
+ end
+
+ def recv_tracesExist()
+ result = receive_message(TracesExist_result)
+ return result.success unless result.success.nil?
+ raise result.qe unless result.qe.nil?
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'tracesExist failed: unknown result')
+ end
+
def getTracesByIds(trace_ids, adjust)
send_getTracesByIds(trace_ids, adjust)
return recv_getTracesByIds()
@@ -273,6 +289,17 @@ def process_getTraceIdsByAnnotation(seqid, iprot, oprot)
write_result(result, oprot, 'getTraceIdsByAnnotation', seqid)
end
+ def process_tracesExist(seqid, iprot, oprot)
+ args = read_args(iprot, TracesExist_args)
+ result = TracesExist_result.new()
+ begin
+ result.success = @handler.tracesExist(args.trace_ids)
+ rescue Zipkin::QueryException => qe
+ result.qe = qe
+ end
+ write_result(result, oprot, 'tracesExist', seqid)
+ end
+
def process_getTracesByIds(seqid, iprot, oprot)
args = read_args(iprot, GetTracesByIds_args)
result = GetTracesByIds_result.new()
@@ -533,6 +560,40 @@ def validate
::Thrift::Struct.generate_accessors self
end
+ class TracesExist_args
+ include ::Thrift::Struct, ::Thrift::Struct_Union
+ TRACE_IDS = 1
+
+ FIELDS = {
+ TRACE_IDS => {:type => ::Thrift::Types::LIST, :name => 'trace_ids', :element => {:type => ::Thrift::Types::I64}}
+ }
+
+ def struct_fields; FIELDS; end
+
+ def validate
+ end
+
+ ::Thrift::Struct.generate_accessors self
+ end
+
+ class TracesExist_result
+ include ::Thrift::Struct, ::Thrift::Struct_Union
+ SUCCESS = 0
+ QE = 1
+
+ FIELDS = {
+ SUCCESS => {:type => ::Thrift::Types::SET, :name => 'success', :element => {:type => ::Thrift::Types::I64}},
+ QE => {:type => ::Thrift::Types::STRUCT, :name => 'qe', :class => Zipkin::QueryException}
+ }
+
+ def struct_fields; FIELDS; end
+
+ def validate
+ end
+
+ ::Thrift::Struct.generate_accessors self
+ end
+
class GetTracesByIds_args
include ::Thrift::Struct, ::Thrift::Struct_Union
TRACE_IDS = 1
View
31 zipkin-hadoop-job-runner/src/scripts/find_data.sh
@@ -1,31 +0,0 @@
-#!/bin/bash
-# Copyright 2012 Twitter Inc.
-#
-# 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.
-
-#Usage : find_data.sh hostname input_file_name server_name port_number is_key_data
-
-HOSTNAME=$1
-HDFSFILENAME=$2
-SERVERNAME=$3
-PORTNUMBER=$4
-ISKEYDATA=$5
-
-#Get the file location for the jar file with all the dependencies and moves it to where the job is being run
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-DIR="$(dirname "$DIR")"
-DIR="$(dirname "$DIR")"
-scp $DIR/target/zipkin-hadoop-job-runner-assembly-0.2.0-SNAPSHOT.jar $HOSTNAME:.
-
-#Reads the input into the server
-ssh -C $HOSTNAME "java -cp zipkin-hadoop-job-runner-assembly-0.2.0-SNAPSHOT.jar com.twitter.zipkin.hadoop.ProcessPopularKeys "$HDFSFILENAME" "$SERVERNAME" "$PORTNUMBER" "$ISKEYDATA
View
118 zipkin-hadoop-job-runner/src/scripts/has-sampled.rb
@@ -0,0 +1,118 @@
+#!/usr/bin/env ruby
+# Copyright 2012 Twitter Inc.
+#
+# 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.
+
+require 'rubygems'
+require 'zipkin-query'
+require 'thrift_client'
+require 'finagle-thrift'
+require 'zookeeper'
+require 'optparse'
+require 'ostruct'
+require 'set'
+
+class OptparseHasSampledArguments
+
+ #
+ # Return a structure describing the options.
+ #
+ def self.parse(args)
+ # The options specified on the command line will be collected in *options*.
+ # We set default values here.
+ options = OpenStruct.new
+ options.input = nil
+ options.output = nil
+ options.preprocessor = false
+
+ opts = OptionParser.new do |opts|
+ opts.banner = "Usage: run_job.rb -i INPUT -o OUTPUT"
+
+ opts.separator ""
+ opts.separator "Specific options:"
+
+ opts.on("-i", "--input INPUT",
+ "The INPUT file to read from") do |input|
+ options.input = input
+ end
+
+ opts.on("-o", "--output OUTPUT",
+ "The OUTPUT file to write to") do |output|
+ options.output = output
+ end
+
+ opts.separator ""
+ opts.separator "Common options:"
+ opts.on_tail("-h", "--help", "Show this message") do
+ puts opts
+ exit
+ end
+ end
+ opts.parse!(args)
+ options
+ end
+end
+
+options = OptparseHasSampledArguments.parse(ARGV)
+
+$config = {
+ :zipkin_query_host => "localhost", #whatever the collector is
+ :zipkin_query_port => 9411,
+ :skip_zookeeper => true
+}
+
+def sampled_traces(trace_ids)
+ result = false
+ traces = nil
+ ZipkinQuery::Client.with_transport($config) do |client|
+ traces = client.tracesExist(trace_ids)
+ end
+ return traces
+end
+
+def get_trace_id(line)
+ return line.split("\t")[1].to_i
+end
+
+File.open(options.output, 'w') do |out_file|
+ trace_list = []
+ File.open(options.input, 'r').each do |line|
+ trace_list = trace_list << get_trace_id(line)
+ end
+ sampled = sampled_traces(trace_list)
+ File.open(options.input, 'r').each do |line|
+ if (sampled.include?(get_trace_id(line)))
+ out_file.print line
+ puts line
+ end
+ end
+end
+
+=begin
+h = Hash.new
+
+File.open(options.input, 'r').each do |line|
+ ary = line.split("\t")
+ if h[ary[0]] == nil
+ h[ary[0]] = Array.new(1, ary[1].to_i)
+ else
+ h[ary[0]] = h[ary[0]] << ary[1].to_i
+ end
+end
+
+ary = Array.new()
+
+h.each do |service, traces|
+ p sampled_traces(traces)
+end
+=end
View
14 zipkin-hadoop/src/scripts/run_all_jobs.rb
@@ -1,4 +1,18 @@
#!/usr/bash/env ruby
+# Copyright 2012 Twitter Inc.
+#
+# 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.
+
# Runs all scalding jobs in package com.twitter.zipkin.hadoop
require 'optparse'
View
16 zipkin-hadoop/src/scripts/run_job.rb
@@ -1,5 +1,19 @@
#!/usr/bash/env ruby
-# Script that rxuns a single scalding job
+# Copyright 2012 Twitter Inc.
+#
+# 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.
+
+# Script that runs a single scalding job
require 'optparse'
require 'ostruct'
Please sign in to comment.
Something went wrong with that request. Please try again.