{"_id":"56a0bda13697d80d002ac608","__v":21,"project":"54774d9af3736008009e9e0e","parentDoc":null,"category":{"_id":"56a0bd9f3697d80d002ac5e9","__v":3,"project":"54774d9af3736008009e9e0e","version":"56a0bd9e3697d80d002ac5e7","pages":["56a0bda13697d80d002ac5ff","56a0bda13697d80d002ac600","56a0bda13697d80d002ac601","56a0bda13697d80d002ac602","56a0bda13697d80d002ac603","56a0bda13697d80d002ac604","56a0bda13697d80d002ac605","56a0bda13697d80d002ac606","56a0bda13697d80d002ac607","56a0bda13697d80d002ac608","56a0bda13697d80d002ac609","56a0bda13697d80d002ac60a","56a0bda13697d80d002ac60b","56a0bda13697d80d002ac60c","56a0bda13697d80d002ac60d","56a0bda13697d80d002ac60e","56a0bda13697d80d002ac60f","56a0bda13697d80d002ac610","56a0bda13697d80d002ac611","56a0bda13697d80d002ac612","56a0bda13697d80d002ac613","56a0bda13697d80d002ac614","56a5d7f7d222d20d00500d91","56a8c90fc48ee00d0092e1d1"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-05T14:34:09.364Z","from_sync":false,"order":17,"slug":"developer-manual","title":"Advanced Topics"},"user":"54e341c4ce1b4017000dffef","version":{"_id":"56a0bd9e3697d80d002ac5e7","project":"54774d9af3736008009e9e0e","__v":20,"createdAt":"2016-01-21T11:14:38.131Z","releaseDate":"2016-01-21T11:14:38.131Z","categories":["56a0bd9f3697d80d002ac5e8","56a0bd9f3697d80d002ac5e9","56a0bd9f3697d80d002ac5ea","56a0bd9f3697d80d002ac5eb","56b098a43a5b810d00745e3f","56b098da8f7a4f0d0029dd10","56d5a8ecf612b80b00fb69cd","570989853ab43c0e0072b2d6","571006aa10300c0e007f6133","5735a52431a73b1700887ca0","5744b0529e045c0e00b7a7a2","5744b1d0b56d431700d8a4fb","5744b1fb55d65a0e00b436e1","5744b218f9c7411700ce560e","5744b220f9c7411700ce560f","5744b2259e045c0e00b7a7a7","5744b22cf8b79f0e00de6a2d","5744b23155d65a0e00b436e4","5744b242c758290e00fbc235","5744b2569e045c0e00b7a7a8","5756a3f2bb92962900dafe3d","57ee23e81e42900e0014a42f","581c822c98676e0f00d240ef"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Sockets","version_clean":"1.1.0","version":"1.1"},"updates":["575832c58abb520e00ea7c22","575a8d71ef7c930e00832a54"],"next":{"pages":[],"description":""},"createdAt":"2015-03-13T07:38:42.245Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"## Chapter Contents:\n1. [Overview](#overview)\n2. [Scripts, Schedule and Trigger Sockets Traces](#script-schedule-and-trigger-sockets-traces)\n3. [Script Endpoint Traces](#script-endpoint-traces)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Overview\"\n}\n[/block]\nWhat Traces are essentially, is a history of Snippet Script execution. They log information about the Script execution status, its execution duration, time, etc. Since Scripts can be run directly, through Schedule, Trigger Sockets and Script Endpoints, the Traces are grouped based on a method of execution. Script Endpoint Traces are described in a separate section of this chapter because their properties differ from Script, Trigger and Schedule Sockets Traces.\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Traces aren't meant to be persistent. Syncano will store a **100** of latest Script runs . If you want to store Script results, the best way is to create Data Objects and store traces in them. It can be done easily because python and nodejs runtimes have the `syncano` library inside and you can just import and start using it straight away.\",\n  \"title\": \"Important!\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Script, Schedule and Trigger Sockets Traces\"\n}\n[/block]\nAn example of how Syncano represents Snippet Script (as well as Schedules and Triggers) Traces in the API:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"id\\\": 184, \\n    \\\"status\\\": \\\"success\\\", \\n    \\\"executed_at\\\": \\\"2015-03-18T08:52:39.667359Z\\\", \\n    \\\"duration\\\": 233, \\n    \\\"result\\\": \\\"some_result\\\", \\n    \\\"links\\\": {\\n        \\\"self\\\": \\\"/v1.1/instances/<instance>/snippets/scripts/666/traces/777/\\\"\\n    }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nYou can also find same information in the [Dashboard](https://dashboard.syncano.io). Go to the Scripts view, select the Script you want to check Traces of, and switch to the Traces view.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/QydTbehpSqSPjtqYxVSh_Traces_01.png\",\n        \"Traces_01.png\",\n        \"1439\",\n        \"728\",\n        \"#254372\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nBy default you see only execution status, Trace ID, duration time and execution date. If you want to see Snippet Script result as well, click on selected Trace - it will expand, showing more details.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/MQ9HfPeTQSoNJ3zLzoEX_Traces_02.png\",\n        \"Traces_02.png\",\n        \"1439\",\n        \"731\",\n        \"#4a4942\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThis is the information that Traces hold:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`status`\",\n    \"1-0\": \"`executed_at`\",\n    \"2-0\": \"`duration`\",\n    \"3-0\": \"`result`\",\n    \"0-1\": \"Status of the connected Snippet Script. This field can have `success`, `processing`, `failure`, `timeout`, `pending` or `blocked` values\",\n    \"1-1\": \"Time when connected Script was executed (ISO format)\",\n    \"2-1\": \"Duration of Snippet Script run (in ms)\",\n    \"3-1\": \"Snippet Script result represented as a object which contains two keys:\\n- `stderr` with error message if status is failure\\n- `stdout` with answer value if status is success\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\nYou can easily see traces in the Dashboard as well\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Script Endpoint Traces\"\n}\n[/block]\nAs mentioned earlier, Script Endpoint Traces are a bit different from Traces found in other parts of Syncano Platform. They have two additional `meta` and `args` properties. Let's see how a Script Endpoint Trace looks like:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"id\\\": 2039, \\n    \\\"status\\\": \\\"success\\\", \\n    \\\"executed_at\\\": \\\"2015-04-28T13:13:23.970574Z\\\", \\n    \\\"duration\\\": 257, \\n    \\\"result\\\": \\\"ello\\\", \\n    \\\"meta\\\": {\\n        \\\"HTTP_ACCEPT\\\": \\\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\\\", \\n        \\\"HTTP_USER_AGENT\\\": \\\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36\\\", \\n        \\\"HTTP_DNT\\\": \\\"1\\\", \\n        \\\"REMOTE_ADDR\\\": \\\"91.202.125.2\\\", \\n        \\\"HTTP_ACCEPT_LANGUAGE\\\": \\\"en-US,en;q=0.8\\\", \\n        \\\"REQUEST_METHOD\\\": \\\"GET\\\", \\n        \\\"HTTP_HOST\\\": \\\"api.syncano.rocks\\\", \\n        \\\"PATH_INFO\\\": \\\"/v1.1/instances/<instance>/snippets/scripts/run/\\\", \\n        \\\"HTTP_CACHE_CONTROL\\\": \\\"max-age=0\\\", \\n        \\\"HTTP_ACCEPT_ENCODING\\\": \\\"gzip, deflate, sdch\\\"\\n    }, \\n    \\\"args\\\": {}, \\n    \\\"links\\\": {\\n        \\\"self\\\": \\\"/v1.1/instances/<instance>/snippets/scripts/<script_id>/traces/<trace_id>/\\\"\\n    }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nHere are the Script Endpoint Trace properties:\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`meta`\",\n    \"2-1\": \"Status of the connected Script. This field can have success, failure or timeout values.\",\n    \"2-0\": \"`status`\",\n    \"3-0\": \"`executed_at`\",\n    \"3-1\": \"Time when connected Script was executed (ISO format)\",\n    \"4-0\": \"`duration`\",\n    \"4-1\": \"Duration of Script run (in ms)\",\n    \"5-0\": \"`result`\",\n    \"5-1\": \"Snippet Script result represented as a object which contains two keys:\\n- `stderr` with error message if status is failure\\n- `stdout` with answer value if status is success\",\n    \"h-0\": \"Property\",\n    \"h-1\": \"Description\",\n    \"1-0\": \"`args`\",\n    \"0-1\": \"This field contains HTTP Request Header information from a client that made a HTTP request using this specific Script Endpoint.\",\n    \"1-1\": \"Payload that was passed to the Script.\"\n  },\n  \"cols\": 2,\n  \"rows\": 6\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Learn More\",\n  \"body\": \"For example API calls with traces - visit the following pages:\\n\\n**Snippet Scripts** - [Trace List](http://docs.syncano.com/v0.1.1/docs/script-list-traces), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/script-traces-details)\\n**Schedule Sockets** - [Trace List](http://docs.syncano.com/v0.1.1/docs/schedules-traces-list), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/schedules-traces-details)\\n**Trigger Sockets** - [Trace List](http://docs.syncano.com/v0.1.1/docs/triggers-traces-list), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/triggers-traces-details)\\n**Script Endpoints** - [Trace List](http://docs.syncano.com/v0.1.1/docs/endpoints-scripts-traces-list), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/endpoints-scripts-traces-details)\"\n}\n[/block]\nNext chapter is [Request Batching](doc:request-batching) - learn how to send more than 1 request at a time to Syncano.","excerpt":"How do you know that Snippet Script was executed? In this Chapter you'll learn what Traces are and how to get Traces for Scripts, Schedule, Triggers and Script Endpoints runs.","slug":"traces","type":"basic","title":"Traces"}

Traces

How do you know that Snippet Script was executed? In this Chapter you'll learn what Traces are and how to get Traces for Scripts, Schedule, Triggers and Script Endpoints runs.

## Chapter Contents: 1. [Overview](#overview) 2. [Scripts, Schedule and Trigger Sockets Traces](#script-schedule-and-trigger-sockets-traces) 3. [Script Endpoint Traces](#script-endpoint-traces) [block:api-header] { "type": "basic", "title": "Overview" } [/block] What Traces are essentially, is a history of Snippet Script execution. They log information about the Script execution status, its execution duration, time, etc. Since Scripts can be run directly, through Schedule, Trigger Sockets and Script Endpoints, the Traces are grouped based on a method of execution. Script Endpoint Traces are described in a separate section of this chapter because their properties differ from Script, Trigger and Schedule Sockets Traces. [block:callout] { "type": "warning", "body": "Traces aren't meant to be persistent. Syncano will store a **100** of latest Script runs . If you want to store Script results, the best way is to create Data Objects and store traces in them. It can be done easily because python and nodejs runtimes have the `syncano` library inside and you can just import and start using it straight away.", "title": "Important!" } [/block] [block:api-header] { "type": "basic", "title": "Script, Schedule and Trigger Sockets Traces" } [/block] An example of how Syncano represents Snippet Script (as well as Schedules and Triggers) Traces in the API: [block:code] { "codes": [ { "code": "{\n \"id\": 184, \n \"status\": \"success\", \n \"executed_at\": \"2015-03-18T08:52:39.667359Z\", \n \"duration\": 233, \n \"result\": \"some_result\", \n \"links\": {\n \"self\": \"/v1.1/instances/<instance>/snippets/scripts/666/traces/777/\"\n }\n}", "language": "json" } ] } [/block] You can also find same information in the [Dashboard](https://dashboard.syncano.io). Go to the Scripts view, select the Script you want to check Traces of, and switch to the Traces view. [block:image] { "images": [ { "image": [ "https://files.readme.io/QydTbehpSqSPjtqYxVSh_Traces_01.png", "Traces_01.png", "1439", "728", "#254372", "" ] } ] } [/block] By default you see only execution status, Trace ID, duration time and execution date. If you want to see Snippet Script result as well, click on selected Trace - it will expand, showing more details. [block:image] { "images": [ { "image": [ "https://files.readme.io/MQ9HfPeTQSoNJ3zLzoEX_Traces_02.png", "Traces_02.png", "1439", "731", "#4a4942", "" ] } ] } [/block] This is the information that Traces hold: [block:parameters] { "data": { "h-0": "Property", "h-1": "Description", "0-0": "`status`", "1-0": "`executed_at`", "2-0": "`duration`", "3-0": "`result`", "0-1": "Status of the connected Snippet Script. This field can have `success`, `processing`, `failure`, `timeout`, `pending` or `blocked` values", "1-1": "Time when connected Script was executed (ISO format)", "2-1": "Duration of Snippet Script run (in ms)", "3-1": "Snippet Script result represented as a object which contains two keys:\n- `stderr` with error message if status is failure\n- `stdout` with answer value if status is success" }, "cols": 2, "rows": 4 } [/block] You can easily see traces in the Dashboard as well [block:api-header] { "type": "basic", "title": "Script Endpoint Traces" } [/block] As mentioned earlier, Script Endpoint Traces are a bit different from Traces found in other parts of Syncano Platform. They have two additional `meta` and `args` properties. Let's see how a Script Endpoint Trace looks like: [block:code] { "codes": [ { "code": "{\n \"id\": 2039, \n \"status\": \"success\", \n \"executed_at\": \"2015-04-28T13:13:23.970574Z\", \n \"duration\": 257, \n \"result\": \"ello\", \n \"meta\": {\n \"HTTP_ACCEPT\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\", \n \"HTTP_USER_AGENT\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36\", \n \"HTTP_DNT\": \"1\", \n \"REMOTE_ADDR\": \"91.202.125.2\", \n \"HTTP_ACCEPT_LANGUAGE\": \"en-US,en;q=0.8\", \n \"REQUEST_METHOD\": \"GET\", \n \"HTTP_HOST\": \"api.syncano.rocks\", \n \"PATH_INFO\": \"/v1.1/instances/<instance>/snippets/scripts/run/\", \n \"HTTP_CACHE_CONTROL\": \"max-age=0\", \n \"HTTP_ACCEPT_ENCODING\": \"gzip, deflate, sdch\"\n }, \n \"args\": {}, \n \"links\": {\n \"self\": \"/v1.1/instances/<instance>/snippets/scripts/<script_id>/traces/<trace_id>/\"\n }\n}", "language": "json" } ] } [/block] Here are the Script Endpoint Trace properties: [block:parameters] { "data": { "0-0": "`meta`", "2-1": "Status of the connected Script. This field can have success, failure or timeout values.", "2-0": "`status`", "3-0": "`executed_at`", "3-1": "Time when connected Script was executed (ISO format)", "4-0": "`duration`", "4-1": "Duration of Script run (in ms)", "5-0": "`result`", "5-1": "Snippet Script result represented as a object which contains two keys:\n- `stderr` with error message if status is failure\n- `stdout` with answer value if status is success", "h-0": "Property", "h-1": "Description", "1-0": "`args`", "0-1": "This field contains HTTP Request Header information from a client that made a HTTP request using this specific Script Endpoint.", "1-1": "Payload that was passed to the Script." }, "cols": 2, "rows": 6 } [/block] [block:callout] { "type": "info", "title": "Learn More", "body": "For example API calls with traces - visit the following pages:\n\n**Snippet Scripts** - [Trace List](http://docs.syncano.com/v0.1.1/docs/script-list-traces), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/script-traces-details)\n**Schedule Sockets** - [Trace List](http://docs.syncano.com/v0.1.1/docs/schedules-traces-list), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/schedules-traces-details)\n**Trigger Sockets** - [Trace List](http://docs.syncano.com/v0.1.1/docs/triggers-traces-list), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/triggers-traces-details)\n**Script Endpoints** - [Trace List](http://docs.syncano.com/v0.1.1/docs/endpoints-scripts-traces-list), [Trace Detail](http://docs.syncano.com/v0.1.1/docs/endpoints-scripts-traces-details)" } [/block] Next chapter is [Request Batching](doc:request-batching) - learn how to send more than 1 request at a time to Syncano.