feat: add ops trace (#5483)

Co-authored-by: takatost <takatost@gmail.com>
This commit is contained in:
Joe
2024-06-26 17:33:29 +08:00
committed by GitHub
parent 31a061ebaa
commit 4e2de638af
58 changed files with 3553 additions and 622 deletions

View File

@@ -6,7 +6,7 @@ from typing import Optional
from flask import current_app, request
from flask_login import UserMixin
from sqlalchemy import Float, text
from sqlalchemy import Float, func, text
from core.file.tool_file_parser import ToolFileParser
from core.file.upload_file_parser import UploadFileParser
@@ -73,6 +73,7 @@ class App(db.Model):
is_demo = db.Column(db.Boolean, nullable=False, server_default=db.text('false'))
is_public = db.Column(db.Boolean, nullable=False, server_default=db.text('false'))
is_universal = db.Column(db.Boolean, nullable=False, server_default=db.text('false'))
tracing = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, nullable=False, server_default=db.text('CURRENT_TIMESTAMP(0)'))
updated_at = db.Column(db.DateTime, nullable=False, server_default=db.text('CURRENT_TIMESTAMP(0)'))
@@ -1328,3 +1329,38 @@ class TagBinding(db.Model):
target_id = db.Column(StringUUID, nullable=True)
created_by = db.Column(StringUUID, nullable=False)
created_at = db.Column(db.DateTime, nullable=False, server_default=db.text('CURRENT_TIMESTAMP(0)'))
class TraceAppConfig(db.Model):
__tablename__ = 'trace_app_config'
__table_args__ = (
db.PrimaryKeyConstraint('id', name='tracing_app_config_pkey'),
db.Index('tracing_app_config_app_id_idx', 'app_id'),
)
id = db.Column(StringUUID, server_default=db.text('uuid_generate_v4()'))
app_id = db.Column(StringUUID, nullable=False)
tracing_provider = db.Column(db.String(255), nullable=True)
tracing_config = db.Column(db.JSON, nullable=True)
created_at = db.Column(db.DateTime, nullable=False, server_default=func.now())
updated_at = db.Column(db.DateTime, nullable=False, server_default=func.now(), onupdate=func.now())
is_active = db.Column(db.Boolean, nullable=False, server_default=db.text('true'))
@property
def tracing_config_dict(self):
return self.tracing_config if self.tracing_config else {}
@property
def tracing_config_str(self):
return json.dumps(self.tracing_config_dict)
def to_dict(self):
return {
'id': self.id,
'app_id': self.app_id,
'tracing_provider': self.tracing_provider,
'tracing_config': self.tracing_config_dict,
"is_active": self.is_active,
"created_at": self.created_at.__str__() if self.created_at else None,
'updated_at': self.updated_at.__str__() if self.updated_at else None,
}