(ws) cobra to sentry - created events with sentry tags based on tags present in the cobra messages
This commit is contained in:
		@@ -1,6 +1,10 @@
 | 
				
			|||||||
# Changelog
 | 
					# Changelog
 | 
				
			||||||
All notable changes to this project will be documented in this file.
 | 
					All notable changes to this project will be documented in this file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## [7.5.2] - 2019-12-11
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(ws) cobra to sentry - created events with sentry tags based on tags present in the cobra messages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [7.5.1] - 2019-12-06
 | 
					## [7.5.1] - 2019-12-06
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(mac) convert SSL errors to utf8
 | 
					(mac) convert SSL errors to utf8
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,7 @@
 | 
				
			|||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
#include <sstream>
 | 
					#include <sstream>
 | 
				
			||||||
#include <ixwebsocket/IXWebSocketHttpHeaders.h>
 | 
					#include <ixwebsocket/IXWebSocketHttpHeaders.h>
 | 
				
			||||||
 | 
					#include <ixwebsocket/IXWebSocketVersion.h>
 | 
				
			||||||
#include <ixcore/utils/IXCoreLogger.h>
 | 
					#include <ixcore/utils/IXCoreLogger.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -120,26 +121,6 @@ namespace ix
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        Json::Value payload;
 | 
					        Json::Value payload;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        payload["platform"] = "python";
 | 
					 | 
				
			||||||
        payload["sdk"]["name"] = "ws";
 | 
					 | 
				
			||||||
        payload["sdk"]["version"] = "1.0.0";
 | 
					 | 
				
			||||||
        payload["timestamp"] = SentryClient::getIso8601();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        bool isNoisyTypes = msg["id"].asString() == "game_noisytypes_id";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        std::string stackTraceFieldName = isNoisyTypes ? "traceback" : "stack";
 | 
					 | 
				
			||||||
        std::string stack(msg["data"][stackTraceFieldName].asString());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Json::Value exception;
 | 
					 | 
				
			||||||
        exception["stacktrace"]["frames"] = parseLuaStackTrace(stack);
 | 
					 | 
				
			||||||
        exception["value"] = isNoisyTypes ? parseExceptionName(stack) : msg["data"]["message"];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        payload["exception"].append(exception);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Json::Value extra;
 | 
					 | 
				
			||||||
        extra["cobra_event"] = msg;
 | 
					 | 
				
			||||||
        extra["cobra_event"] = msg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
        // "tags": [
 | 
					        // "tags": [
 | 
				
			||||||
        //   [
 | 
					        //   [
 | 
				
			||||||
@@ -148,8 +129,62 @@ namespace ix
 | 
				
			|||||||
        //   ],
 | 
					        //   ],
 | 
				
			||||||
        //  ]
 | 
					        //  ]
 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
        Json::Value tags;
 | 
					        Json::Value tags(Json::arrayValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        payload["platform"] = "python";
 | 
				
			||||||
 | 
					        payload["sdk"]["name"] = "ws";
 | 
				
			||||||
 | 
					        payload["sdk"]["version"] = IX_WEBSOCKET_VERSION;
 | 
				
			||||||
 | 
					        payload["timestamp"] = SentryClient::getIso8601();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool isNoisyTypes = msg["id"].asString() == "game_noisytypes_id";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::string stackTraceFieldName = isNoisyTypes ? "traceback" : "stack";
 | 
				
			||||||
 | 
					        std::string stack;
 | 
				
			||||||
 | 
					        std::string message;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (isNoisyTypes)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            stack = msg["data"][stackTraceFieldName].asString();
 | 
				
			||||||
 | 
					            message = parseExceptionName(stack);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else // logging
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (msg["data"].isMember("info"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                stack = msg["data"]["info"][stackTraceFieldName].asString();
 | 
				
			||||||
 | 
					                message = msg["data"]["info"]["message"].asString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (msg["data"].isMember("tags"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    auto members = msg["data"]["tags"].getMemberNames();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    for (auto member : members)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Json::Value tag;
 | 
				
			||||||
 | 
					                        tag.append(member);
 | 
				
			||||||
 | 
					                        tag.append(msg["data"]["tags"][member]);
 | 
				
			||||||
 | 
					                        tags.append(tag);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                stack = msg["data"][stackTraceFieldName].asString();
 | 
				
			||||||
 | 
					                message = msg["data"]["message"].asString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Json::Value exception;
 | 
				
			||||||
 | 
					        exception["stacktrace"]["frames"] = parseLuaStackTrace(stack);
 | 
				
			||||||
 | 
					        exception["value"] = message;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        payload["exception"].append(exception);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Json::Value extra;
 | 
				
			||||||
 | 
					        extra["cobra_event"] = msg;
 | 
				
			||||||
 | 
					        extra["cobra_event"] = msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Builtin tags
 | 
				
			||||||
        Json::Value gameTag;
 | 
					        Json::Value gameTag;
 | 
				
			||||||
        gameTag.append("game");
 | 
					        gameTag.append("game");
 | 
				
			||||||
        gameTag.append(msg["device"]["game"]);
 | 
					        gameTag.append(msg["device"]["game"]);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,4 +6,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define IX_WEBSOCKET_VERSION "7.5.1"
 | 
					#define IX_WEBSOCKET_VERSION "7.5.2"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								makefile
									
									
									
									
									
								
							@@ -40,7 +40,7 @@ xcode_openssl:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
.PHONY: docker
 | 
					.PHONY: docker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NAME   := bsergean/ws
 | 
					NAME   := ${DOCKER_REPO}/ws
 | 
				
			||||||
TAG    := $(shell sh tools/extract_version.sh)
 | 
					TAG    := $(shell sh tools/extract_version.sh)
 | 
				
			||||||
IMG    := ${NAME}:${TAG}
 | 
					IMG    := ${NAME}:${TAG}
 | 
				
			||||||
LATEST := ${NAME}:latest
 | 
					LATEST := ${NAME}:latest
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,6 +84,12 @@ namespace ix
 | 
				
			|||||||
                auto ret = sentryClient.send(msg, verbose);
 | 
					                auto ret = sentryClient.send(msg, verbose);
 | 
				
			||||||
                HttpResponsePtr response = ret.first;
 | 
					                HttpResponsePtr response = ret.first;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (!response)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    spdlog::warn("Null HTTP Response");
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (verbose)
 | 
					                if (verbose)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    for (auto it : response->headers)
 | 
					                    for (auto it : response->headers)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user