Skip to content

Commit cca304f

Browse files
committedDec 12, 2019
(ws) cobra to sentry - created events with sentry tags based on tags present in the cobra messages
1 parent 432624d commit cca304f

File tree

5 files changed

+60
-15
lines changed

5 files changed

+60
-15
lines changed
 

‎docs/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [7.5.2] - 2019-12-11
5+
6+
(ws) cobra to sentry - created events with sentry tags based on tags present in the cobra messages
7+
48
## [7.5.1] - 2019-12-06
59

610
(mac) convert SSL errors to utf8

‎ixsentry/ixsentry/IXSentryClient.cpp

+48-13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <fstream>
1212
#include <sstream>
1313
#include <ixwebsocket/IXWebSocketHttpHeaders.h>
14+
#include <ixwebsocket/IXWebSocketVersion.h>
1415
#include <ixcore/utils/IXCoreLogger.h>
1516

1617

@@ -120,36 +121,70 @@ namespace ix
120121
{
121122
Json::Value payload;
122123

124+
//
125+
// "tags": [
126+
// [
127+
// "a",
128+
// "b"
129+
// ],
130+
// ]
131+
//
132+
Json::Value tags(Json::arrayValue);
133+
123134
payload["platform"] = "python";
124135
payload["sdk"]["name"] = "ws";
125-
payload["sdk"]["version"] = "1.0.0";
136+
payload["sdk"]["version"] = IX_WEBSOCKET_VERSION;
126137
payload["timestamp"] = SentryClient::getIso8601();
127138

128139
bool isNoisyTypes = msg["id"].asString() == "game_noisytypes_id";
129140

130141
std::string stackTraceFieldName = isNoisyTypes ? "traceback" : "stack";
131-
std::string stack(msg["data"][stackTraceFieldName].asString());
142+
std::string stack;
143+
std::string message;
144+
145+
if (isNoisyTypes)
146+
{
147+
stack = msg["data"][stackTraceFieldName].asString();
148+
message = parseExceptionName(stack);
149+
}
150+
else // logging
151+
{
152+
if (msg["data"].isMember("info"))
153+
{
154+
stack = msg["data"]["info"][stackTraceFieldName].asString();
155+
message = msg["data"]["info"]["message"].asString();
156+
157+
if (msg["data"].isMember("tags"))
158+
{
159+
auto members = msg["data"]["tags"].getMemberNames();
160+
161+
for (auto member : members)
162+
{
163+
Json::Value tag;
164+
tag.append(member);
165+
tag.append(msg["data"]["tags"][member]);
166+
tags.append(tag);
167+
}
168+
}
169+
}
170+
else
171+
{
172+
stack = msg["data"][stackTraceFieldName].asString();
173+
message = msg["data"]["message"].asString();
174+
}
175+
}
132176

133177
Json::Value exception;
134178
exception["stacktrace"]["frames"] = parseLuaStackTrace(stack);
135-
exception["value"] = isNoisyTypes ? parseExceptionName(stack) : msg["data"]["message"];
179+
exception["value"] = message;
136180

137181
payload["exception"].append(exception);
138182

139183
Json::Value extra;
140184
extra["cobra_event"] = msg;
141185
extra["cobra_event"] = msg;
142186

143-
//
144-
// "tags": [
145-
// [
146-
// "a",
147-
// "b"
148-
// ],
149-
// ]
150-
//
151-
Json::Value tags;
152-
187+
// Builtin tags
153188
Json::Value gameTag;
154189
gameTag.append("game");
155190
gameTag.append(msg["device"]["game"]);

‎ixwebsocket/IXWebSocketVersion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
#pragma once
88

9-
#define IX_WEBSOCKET_VERSION "7.5.1"
9+
#define IX_WEBSOCKET_VERSION "7.5.2"

‎makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ xcode_openssl:
4040

4141
.PHONY: docker
4242

43-
NAME := bsergean/ws
43+
NAME := ${DOCKER_REPO}/ws
4444
TAG := $(shell sh tools/extract_version.sh)
4545
IMG := ${NAME}:${TAG}
4646
LATEST := ${NAME}:latest

‎ws/ws_cobra_to_sentry.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ namespace ix
8484
auto ret = sentryClient.send(msg, verbose);
8585
HttpResponsePtr response = ret.first;
8686

87+
if (!response)
88+
{
89+
spdlog::warn("Null HTTP Response");
90+
continue;
91+
}
92+
8793
if (verbose)
8894
{
8995
for (auto it : response->headers)

0 commit comments

Comments
 (0)
Please sign in to comment.