-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: (qe) Telemetry capturing for PDP/Data proxy #3618
Conversation
c144b46
to
4b6c971
Compare
5fc71ed
to
5b4baea
Compare
5b4baea
to
1da36a3
Compare
fffa84e
to
6970951
Compare
4351a6d
to
ff36a73
Compare
ca0e1b0
to
d4977fb
Compare
ff36a73
to
9a3c4f5
Compare
d4977fb
to
dbd7ac1
Compare
9a3c4f5
to
e8d49a5
Compare
d393ef3
to
7f149a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With all the context and future plans we discussed, let's merge this.
80442d5 fixed the problem with
{
"id": "cldensyuh0002rb9nzo10w4iy",
"extensions": {
"logs": [
{
"span_id": "563b074839c5c57e",
"level": "query",
"timestamp": [
1674832125,
565891000
],
"attributes": {
"params": "[]",
"query": "SELECT 1",
"duration_ms": "12"
}
},
{
"span_id": "3b3817ccec15d3e9",
"level": "query",
"timestamp": [
1674832125,
572383000
],
"attributes": {
"query": "BEGIN",
"duration_ms": "4",
"params": "[]"
}
}
],
"traces": [
{
"trace_id": "73797568303030327a6f313077346979",
"span_id": "563b074839c5c57e",
"parent_span_id": "fc6e12b498c57dce",
"name": "prisma:engine:db_query",
"start_time": [
1674832125,
553089000
],
"end_time": [
1674832125,
566096000
],
"attributes": {
"db.statement": "SELECT 1"
}
},
{
"trace_id": "73797568303030327a6f313077346979",
"span_id": "fc6e12b498c57dce",
"parent_span_id": "6925d3c29b00efb1",
"name": "prisma:engine:connection",
"start_time": [
1674832125,
552560000
],
"end_time": [
1674832125,
567526000
],
"attributes": {
"db.type": "postgres"
}
},
{
"trace_id": "73797568303030327a6f313077346979",
"span_id": "3b3817ccec15d3e9",
"parent_span_id": "6925d3c29b00efb1",
"name": "prisma:engine:db_query",
"start_time": [
1674832125,
567792000
],
"end_time": [
1674832125,
572568000
],
"attributes": {
"db.statement": "BEGIN"
}
}
]
}
} |
d9e998f
to
74afcd5
Compare
c56eaca
to
8b17658
Compare
And move them to the telemetry package as an extension trait
8b17658
to
3aa0d7b
Compare
Extracted from #3505 and to be released after the preparatory refactoring in #3617
Tracked in https://github.com/prisma/client-planning/issues/158
Sibling to prisma/prisma#16748
Closes https://github.com/prisma/client-planning/issues/138
Closes https://github.com/prisma/client-planning/issues/144
Closes https://github.com/prisma/client-planning/issues/145
Implements traces and log capturing in concordance with the (private link) contract specification
The technical design is best explained throw the interaction diagram below:
In the diagram, you will see objects whose lifetime is static. The boxes for those have a double
width margin. These are:
server
itselfTRACER
, which handleslog!
andspan!
and uses the globalPROCESSOR
toprocess the data constituting a trace
Span
s and logEvent
sPROCESSOR
, which manages theStorage
set of data structures, holding logs,traces (and capture settings) per request.
Then, through the request lifecycle, different objects are created and dropped:
Settings
] object is built, thisobject determines, for the request, how logging and tracing are going to be captured: if only
traces, logs, or both, and which log levels are going to be captured.
Capturer
is created; a capturer is nothing but an exporterwrapped to start capturing / fetch the captures for this particular request.
Then the capturing process works in this way:
Capture
object [2], which is configured with the settingsdenoted by the
X-capture-telemetry
Capturer
to start capturing all the logs and traces occurring onthe request [3] (denoted by a
trace_id
) Thetrace_id
is either carried on thetraceparent
header or implicitly created on the first span of the request. To start capturing implies
creating for the
trace_id
in two different data structures:logs
andtraces
; and storingthe settings for selecting the Spans and Event to capture [4].
TRACER
, and get hydrated in thePROCESSOR
[7],which writes them in the shard corresponding to the current
trace_id
, into thelogs
andtraces
storage [8]. The settings previously stored under thetrace_id
key, are used to pick which events and spans are going to be captured based on their level.
PrismaResponse
to theserver [9].
PROCESSOR
to fetch the captures [10]Storage
[11]. At that time, althoughthat's not represented in the diagram, the captures are deleted from the storage, thus
freeing any memory used for capturing during the request
logs
andtraces
extensions in thePrismaResponse
[12],it serializes the extended response in json format and returns it as an HTTP Response
blob [13].