示例#1
0
def main():
    # Instantiates the Query Client
    query_client = MixpanelQueryClient('582d4b303bf22dd746b5bb1b9acbff63',
                                       '8b2d351133ac2a5d4df0700afc595fb6')

    componentNames = [
        "instagram-timeline", "facebook-wall", "github-events",
        "googleplus-timeline", "twitter-timeline", "pinterest-timeline",
        "finance-search", "open-weather", "traffic-incidents",
        "reddit-timeline", "spotify"
    ]

    if len(sys.argv) == 2 and sys.argv[1] in componentNames:
        component = sys.argv[1]
        print " ### COMPONENTE ", component, "  ###"
        if component == 'googleplus-timeline':
            total_latency_stable = 0
            total_latency_latency = 0
            general_time_stable = 0
            general_time_latency = 0
            tag = ""
            experiment_id = 0
            experiment_timestamp = 0
            request = ""
            result_id = ""
            # Obtain data from mixpanel
            # First, we obtain data generated from host versions.
            # The method will return a dict, where the field experiment_id will be the key
            # Then we'll obtain the events generated from the components
            query = 'properties["component"]==\"' + component + '\" and properties["version"]=="host"'

            # We obtain the events related to the results of the latency metric calculated (we'll check for duplicates later)
            query = 'properties["component"]==\"' + component + '\"'
            metrics = query_client.get_export(START_STUDY_DATE,
                                              END_DATE,
                                              'latencyMetric',
                                              where=query,
                                              result_key='version')

            for version, values in metrics.iteritems():
                if version != "host":
                    metric_value = values['requestDuration'] - metrics['host'][
                        'requestDuration']
                    print "----------------------------------"
                    print "Tiempo del cliente: %f" % values['requestDuration']
                    print "Tiempo del host: %f" % metrics['host'][
                        'requestDuration']
                    tag = version + " vs host"
                    result_id = values["experiment_id"] + tag
                    sendResults(component, values['experiment_id'],
                                values['experiment_timestamp'], tag,
                                metric_value, result_id)
        else:
            print ">>> Calculando métricas de latencia de experimentos realizados desde " + START_DATE + " hasta " + END_DATE
            # Obtain data from mixpanel
            # First, we obtain data generated from host versions.
            # The method will return a dict, where the field experiment_id will be the key
            # Then we'll obtain the events generated from the components
            query = 'properties["component"]==\"' + component + '\" and properties["version"]=="host"'
            experiments_dict = query_client.get_export(
                START_DATE,
                END_DATE,
                'latencyMetric',
                where=query,
                result_key='experiment_id')
            # We obtain the calculated metrics on the same range of time data to check if there is any latency records
            #(and to check later for duplicates)
            query = 'properties["component"]==\"' + component + '\"'
            latency_records = query_client.get_export(
                START_STUDY_DATE,
                END_DATE,
                'latencyResult',
                where=query,
                result_key='experiment_id')

            for experiment_id, experimentHost in experiments_dict.iteritems():
                # Checks if the actual experiment has been calculated (to not send duplicate results)
                print '------------------------------------------------------------------------------------------'
                print ">>> Id del experimento: ", experimentHost[
                    'experiment_id']

                # We obtain the event generated for every component experiment (one by component version)
                query = 'properties["experiment_id"]==\"' + experimentHost[
                    'experiment_id'] + '\" and properties["version"]!="host"'
                component_versions_experiments = query_client.get_export(
                    START_DATE,
                    END_DATE,
                    'latencyMetric',
                    where=query,
                    result_key='version')
                # We iterate over the events related to versions stable, accuracy_defects, latency_defects
                for key, experimentClient in component_versions_experiments.iteritems(
                ):
                    print "---------------------------------------"
                    tag = experimentClient["version"] + " vs host"
                    # We check for duplicate in latency results
                    result_id = experimentClient["experiment_id"] + tag
                    if latency_records == None:
                        # We calculate the differences and send it back to Mixpanel (component - host)
                        latency = experimentClient[
                            "requestDuration"] - experimentHost[
                                "requestDuration"]
                        sendResults(component, experimentHost["experiment_id"],
                                    experimentClient['experiment_timestamp'],
                                    tag, latency, result_id)
                    else:
                        if not result_id in latency_records:
                            # We calculate the differences and send it back to Mixpanel
                            latency = experimentClient[
                                "requestDuration"] - experimentHost[
                                    "requestDuration"]
                            print "Tiempo de latencia del cliente ", experimentClient[
                                "requestDuration"]
                            print "Tiempo de latencia del host ", experimentHost[
                                "requestDuration"]
                            sendResults(
                                component, experimentHost["experiment_id"],
                                experimentClient['experiment_timestamp'], tag,
                                latency, result_id)
                        else:
                            print ">>> El experimento " + experimentClient[
                                "experiment_id"] + " con la comparacion " + tag + " ya se ha calculado previamente, por lo que no volvemos a enviar los calculos"
    else:
        print "Wrong parameter"
        # {}: Obligatorio, []: opcional
        print "Usage: collectLatencyRecords.py {facebook-wall|instagram-timeline|github-events|googleplus-timeline|twitter-timeline | pinterest-timeline}"
#    See the License for the specific language governing permissions and
#    limitations under the License.

###############################################################################
#   This script get the results stored in Mixpanel and saves them in a file   #
###############################################################################

# First, we made the necessary imports to run the script
import json, csv, time
import mixpanel
from mixpanel_client import MixpanelQueryClient
from mixpanel import Mixpanel

# We need the tokens for Mixpanel projects to get the results
mp_latency = Mixpanel("53da31965c3d047fa72de756aae43db1") # events sender
query_client = MixpanelQueryClient('582d4b303bf22dd746b5bb1b9acbff63', '8b2d351133ac2a5d4df0700afc595fb6') # query client

# Initial and final date
START_DATE = "2017-04-04"
END_DATE = time.strftime("%Y-%m-%d")

# Query to get data of the all Results events
resp = query_client.get_export(START_DATE, END_DATE, 'latencyResult', result_key='result_id')

# Resp is a dict, access to fields
for key in resp.keys():
	# Time to show the information stored
	print "#########################################################"
	print "Componente: " + resp[key]["component"]
	print "Version evaluada: " + resp[key]["tag"]
	print "Valor de metrica: " + str(resp[key]["latency"])
def main():
	# Instantiates the Query Client
	query_client = MixpanelQueryClient('582d4b303bf22dd746b5bb1b9acbff63', '8b2d351133ac2a5d4df0700afc595fb6')

	componentNames = ["instagram-timeline", "facebook-wall", "github-events", "googleplus-timeline", "twitter-timeline", "pinterest-timeline", 
						"finance-search", "open-weather", "traffic-incidents", "reddit-timeline","spotify"]

	if len(sys.argv) == 2 and sys.argv[1] in componentNames:
		component = sys.argv[1]
		print " ### COMPONENTE ", component, "  ###"
		if component == 'googleplus-timeline':
			total_latency_stable = 0
			total_latency_latency = 0
			general_time_stable = 0
			general_time_latency = 0
			tag = ""
			experiment_id = 0
			experiment_timestamp = 0
			request = ""
			result_id = ""
			# Obtain data from mixpanel
			# First, we obtain data generated from host versions.
			# The method will return a dict, where the field experiment_id will be the key
			# Then we'll obtain the events generated from the components
			query = 'properties["component"]==\"' + component + '\" and properties["version"]=="host"'
			
			# We obtain the events related to the results of the latency metric calculated (we'll check for duplicates later)
			query = 'properties["component"]==\"' + component + '\"'
			metrics = query_client.get_export(START_STUDY_DATE,END_DATE, 'latencyMetric', where=query, result_key='version')

			for version, values in metrics.iteritems():
				if version != "host":
					metric_value = values['requestDuration'] - metrics['host']['requestDuration']
					print "----------------------------------"
					print "Tiempo del cliente: %f" % values['requestDuration']
					print "Tiempo del host: %f" % metrics['host']['requestDuration']
					tag = version + " vs host"
					result_id = values["experiment_id"] + tag
					sendResults(component, values['experiment_id'], values['experiment_timestamp'], tag, metric_value, result_id)
		else:
			print ">>> Calculando métricas de latencia de experimentos realizados desde " + START_DATE + " hasta " + END_DATE
			# Obtain data from mixpanel
			# First, we obtain data generated from host versions.
			# The method will return a dict, where the field experiment_id will be the key
			# Then we'll obtain the events generated from the components
			query = 'properties["component"]==\"' + component + '\" and properties["version"]=="host"'
			experiments_dict = query_client.get_export(START_DATE,END_DATE, 'latencyMetric', where=query, result_key='experiment_id')
			# We obtain the calculated metrics on the same range of time data to check if there is any latency records
			#(and to check later for duplicates)
			query = 'properties["component"]==\"' + component + '\"'
			latency_records = query_client.get_export(START_STUDY_DATE,END_DATE, 'latencyResult', where=query, result_key='experiment_id')

			for experiment_id, experimentHost in experiments_dict.iteritems():
				# Checks if the actual experiment has been calculated (to not send duplicate results)
				print '------------------------------------------------------------------------------------------'
				print ">>> Id del experimento: ", experimentHost['experiment_id']

				# We obtain the event generated for every component experiment (one by component version)
				query = 'properties["experiment_id"]==\"' + experimentHost['experiment_id'] + '\" and properties["version"]!="host"'
				component_versions_experiments = query_client.get_export(START_DATE, END_DATE, 'latencyMetric', where=query, result_key='version')
				# We iterate over the events related to versions stable, accuracy_defects, latency_defects
				for key, experimentClient in component_versions_experiments.iteritems():
					print "---------------------------------------"
					tag = experimentClient["version"] + " vs host"
					# We check for duplicate in latency results
					result_id = experimentClient["experiment_id"] + tag
					if latency_records == None:
						# We calculate the differences and send it back to Mixpanel (component - host)
						latency = experimentClient["requestDuration"] - experimentHost["requestDuration"]
						sendResults(component, experimentHost["experiment_id"], experimentClient['experiment_timestamp'],tag,latency,result_id)
					else:
						if not result_id in latency_records:
            	# We calculate the differences and send it back to Mixpanel
							latency = experimentClient["requestDuration"] - experimentHost["requestDuration"]
							print "Tiempo de latencia del cliente ", experimentClient["requestDuration"]
							print "Tiempo de latencia del host ", experimentHost["requestDuration"]
							sendResults(component, experimentHost["experiment_id"], experimentClient['experiment_timestamp'],tag,latency,result_id)
						else:
							print ">>> El experimento " + experimentClient["experiment_id"] + " con la comparacion " + tag + " ya se ha calculado previamente, por lo que no volvemos a enviar los calculos"
	else:
		print "Wrong parameter"
		# {}: Obligatorio, []: opcional
		print "Usage: collectLatencyRecords.py {facebook-wall|instagram-timeline|github-events|googleplus-timeline|twitter-timeline | pinterest-timeline}"
def main():
	# Instantiates the Query Client
	query_client = MixpanelQueryClient('862a8448704d584ce149704707a0e4e7', '59bf255504e02918c9dc83eb7640144c')
	
	componentNames = ["instagram-timeline", "facebook-wall", "github-events", "googleplus-timeline", "twitter-timeline"]

	if len(sys.argv) == 2 and sys.argv[1] in componentNames:
		component = sys.argv[1]
		print " ### COMPONENTE ", component, "  ###"
		if component == 'googleplus-timeline':
			# Obtain data from mixpanel
			# First, we obtain data generated from host versions. 
			# The method will return a dict, where the field experiment_id will be the key
			# Then we'll obtain the events generated from the components
			query = 'properties["component"]==\"' + component + '\" and properties["version"]=="host"'
			# It returns a dict with all the experiments done today, sorted by event_id (concatenation of experiment_id and request to the API)
			experiments_events_dict = query_client.get_export(START_DATE,END_DATE, 'latencyMetric', where=query, result_key='event_id')

			# We obtain the events related to the results of the latency metric calculated (we'll check for duplicates later)
			query = 'properties["component"]==\"' + component + '\"'
			latency_records = query_client.get_export(START_STUDY_DATE,END_DATE, 'latencyResult', where=query, result_key='result_id')

			# We iterate over the experiments results (obtained from host version), and obtain each group of events related to a specific API request
			for event_id,eventHost in experiments_events_dict.iteritems():
				request = eventHost["request"]
				# We obtain the group of events related to an especific request to the API, as part of one specific experiment
				query = 'properties["component"]==\"' + component + '\" and properties["version"]!="host" and properties["request"]==\"' + request + '\"'
				event_request_dict = query_client.get_export(START_DATE,END_DATE, 'latencyMetric', where=query, result_key='version')
				# We iterate over the results, a dict that contains an event for each client version (stable, accuracy_defects, latency_defects)
				# For each experiment result obtained in host (a certain request to the G+ API), we obtain the results in the different versions
				for event_version, eventClient in event_request_dict.iteritems():
					print "----------------------------------"
					tag = eventClient["version"] + " vs host"
					# We check for duplicate in latency results
					result_id = eventClient["event_id"] + tag
					if not result_id in latency_records:
						# We calculate the differences and send it back to Mixpanel
						latency = eventClient["requestDuration"] - eventHost["requestDuration"]
						sendResults(component, eventHost["experiment_id"], eventClient['experiment_timestamp'], tag, latency, result_id)
					else:
						print ">>> El experimento " + eventClient["experiment_id"] + " con peticion " + eventClient["request"] + " con la comparacion " + tag + " ya se ha calculado previamente, por lo que no volvemos a enviar los calculos"

		else:
			# Obtain data from mixpanel
			# First, we obtain data generated from host versions. 
			# The method will return a dict, where the field experiment_id will be the key
			# Then we'll obtain the events generated from the components
			query = 'properties["component"]==\"' + component + '\" and properties["version"]=="host"'
			experiments_dict = query_client.get_export(START_DATE,END_DATE, 'latencyMetric', where=query, result_key='experiment_id')
			
			# We obtain the calculated metrics on the same range of time data to check if there is any latency records
			#(and to check later for duplicates) 
			query = 'properties["component"]==\"' + component + '\"'
			latency_records = query_client.get_export(START_STUDY_DATE,END_DATE, 'latencyResult', where=query, result_key='result_id')
			
			for experiment_id, experimentHost in experiments_dict.iteritems():
				# Checks if the actual experiment has been calculated (to not send duplicate results)
				print '------------------------------------------------------------------------------------------'
				print ">>> Id del experimento: ", experimentHost['experiment_id']
				# print experimentHost
				# We obtain the event generated for every component experiment (one by component version) 
				query = 'properties["experiment_id"]==\"' + experimentHost['experiment_id'] + '\" and properties["version"]!="host"'
				component_versions_experiments = query_client.get_export(START_DATE, END_DATE, 'latencyMetric', where=query, result_key='version')
				# We iterate over the events related to versions stable, accuracy_defects, latency_defects 
				for key, experimentClient in component_versions_experiments.iteritems():
					print "---------------------------------------"
					tag = experimentClient["version"] + " vs host"
					# We check for duplicate in latency results
					result_id = experimentClient["experiment_id"] + tag
					if not result_id in latency_records:
						# We calculate the differences and send it back to Mixpanel
						latency = experimentClient["requestDuration"] - experimentHost["requestDuration"]
						sendResults(component, experimentHost["experiment_id"], experimentClient['experiment_timestamp'],tag,latency,result_id)
					else:
						print ">>> El experimento " + experimentClient["experiment_id"] + " con la comparacion " + tag + " ya se ha calculado previamente, por lo que no volvemos a enviar los calculos"
	else:
		print "Wrong parameter"
		# {}: Obligatorio, []: opcional
		print "Usage: collectLatencyRecords.py {facebook-wall|instagram-timeline|github-events|googleplus-timeline|twitter-timeline}"
#    See the License for the specific language governing permissions and
#    limitations under the License.

###############################################################################
#   This script get the results stored in Mixpanel and saves them in a file   #
###############################################################################

# First, we made the necessary imports to run the script
import json, csv, time
import mixpanel
from mixpanel_client import MixpanelQueryClient
from mixpanel import Mixpanel

# We need the tokens for Mixpanel projects to get the results
mp_comp = Mixpanel("a31e7a032cce99482d8b407d768f9c04")
query_client = MixpanelQueryClient("3b1ffdd0d5ad8637f954b3a3febaf3f3", "6b789a89178408fa8f0b51e6b2cd93e9")

#Boundary dates for retrieving data
START_DATE = "2017-04-04"
END_DATE = time.strftime("%Y-%m-%d")

# Query to retrieve the results
resp = query_client.get_export(START_DATE, END_DATE, result_key='component')

# Go through the response to print the values
for key in resp.keys():
	print "#########################################################"
	print "Componente: " + resp[key]["component"]
	print "Valor de metrica: " + str(resp[key]["complexity"])
	# print "Id de ejecucion: " + resp[key]["Time"]
	print "#########################################################"
示例#6
0
#    limitations under the License.

###############################################################################
#   This script get the results stored in Mixpanel and saves them in a file   #
###############################################################################

# First, we made the necessary imports to run the script
import json, csv, time
import mixpanel
from mixpanel_client import MixpanelQueryClient
from mixpanel import Mixpanel

# We need the tokens for Mixpanel projects to get the results
mp_latency = Mixpanel("53da31965c3d047fa72de756aae43db1")  # events sender
query_client = MixpanelQueryClient(
    '582d4b303bf22dd746b5bb1b9acbff63',
    '8b2d351133ac2a5d4df0700afc595fb6')  # query client

# Initial and final date
START_DATE = "2017-04-04"
END_DATE = time.strftime("%Y-%m-%d")

# Query to get data of the all Results events
resp = query_client.get_export(START_DATE,
                               END_DATE,
                               'latencyResult',
                               result_key='result_id')

# Resp is a dict, access to fields
for key in resp.keys():
    # Time to show the information stored
#    See the License for the specific language governing permissions and
#    limitations under the License.

###############################################################################
#   This script get the results stored in Mixpanel and saves them in a file   #
###############################################################################

# First, we made the necessary imports to run the script
import json, csv, time
import mixpanel
from mixpanel_client import MixpanelQueryClient
from mixpanel import Mixpanel

# We need the tokens for Mixpanel projects to get the results
mp_structural = Mixpanel("ec0790cae6fb383f1cf7cab42a72c803")
query_client = MixpanelQueryClient("18b5a87adbd0110fe0ac350b1beaea49",
                                   "fbd54d7328b3229372997d05d24c36be")

# Boundary dates for retrieving data
START_DATE = "2017-04-04"
END_DATE = time.strftime("%Y-%m-%d")

# Query to get data from Mixpanel
resp = query_client.get_export(START_DATE,
                               END_DATE,
                               result_key="experiment_id")

# Access to fields of the data
for key in resp.keys():
    print "#########################################################"
    print "Component: " + resp[key]["file_name"]
    print "Valor de metrica: " + str(resp[key]["unique_imports"])
示例#8
0
# -*- coding: utf-8 -*-

import urllib2
import sys
import httplib
import urllib
import json
import ssl
import webbrowser
import mixpanel
from mixpanel_client import MixpanelQueryClient
from mixpanel import Mixpanel
import time
mp = Mixpanel("53da31965c3d047fa72de756aae43db1")
# Instantiates the Query Client
query_client = MixpanelQueryClient('582d4b303bf22dd746b5bb1b9acbff63',
                                   '8b2d351133ac2a5d4df0700afc595fb6')


def replicate_googleplus_requests(access_token, experiment_id,
                                  experiment_list):
    google_requests = {}
    # Endpoint where it is deployed the different versions of twitter-timeline (with the script tracker that sends events to Mixpanel!)
    # remote_base_url = "TWITTER_ENDPOINT"
    for key, experiment in experiment_list.iteritems():
        google_url = experiment['request']
        print ">>> Endpoint: " + google_url
        if experiment['requestCount'] >= 2:
            options_requestTime = 0
            # Si replicamos un experimento cliente en el que se han realizado dos llamadas,
            # haremos primero una petición de tipo OPTIONS y luego una de tipo GET
            # if experiment['requestCount'] == 2:
#    limitations under the License.

###############################################################################
#   This script get the results stored in Mixpanel and saves them in a file   #
###############################################################################

# First, we made the necessary imports to run the script
import json, csv, time
import mixpanel
from mixpanel_client import MixpanelQueryClient
from mixpanel import Mixpanel

# We need the tokens for Mixpanel projects to get the results
mp_maintenance = Mixpanel("c693798b11075795d9e72c784b2d0864")  # events sender
query_client = MixpanelQueryClient(
    "eb4d6565391f79168f8b0482528d5eb1",
    "354211d103b349b2d4c0b138afe25371")  # query client

# Boundary dates for retrieving data of maintenance
START_DATE = "2017-04-04"
END_DATE = time.strftime("%Y-%m-%d")

# Query for retrieving the results
resp = query_client.get_export(START_DATE, END_DATE, result_key='component')

# Resp is a dict.
for key in resp.keys():
    # Time to print the important info about the metric
    print "#########################################################"
    print "Componente: " + resp[key]["component"]
    print "Valor de metrica: " + str(resp[key]["maintainability"])