简体   繁体   English

在数据库中存储堆栈跟踪的最佳方法是什么

[英]What is the best way to store stacktrace in database

I'm looking for the best way to store the stacktrace (obtained via Thread.dumpStack()) and exception trace in the database. 我正在寻找存储堆栈跟踪(通过Thread.dumpStack()获得)和数据库中的异常跟踪的最佳方法。

I'm developing an app that does application performance. 我正在开发一个应用程序性能的应用程序。 It traces method calls(with duration), captures errors (that result in exception trace) & generates stack trace for slow executions. 它跟踪方法调用(持续时间),捕获错误(导致异常跟踪)并生成缓慢执行的堆栈跟踪。

The environment is Java + MySQL 5.0 环境是Java + MySQL 5.0

Currently, the trace info of a web request & stack traces are stored in a file(as json) and meta data is stored in the database table. 目前,Web请求和堆栈跟踪的跟踪信息存储在文件中(如json),元数据存储在数据库表中。

For reporting & replication purpose, I'm thinking of storing them in the database. 出于报告和复制的目的,我正在考虑将它们存储在数据库中。 On an average, the size of complete trace info is 40 kb. 平均而言,完整跟踪信息的大小为40 kb。 Is it prudent to store them in the db or keep it in the file system and move to nosql. 将它们存储在数据库中还是保存在文件系统中并转移到nosql是明智的。

Moving to nosql, i can solve the replication but still the reporting will be a tough one. 转到nosql,我可以解决复制,但报告仍然很难。

Why not store the additional information needed for reporting as part of the 'metadata'? 为什么不将报告所需的其他信息存储为“元数据”的一部分? There may not be anything wrong with storing the complete stack trace in a file and storing a reference to that file in the DB depending on the needs of the application. 将完整的堆栈跟踪存储在文件中并根据应用程序的需要在DB中存储对该文件的引用可能没有任何问题。 I would consider what you need to report on and evaluate those elements for inclusion in the DB. 我会考虑您需要报告的内容并评估这些元素以包含在数据库中。 For example, are you reporting on the root cause of the exception? 例如,您是否报告了异常的根本原因? Consider pre-processing the data down to what you need for reporting. 考虑将数据预处理到您需要报告的内容。 If you are already saving the entire stack trace separately, you won't be losing any information should you need to report on something else in the future. 如果您已经单独保存整个堆栈跟踪,那么如果您将来需要报告其他内容,则不会丢失任何信息。

This question was asked a long time ago so I assume you have already made a decision but I would have been hesitant about moving to a nosql architecture without having a clear reason for doing so. 很久以前就问过这个问题,所以我假设你已经做出了一个决定,但是在没有明确理由的情况下,我会犹豫是否转向nosql架构。 Relational databases still have their place in certain scenarios and most of them have an efficient mechanism for storing large amounts of text (eg a stack trace). 关系数据库在某些场景中仍然占有一席之地,并且它们中的大多数都具有用于存储大量文本的有效机制(例如,堆栈跟踪)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM