(ws) cobra to sentry - created events with sentry tags based on tags present in the cobra messages

This commit is contained in:
Benjamin Sergeant 2019-12-11 17:27:37 -08:00
parent c86fa8ad3b
commit e223f8fac2
5 changed files with 68 additions and 23 deletions

View File

@ -1,6 +1,10 @@
# Changelog
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
(mac) convert SSL errors to utf8

View File

@ -11,6 +11,7 @@
#include <fstream>
#include <sstream>
#include <ixwebsocket/IXWebSocketHttpHeaders.h>
#include <ixwebsocket/IXWebSocketVersion.h>
#include <ixcore/utils/IXCoreLogger.h>
@ -120,26 +121,6 @@ namespace ix
{
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": [
// [
@ -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;
gameTag.append("game");
gameTag.append(msg["device"]["game"]);

View File

@ -6,4 +6,4 @@
#pragma once
#define IX_WEBSOCKET_VERSION "7.5.1"
#define IX_WEBSOCKET_VERSION "7.5.2"

View File

@ -40,7 +40,7 @@ xcode_openssl:
.PHONY: docker
NAME := bsergean/ws
NAME := ${DOCKER_REPO}/ws
TAG := $(shell sh tools/extract_version.sh)
IMG := ${NAME}:${TAG}
LATEST := ${NAME}:latest

View File

@ -84,6 +84,12 @@ namespace ix
auto ret = sentryClient.send(msg, verbose);
HttpResponsePtr response = ret.first;
if (!response)
{
spdlog::warn("Null HTTP Response");
continue;
}
if (verbose)
{
for (auto it : response->headers)