@xeonr/telemetry 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -2
- package/dist/baggage.d.ts +21 -0
- package/dist/baggage.d.ts.map +1 -0
- package/dist/baggage.js +117 -0
- package/dist/baggage.js.map +1 -0
- package/dist/boot.d.ts +7 -0
- package/dist/boot.d.ts.map +1 -0
- package/dist/boot.js +10 -0
- package/dist/boot.js.map +1 -0
- package/dist/connect.d.ts +63 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +200 -0
- package/dist/connect.js.map +1 -0
- package/dist/fetch.d.ts +19 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +41 -0
- package/dist/fetch.js.map +1 -0
- package/dist/identity.d.ts +79 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +173 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/job.d.ts +38 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +107 -0
- package/dist/job.js.map +1 -0
- package/dist/keys.d.ts +80 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +90 -0
- package/dist/keys.js.map +1 -0
- package/dist/keys.json +127 -0
- package/dist/log.d.ts +43 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +139 -0
- package/dist/log.js.map +1 -0
- package/dist/processor.d.ts +76 -0
- package/dist/processor.d.ts.map +1 -0
- package/dist/processor.js +160 -0
- package/dist/processor.js.map +1 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +34 -0
- package/dist/register.js.map +1 -0
- package/dist/sanitize.d.ts +17 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +52 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/sdk.d.ts +50 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +207 -0
- package/dist/sdk.js.map +1 -0
- package/package.json +97 -3
- package/register.cjs +3 -0
package/dist/keys.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Code generated by scripts/gen-keys.mjs from keys.json. DO NOT EDIT.
|
|
2
|
+
// Vocabulary version 1.
|
|
3
|
+
export const VOCABULARY_VERSION = 1;
|
|
4
|
+
/** Subject is the verified principal's full URN (urn:xeonr:auth:uid:user:88, a service account, a client, an API key's owner or the key itself). Never a bare id. */
|
|
5
|
+
export const KeySubject = "xeonr.subject";
|
|
6
|
+
export const FieldSubject = "subject";
|
|
7
|
+
/** SubjectKind is derived from Subject's URN prefix (SubjectKind func): user, service_account, client, api_key, team; anonymous for an unauthenticated request, system for a job with no caller, unknown for a URN with no recognised prefix. */
|
|
8
|
+
export const KeySubjectKind = "xeonr.subject.kind";
|
|
9
|
+
export const FieldSubjectKind = "subject_kind";
|
|
10
|
+
/** OrgID is the auth organisation id (Principal.OrganisationID). Not Lantern's org.id resource attribute. */
|
|
11
|
+
export const KeyOrgID = "xeonr.org.id";
|
|
12
|
+
export const FieldOrgID = "org_id";
|
|
13
|
+
/** ClientID is the OAuth client the token was issued to. */
|
|
14
|
+
export const KeyClientID = "xeonr.client.id";
|
|
15
|
+
export const FieldClientID = "client_id";
|
|
16
|
+
/** ApplicationID is the auth application the token was minted for. */
|
|
17
|
+
export const KeyApplicationID = "xeonr.application.id";
|
|
18
|
+
export const FieldApplicationID = "application_id";
|
|
19
|
+
/** DelegatorApp is the product acting for the user on an RFC 8693 exchanged token; empty unless delegated. */
|
|
20
|
+
export const KeyDelegatorApp = "xeonr.delegator.app";
|
|
21
|
+
export const FieldDelegatorApp = "delegator_app";
|
|
22
|
+
/** APIKeyID is the API key's URN when a key authenticated the request. */
|
|
23
|
+
export const KeyAPIKeyID = "xeonr.api_key.id";
|
|
24
|
+
export const FieldAPIKeyID = "api_key_id";
|
|
25
|
+
/** AuthMethod is how the caller authenticated: bearer, cookie, api_key, or none. */
|
|
26
|
+
export const KeyAuthMethod = "xeonr.auth.method";
|
|
27
|
+
export const FieldAuthMethod = "auth_method";
|
|
28
|
+
/** OriginSubject is the subject at the entry of the trace. It survives a service-account hop through baggage from trusted in-cluster peers. */
|
|
29
|
+
export const KeyOriginSubject = "xeonr.origin.subject";
|
|
30
|
+
export const FieldOriginSubject = "origin_subject";
|
|
31
|
+
/** OriginService is the service.name of the trace's entry service. */
|
|
32
|
+
export const KeyOriginService = "xeonr.origin.service";
|
|
33
|
+
export const FieldOriginService = "origin_service";
|
|
34
|
+
/** TeamURN is the team the request acts on (resource ownership), set by the handler with SetTeam. Never the caller's membership list. */
|
|
35
|
+
export const KeyTeamURN = "xeonr.team.urn";
|
|
36
|
+
export const FieldTeamURN = "team_urn";
|
|
37
|
+
/** ResourceType is the kind of the request's target, set with SetResource. */
|
|
38
|
+
export const KeyResourceType = "xeonr.resource.type";
|
|
39
|
+
export const FieldResourceType = "resource_type";
|
|
40
|
+
/** ResourceID is the target's id, set with SetResource. */
|
|
41
|
+
export const KeyResourceID = "xeonr.resource.id";
|
|
42
|
+
export const FieldResourceID = "resource_id";
|
|
43
|
+
/** ResourceURN is the target's URN, set with SetResource. */
|
|
44
|
+
export const KeyResourceURN = "xeonr.resource.urn";
|
|
45
|
+
export const FieldResourceURN = "resource_urn";
|
|
46
|
+
/** Scopes are the token's scopes. They go on the RPC server span only: Attributes and Fields leave them out. */
|
|
47
|
+
export const KeyScopes = "xeonr.scopes";
|
|
48
|
+
/** JobName is the background job's name (trail.outbox.flush), set by StartJob. */
|
|
49
|
+
export const KeyJobName = "xeonr.job.name";
|
|
50
|
+
export const FieldJobName = "job";
|
|
51
|
+
/** JobRunID identifies one run of the job, set by StartJob. */
|
|
52
|
+
export const KeyJobRunID = "xeonr.job.run_id";
|
|
53
|
+
export const FieldJobRunID = "job_run_id";
|
|
54
|
+
/** JobTrigger is what started the job (cron, queue, request), set by StartJob's Trigger option. */
|
|
55
|
+
export const KeyJobTrigger = "xeonr.job.trigger";
|
|
56
|
+
export const FieldJobTrigger = "job_trigger";
|
|
57
|
+
/** the Connect procedure of the request a log line belongs to */
|
|
58
|
+
export const FieldProcedure = "procedure";
|
|
59
|
+
/** the Connect code of a finished RPC */
|
|
60
|
+
export const FieldStatus = "status";
|
|
61
|
+
/** how long the RPC or job took, in milliseconds */
|
|
62
|
+
export const FieldDurationMS = "duration_ms";
|
|
63
|
+
/** the resolved client address (connectmw.ClientIPResolver) */
|
|
64
|
+
export const FieldIP = "ip";
|
|
65
|
+
/** true on a span whose request or job panicked */
|
|
66
|
+
export const KeyPanic = "xeonr.panic";
|
|
67
|
+
/** The §4.2 table in order. */
|
|
68
|
+
export const IDENTITY_KEYS = [
|
|
69
|
+
{ "field": "Subject", "prop": "subject", "span": "xeonr.subject", "log": "subject" },
|
|
70
|
+
{ "field": "SubjectKind", "prop": "subjectKind", "span": "xeonr.subject.kind", "log": "subject_kind" },
|
|
71
|
+
{ "field": "OrgID", "prop": "orgId", "span": "xeonr.org.id", "log": "org_id", "baggage": true },
|
|
72
|
+
{ "field": "ClientID", "prop": "clientId", "span": "xeonr.client.id", "log": "client_id" },
|
|
73
|
+
{ "field": "ApplicationID", "prop": "applicationId", "span": "xeonr.application.id", "log": "application_id" },
|
|
74
|
+
{ "field": "DelegatorApp", "prop": "delegatorApp", "span": "xeonr.delegator.app", "log": "delegator_app" },
|
|
75
|
+
{ "field": "APIKeyID", "prop": "apiKeyId", "span": "xeonr.api_key.id", "log": "api_key_id" },
|
|
76
|
+
{ "field": "AuthMethod", "prop": "authMethod", "span": "xeonr.auth.method", "log": "auth_method" },
|
|
77
|
+
{ "field": "OriginSubject", "prop": "originSubject", "span": "xeonr.origin.subject", "log": "origin_subject", "baggage": true },
|
|
78
|
+
{ "field": "OriginService", "prop": "originService", "span": "xeonr.origin.service", "log": "origin_service", "baggage": true },
|
|
79
|
+
{ "field": "TeamURN", "prop": "teamUrn", "span": "xeonr.team.urn", "log": "team_urn" },
|
|
80
|
+
{ "field": "ResourceType", "prop": "resourceType", "span": "xeonr.resource.type", "log": "resource_type" },
|
|
81
|
+
{ "field": "ResourceID", "prop": "resourceId", "span": "xeonr.resource.id", "log": "resource_id" },
|
|
82
|
+
{ "field": "ResourceURN", "prop": "resourceUrn", "span": "xeonr.resource.urn", "log": "resource_urn" },
|
|
83
|
+
{ "field": "Scopes", "prop": "scopes", "span": "xeonr.scopes", "rpcServerSpanOnly": true },
|
|
84
|
+
{ "field": "JobName", "prop": "jobName", "span": "xeonr.job.name", "log": "job" },
|
|
85
|
+
{ "field": "JobRunID", "prop": "jobRunId", "span": "xeonr.job.run_id", "log": "job_run_id" },
|
|
86
|
+
{ "field": "JobTrigger", "prop": "jobTrigger", "span": "xeonr.job.trigger", "log": "job_trigger" },
|
|
87
|
+
];
|
|
88
|
+
/** The baggage members, in table order: nothing else ever travels as baggage. */
|
|
89
|
+
export const BAGGAGE_KEYS = ["xeonr.org.id", "xeonr.origin.subject", "xeonr.origin.service"];
|
|
90
|
+
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,wBAAwB;AAYxB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,qKAAqK;AACrK,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,iPAAiP;AACjP,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,6GAA6G;AAC7G,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AACnC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IAC7F,EAAC,OAAO,EAAC,QAAQ,EAAC,MAAM,EAAC,QAAQ,EAAC,MAAM,EAAC,cAAc,EAAC,mBAAmB,EAAC,IAAI,EAAC;IACjF,EAAC,OAAO,EAAC,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,gBAAgB,EAAC,KAAK,EAAC,KAAK,EAAC;IACxE,EAAC,OAAO,EAAC,UAAU,EAAC,MAAM,EAAC,UAAU,EAAC,MAAM,EAAC,kBAAkB,EAAC,KAAK,EAAC,YAAY,EAAC;IACnF,EAAC,OAAO,EAAC,YAAY,EAAC,MAAM,EAAC,YAAY,EAAC,MAAM,EAAC,mBAAmB,EAAC,KAAK,EAAC,aAAa,EAAC;CACzF,CAAC;AAEF,iFAAiF;AACjF,MAAM,CAAC,MAAM,YAAY,GAAsB,CAAC,cAAc,EAAC,sBAAsB,EAAC,sBAAsB,CAAC,CAAC"}
|
package/dist/keys.json
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "The fleet's identity vocabulary (observability plan §4.2). telemetry/keys_gen.go is generated from this file (go generate ./telemetry); @xeonr/telemetry (Node) compares its own constants against it. One key per concept: the log field is the span key without `xeonr.`, dots as underscores, except where the table names a shorter field. Keys are dots only and never collide with Lantern's direct-column aliases or resource namespaces.",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"identity": [
|
|
5
|
+
{
|
|
6
|
+
"field": "Subject",
|
|
7
|
+
"span": "xeonr.subject",
|
|
8
|
+
"log": "subject",
|
|
9
|
+
"doc": "Subject is the verified principal's full URN (urn:xeonr:auth:uid:user:88, a service account, a client, an API key's owner or the key itself). Never a bare id."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"field": "SubjectKind",
|
|
13
|
+
"span": "xeonr.subject.kind",
|
|
14
|
+
"log": "subject_kind",
|
|
15
|
+
"values": ["user", "service_account", "client", "api_key", "team", "anonymous", "system", "unknown"],
|
|
16
|
+
"doc": "SubjectKind is derived from Subject's URN prefix (SubjectKind func): user, service_account, client, api_key, team; anonymous for an unauthenticated request, system for a job with no caller, unknown for a URN with no recognised prefix."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"field": "OrgID",
|
|
20
|
+
"span": "xeonr.org.id",
|
|
21
|
+
"log": "org_id",
|
|
22
|
+
"baggage": true,
|
|
23
|
+
"doc": "OrgID is the auth organisation id (Principal.OrganisationID). Not Lantern's org.id resource attribute."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"field": "ClientID",
|
|
27
|
+
"span": "xeonr.client.id",
|
|
28
|
+
"log": "client_id",
|
|
29
|
+
"doc": "ClientID is the OAuth client the token was issued to."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"field": "ApplicationID",
|
|
33
|
+
"span": "xeonr.application.id",
|
|
34
|
+
"log": "application_id",
|
|
35
|
+
"doc": "ApplicationID is the auth application the token was minted for."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"field": "DelegatorApp",
|
|
39
|
+
"span": "xeonr.delegator.app",
|
|
40
|
+
"log": "delegator_app",
|
|
41
|
+
"doc": "DelegatorApp is the product acting for the user on an RFC 8693 exchanged token; empty unless delegated."
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"field": "APIKeyID",
|
|
45
|
+
"span": "xeonr.api_key.id",
|
|
46
|
+
"log": "api_key_id",
|
|
47
|
+
"doc": "APIKeyID is the API key's URN when a key authenticated the request."
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"field": "AuthMethod",
|
|
51
|
+
"span": "xeonr.auth.method",
|
|
52
|
+
"log": "auth_method",
|
|
53
|
+
"values": ["bearer", "cookie", "api_key", "none"],
|
|
54
|
+
"doc": "AuthMethod is how the caller authenticated: bearer, cookie, api_key, or none."
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"field": "OriginSubject",
|
|
58
|
+
"span": "xeonr.origin.subject",
|
|
59
|
+
"log": "origin_subject",
|
|
60
|
+
"baggage": true,
|
|
61
|
+
"doc": "OriginSubject is the subject at the entry of the trace. It survives a service-account hop through baggage from trusted in-cluster peers."
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"field": "OriginService",
|
|
65
|
+
"span": "xeonr.origin.service",
|
|
66
|
+
"log": "origin_service",
|
|
67
|
+
"baggage": true,
|
|
68
|
+
"doc": "OriginService is the service.name of the trace's entry service."
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"field": "TeamURN",
|
|
72
|
+
"span": "xeonr.team.urn",
|
|
73
|
+
"log": "team_urn",
|
|
74
|
+
"doc": "TeamURN is the team the request acts on (resource ownership), set by the handler with SetTeam. Never the caller's membership list."
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"field": "ResourceType",
|
|
78
|
+
"span": "xeonr.resource.type",
|
|
79
|
+
"log": "resource_type",
|
|
80
|
+
"doc": "ResourceType is the kind of the request's target, set with SetResource."
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"field": "ResourceID",
|
|
84
|
+
"span": "xeonr.resource.id",
|
|
85
|
+
"log": "resource_id",
|
|
86
|
+
"doc": "ResourceID is the target's id, set with SetResource."
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"field": "ResourceURN",
|
|
90
|
+
"span": "xeonr.resource.urn",
|
|
91
|
+
"log": "resource_urn",
|
|
92
|
+
"doc": "ResourceURN is the target's URN, set with SetResource."
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"field": "Scopes",
|
|
96
|
+
"span": "xeonr.scopes",
|
|
97
|
+
"type": "[]string",
|
|
98
|
+
"rpc_server_span_only": true,
|
|
99
|
+
"doc": "Scopes are the token's scopes. They go on the RPC server span only: Attributes and Fields leave them out."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"field": "JobName",
|
|
103
|
+
"span": "xeonr.job.name",
|
|
104
|
+
"log": "job",
|
|
105
|
+
"doc": "JobName is the background job's name (trail.outbox.flush), set by StartJob."
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"field": "JobRunID",
|
|
109
|
+
"span": "xeonr.job.run_id",
|
|
110
|
+
"log": "job_run_id",
|
|
111
|
+
"doc": "JobRunID identifies one run of the job, set by StartJob."
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"field": "JobTrigger",
|
|
115
|
+
"span": "xeonr.job.trigger",
|
|
116
|
+
"log": "job_trigger",
|
|
117
|
+
"doc": "JobTrigger is what started the job (cron, queue, request), set by StartJob's Trigger option."
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"other": [
|
|
121
|
+
{"name": "Procedure", "log": "procedure", "doc": "the Connect procedure of the request a log line belongs to"},
|
|
122
|
+
{"name": "Status", "log": "status", "doc": "the Connect code of a finished RPC"},
|
|
123
|
+
{"name": "DurationMS", "log": "duration_ms", "doc": "how long the RPC or job took, in milliseconds"},
|
|
124
|
+
{"name": "IP", "log": "ip", "doc": "the resolved client address (connectmw.ClientIPResolver)"},
|
|
125
|
+
{"name": "Panic", "span": "xeonr.panic", "doc": "true on a span whose request or job panicked"}
|
|
126
|
+
]
|
|
127
|
+
}
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@xeonr/telemetry/log`: the service's pino logger (obs.node-telemetry,
|
|
3
|
+
* observability plan §5.6/§6), the Node counterpart of logrus with
|
|
4
|
+
* go-platform's telemetry.LogrusHook:
|
|
5
|
+
*
|
|
6
|
+
* - JSON on stdout only, `level`/`time`/`msg` as logrus writes them, `time`
|
|
7
|
+
* in RFC 3339;
|
|
8
|
+
* - `trace_id`, `span_id`, `trace_flags`, every §4.2 field of the request's
|
|
9
|
+
* identity, `procedure` and `ip`, from the active context. A field the call
|
|
10
|
+
* passes itself wins;
|
|
11
|
+
* - credentials redacted by key, error texts sanitised;
|
|
12
|
+
* - an Error line inside a recording span is mirrored as a span event, so the
|
|
13
|
+
* error's text reaches the trace although logs are never shipped.
|
|
14
|
+
*/
|
|
15
|
+
import { type Context } from "@opentelemetry/api";
|
|
16
|
+
import pino, { type Logger, type LoggerOptions } from "pino";
|
|
17
|
+
export type { Logger } from "pino";
|
|
18
|
+
/** Keys whose values are never logged, at the top level and one level down. */
|
|
19
|
+
export declare const REDACT_KEYS: string[];
|
|
20
|
+
/** The fields the active context adds to a line. */
|
|
21
|
+
export declare function contextFields(ctx?: Context): Record<string, string>;
|
|
22
|
+
/** pino options for the fleet's line shape. Exposed for a service that needs its own destination in tests. */
|
|
23
|
+
export declare function loggerOptions(opts?: {
|
|
24
|
+
level?: string;
|
|
25
|
+
redact?: string[];
|
|
26
|
+
}): LoggerOptions;
|
|
27
|
+
/** An error as a log field: its type, sanitised message, stack and code. Never an upstream body. */
|
|
28
|
+
export declare function serializeError(err: unknown): Record<string, unknown>;
|
|
29
|
+
/** Makes a logger with the fleet's line shape on stdout. Most services use `logger`. */
|
|
30
|
+
export declare function createLogger(opts?: {
|
|
31
|
+
level?: string;
|
|
32
|
+
redact?: string[];
|
|
33
|
+
destination?: pino.DestinationStream;
|
|
34
|
+
}): Logger;
|
|
35
|
+
/** The process's logger. */
|
|
36
|
+
export declare const logger: Logger;
|
|
37
|
+
/**
|
|
38
|
+
* The logger bound to a context other than the active one, as
|
|
39
|
+
* `log.WithContext(ctx)`: for a line about a request or job written from a
|
|
40
|
+
* callback that runs outside it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function withContext(ctx: Context, l?: Logger): Logger;
|
|
43
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAK7D,YAAY,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,+EAA+E;AAC/E,eAAO,MAAM,WAAW,UAgBvB,CAAC;AAIF,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,GAAG,GAAE,OAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAerF;AAED,8GAA8G;AAC9G,wBAAgB,aAAa,CAAC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAAG,aAAa,CAsB7F;AASD,oGAAoG;AACpG,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUpE;AAaD,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAA;CAAO,GAAG,MAAM,CAE3H;AAED,4BAA4B;AAC5B,eAAO,MAAM,MAAM,EAAE,MAAuB,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,GAAE,MAAe,GAAG,MAAM,CAQpE"}
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@xeonr/telemetry/log`: the service's pino logger (obs.node-telemetry,
|
|
3
|
+
* observability plan §5.6/§6), the Node counterpart of logrus with
|
|
4
|
+
* go-platform's telemetry.LogrusHook:
|
|
5
|
+
*
|
|
6
|
+
* - JSON on stdout only, `level`/`time`/`msg` as logrus writes them, `time`
|
|
7
|
+
* in RFC 3339;
|
|
8
|
+
* - `trace_id`, `span_id`, `trace_flags`, every §4.2 field of the request's
|
|
9
|
+
* identity, `procedure` and `ip`, from the active context. A field the call
|
|
10
|
+
* passes itself wins;
|
|
11
|
+
* - credentials redacted by key, error texts sanitised;
|
|
12
|
+
* - an Error line inside a recording span is mirrored as a span event, so the
|
|
13
|
+
* error's text reaches the trace although logs are never shipped.
|
|
14
|
+
*/
|
|
15
|
+
import { context, trace } from "@opentelemetry/api";
|
|
16
|
+
import pino, {} from "pino";
|
|
17
|
+
import { fields, stateFrom } from "./identity.js";
|
|
18
|
+
import { FieldIP, FieldProcedure } from "./keys.js";
|
|
19
|
+
import { sanitize, sanitizeError } from "./sanitize.js";
|
|
20
|
+
/** Keys whose values are never logged, at the top level and one level down. */
|
|
21
|
+
export const REDACT_KEYS = [
|
|
22
|
+
"authorization",
|
|
23
|
+
"cookie",
|
|
24
|
+
"set-cookie",
|
|
25
|
+
"password",
|
|
26
|
+
"passwd",
|
|
27
|
+
"secret",
|
|
28
|
+
"token",
|
|
29
|
+
"accessToken",
|
|
30
|
+
"refreshToken",
|
|
31
|
+
"access_token",
|
|
32
|
+
"refresh_token",
|
|
33
|
+
"id_token",
|
|
34
|
+
"client_secret",
|
|
35
|
+
"apiKey",
|
|
36
|
+
"api_key",
|
|
37
|
+
];
|
|
38
|
+
const ERROR_LEVEL = 50;
|
|
39
|
+
/** The fields the active context adds to a line. */
|
|
40
|
+
export function contextFields(ctx = context.active()) {
|
|
41
|
+
const out = {};
|
|
42
|
+
const sc = trace.getSpanContext(ctx);
|
|
43
|
+
if (sc && trace.isSpanContextValid(sc)) {
|
|
44
|
+
out.trace_id = sc.traceId;
|
|
45
|
+
out.span_id = sc.spanId;
|
|
46
|
+
out.trace_flags = sc.traceFlags.toString(16).padStart(2, "0");
|
|
47
|
+
}
|
|
48
|
+
const s = stateFrom(ctx);
|
|
49
|
+
if (s) {
|
|
50
|
+
Object.assign(out, fields(s.identity()));
|
|
51
|
+
if (s.procedure)
|
|
52
|
+
out[FieldProcedure] = s.procedure;
|
|
53
|
+
if (s.ip)
|
|
54
|
+
out[FieldIP] = s.ip;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/** pino options for the fleet's line shape. Exposed for a service that needs its own destination in tests. */
|
|
59
|
+
export function loggerOptions(opts = {}) {
|
|
60
|
+
const keys = [...REDACT_KEYS, ...(opts.redact ?? [])];
|
|
61
|
+
return {
|
|
62
|
+
level: opts.level ?? process.env.LOG_LEVEL?.trim().toLowerCase() ?? "info",
|
|
63
|
+
base: null,
|
|
64
|
+
messageKey: "msg",
|
|
65
|
+
errorKey: "error",
|
|
66
|
+
timestamp: () => `,"time":"${new Date().toISOString()}"`,
|
|
67
|
+
formatters: { level: (label) => ({ level: label }) },
|
|
68
|
+
mixin: () => contextFields(),
|
|
69
|
+
redact: { paths: keys.flatMap((k) => [`["${k}"]`, `*["${k}"]`]), censor: "[REDACTED]" },
|
|
70
|
+
serializers: {
|
|
71
|
+
error: errorField,
|
|
72
|
+
err: errorField,
|
|
73
|
+
},
|
|
74
|
+
hooks: {
|
|
75
|
+
logMethod(args, method, level) {
|
|
76
|
+
if (level >= ERROR_LEVEL)
|
|
77
|
+
mirrorToSpan(args);
|
|
78
|
+
return method.apply(this, args);
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** An `error` / `err` field: an Error is serialised, a string sanitised, anything else left alone. */
|
|
84
|
+
function errorField(v) {
|
|
85
|
+
if (v instanceof Error)
|
|
86
|
+
return serializeError(v);
|
|
87
|
+
if (typeof v === "string")
|
|
88
|
+
return sanitize(v);
|
|
89
|
+
return v;
|
|
90
|
+
}
|
|
91
|
+
/** An error as a log field: its type, sanitised message, stack and code. Never an upstream body. */
|
|
92
|
+
export function serializeError(err) {
|
|
93
|
+
const { type, message } = sanitizeError(err);
|
|
94
|
+
const out = { type, message };
|
|
95
|
+
if (err instanceof Error) {
|
|
96
|
+
// The frames only: the first line repeats the (unsanitised) message.
|
|
97
|
+
if (err.stack)
|
|
98
|
+
out.stack = err.stack.split("\n").slice(1).join("\n").trim();
|
|
99
|
+
const code = err.code;
|
|
100
|
+
if (typeof code === "string" || typeof code === "number")
|
|
101
|
+
out.code = code;
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function mirrorToSpan(args) {
|
|
106
|
+
const span = trace.getActiveSpan();
|
|
107
|
+
if (!span?.isRecording())
|
|
108
|
+
return;
|
|
109
|
+
const [first, second] = args;
|
|
110
|
+
const msg = typeof first === "string" ? first : typeof second === "string" ? second : "";
|
|
111
|
+
const attrs = { "log.severity": "error", "log.message": sanitize(msg) };
|
|
112
|
+
const err = first instanceof Error ? first : first?.error ?? first?.err;
|
|
113
|
+
if (err !== undefined)
|
|
114
|
+
attrs["exception.message"] = sanitizeError(err).message;
|
|
115
|
+
span.addEvent("log", attrs);
|
|
116
|
+
}
|
|
117
|
+
/** Makes a logger with the fleet's line shape on stdout. Most services use `logger`. */
|
|
118
|
+
export function createLogger(opts = {}) {
|
|
119
|
+
return pino(loggerOptions(opts), opts.destination ?? pino.destination({ dest: 1, sync: true }));
|
|
120
|
+
}
|
|
121
|
+
/** The process's logger. */
|
|
122
|
+
export const logger = createLogger();
|
|
123
|
+
/**
|
|
124
|
+
* The logger bound to a context other than the active one, as
|
|
125
|
+
* `log.WithContext(ctx)`: for a line about a request or job written from a
|
|
126
|
+
* callback that runs outside it.
|
|
127
|
+
*/
|
|
128
|
+
export function withContext(ctx, l = logger) {
|
|
129
|
+
return new Proxy(l, {
|
|
130
|
+
get(target, prop, receiver) {
|
|
131
|
+
const v = Reflect.get(target, prop, receiver);
|
|
132
|
+
if (typeof v !== "function" || !LEVELS.has(prop))
|
|
133
|
+
return v;
|
|
134
|
+
return (...args) => context.with(ctx, () => v.apply(target, args));
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const LEVELS = new Set(["trace", "debug", "info", "warn", "error", "fatal"]);
|
|
139
|
+
//# sourceMappingURL=log.js.map
|
package/dist/log.js.map
ADDED
|
@@ -0,0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AAQ,CAAC,CAAC;YACvD,IAAI,OAAO,CAAC,KAAK,UAAU,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,OAAO,CAAC,CAAC;YAC3D,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAE,CAAkC,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;QACjH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The span processors `init` installs, in order:
|
|
3
|
+
*
|
|
4
|
+
* 1. IdentitySpanProcessor stamps the request's identity on every span
|
|
5
|
+
* started under it (go-platform's telemetry.SpanProcessor).
|
|
6
|
+
* 2. SanitizeSpanProcessor strips queries and credentials from URL attributes
|
|
7
|
+
* and names client spans `HTTP <METHOD> <peer>` (§4.3).
|
|
8
|
+
* 3. The processors a service adds at run time (`addSpanProcessor`), e.g. the
|
|
9
|
+
* upl-im pipeline's own trace store.
|
|
10
|
+
* 4. The OTLP batch processor, behind ExportGuard.
|
|
11
|
+
*/
|
|
12
|
+
import { type Context } from "@opentelemetry/api";
|
|
13
|
+
import type { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace";
|
|
14
|
+
/** `peer.service` (go-platform's KeyPeerService). */
|
|
15
|
+
export declare const KEY_PEER_SERVICE = "peer.service";
|
|
16
|
+
/** Runs `fn` with `peer` named on every HTTP client span it starts: `peer.service`, and the span name `HTTP GET <peer>`. */
|
|
17
|
+
export declare function withPeer<T>(peer: string, fn: () => T, ctx?: Context): T;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare function peerFrom(ctx: Context): string | undefined;
|
|
20
|
+
export declare class IdentitySpanProcessor implements SpanProcessor {
|
|
21
|
+
onStart(span: Span, parent: Context): void;
|
|
22
|
+
onEnd(): void;
|
|
23
|
+
forceFlush(): Promise<void>;
|
|
24
|
+
shutdown(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare class SanitizeSpanProcessor implements SpanProcessor {
|
|
27
|
+
onStart(span: Span, parent: Context): void;
|
|
28
|
+
onEnd(): void;
|
|
29
|
+
forceFlush(): Promise<void>;
|
|
30
|
+
shutdown(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/** Processors added after boot. A span sees the processors that were there when it started. */
|
|
33
|
+
export declare class DynamicSpanProcessor implements SpanProcessor {
|
|
34
|
+
#private;
|
|
35
|
+
add(p: SpanProcessor): void;
|
|
36
|
+
onStart(span: Span, parent: Context): void;
|
|
37
|
+
onEnd(span: ReadableSpan): void;
|
|
38
|
+
forceFlush(): Promise<void>;
|
|
39
|
+
shutdown(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export declare const METRIC_ROOTLESS_CLIENT_SPANS = "xeonr_telemetry_rootless_client_spans_total";
|
|
42
|
+
/** The event attribute that keeps a span event out of the OTLP export. */
|
|
43
|
+
export declare const KEY_LOCAL_EVENT = "xeonr.local";
|
|
44
|
+
/**
|
|
45
|
+
* Attributes for a span event that only the service's own processors may see
|
|
46
|
+
* (`addSpanProcessor`), never the collector: payloads a product shows its own
|
|
47
|
+
* users (the upl-im pipeline's run traces), which §4.2 forbids in Lantern.
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* span.addEvent("rpc.request", localEvent({ payload }));
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function localEvent<T extends Record<string, unknown>>(attrs: T): T & {
|
|
54
|
+
[KEY_LOCAL_EVENT]: true;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Sits in front of the OTLP batch processor:
|
|
58
|
+
*
|
|
59
|
+
* - Keeps a client or producer span that has no parent out of the export
|
|
60
|
+
* (obs.rooted-spans: a database, cache or client span is never a trace
|
|
61
|
+
* root). Such a span means the work ran on a context with no span: a loop
|
|
62
|
+
* or callback not under `startJob`. The instrumentations that can refuse
|
|
63
|
+
* those spans already do (`requireParentSpan`); this catches the rest
|
|
64
|
+
* (mysql2, aws-sdk). Each one dropped is counted in
|
|
65
|
+
* xeonr_telemetry_rootless_client_spans_total{scope}, so the gap stays visible.
|
|
66
|
+
* - Drops `localEvent` events from what is exported.
|
|
67
|
+
*/
|
|
68
|
+
export declare class ExportGuard implements SpanProcessor {
|
|
69
|
+
#private;
|
|
70
|
+
constructor(inner: SpanProcessor);
|
|
71
|
+
onStart(span: Span, parent: Context): void;
|
|
72
|
+
onEnd(span: ReadableSpan): void;
|
|
73
|
+
forceFlush(): Promise<void>;
|
|
74
|
+
shutdown(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../src/processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAgD,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOlF,qDAAqD;AACrD,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,4HAA4H;AAC5H,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,GAAG,GAAE,OAA0B,GAAG,CAAC,CAEzF;AAED,gBAAgB;AAChB,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEzD;AAED,qBAAa,qBAAsB,YAAW,aAAa;IAC1D,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,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