@equipe-tech/observability 0.1.0 → 0.2.1
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/LICENSE +202 -0
- package/README.md +27 -0
- package/dist/Metrics.d.ts +74 -0
- package/dist/Metrics.js +20 -0
- package/dist/MetricsRuntime.d.ts +11 -0
- package/dist/MetricsRuntime.js +1286 -0
- package/dist/RedactionPolicy.d.ts +9 -0
- package/dist/RedactionPolicy.js +246 -0
- package/dist/Telemetry.d.ts +8 -4
- package/dist/Telemetry.js +25 -10
- package/dist/TelemetryConfig.d.ts +1 -0
- package/dist/TelemetryConfig.js +1 -1
- package/dist/browser/BrowserClient.d.ts +74 -0
- package/dist/browser/BrowserClient.js +189 -0
- package/dist/browser/client.d.ts +2 -0
- package/dist/browser/client.js +1 -0
- package/dist/browser/index.d.ts +4 -2
- package/dist/browser/index.js +40 -50
- package/dist/nestjs/BrowserEventsController.d.ts +1 -1
- package/dist/nestjs/BrowserEventsController.js +9 -1
- package/dist/nestjs/HttpRoutePolicy.d.ts +23 -0
- package/dist/nestjs/HttpRoutePolicy.js +179 -0
- package/dist/nestjs/HttpServerOtlpTracer.d.ts +15 -0
- package/dist/nestjs/HttpServerOtlpTracer.js +154 -0
- package/dist/nestjs/RequestWideEventTraceCorrelation.d.ts +15 -0
- package/dist/nestjs/RequestWideEventTraceCorrelation.js +13 -0
- package/dist/nestjs/TelemetryInterceptor.d.ts +23 -4
- package/dist/nestjs/TelemetryInterceptor.js +205 -39
- package/dist/nestjs/TelemetryModule.d.ts +53 -0
- package/dist/nestjs/TelemetryModule.js +428 -0
- package/dist/nestjs/index.d.ts +4 -1
- package/dist/nestjs/index.js +3 -1
- package/dist/node/BrowserEventIngest.d.ts +2 -2
- package/dist/node/BrowserEventIngest.js +3 -3
- package/dist/testing/index.d.ts +34 -2
- package/dist/testing/index.js +92 -10
- package/package.json +23 -1
package/dist/testing/index.js
CHANGED
|
@@ -21,11 +21,14 @@ const ExportedSpan = Schema.Struct({
|
|
|
21
21
|
spanId: Schema.String,
|
|
22
22
|
parentSpanId: Schema.String.pipe(Schema.optionalKey),
|
|
23
23
|
name: Schema.String,
|
|
24
|
+
kind: Schema.Number.pipe(Schema.withDecodingDefault(Effect.succeed(0))),
|
|
24
25
|
status: Schema.Struct({
|
|
25
26
|
code: Schema.Number.pipe(Schema.withDecodingDefault(Effect.succeed(0))),
|
|
26
27
|
message: Schema.String.pipe(Schema.optionalKey),
|
|
27
28
|
}).pipe(Schema.withDecodingDefault(Effect.succeed({ code: 0 }))),
|
|
28
29
|
attributes: Attributes,
|
|
30
|
+
events: Schema.Array(Schema.Struct({ name: Schema.String })).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
|
|
31
|
+
links: Schema.Array(Schema.Struct({ spanId: Schema.String })).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
|
|
29
32
|
});
|
|
30
33
|
const SpanExport = Schema.Struct({
|
|
31
34
|
resourceSpans: Schema.Array(Schema.Struct({
|
|
@@ -51,11 +54,35 @@ const MetricDataPoint = Schema.Struct({
|
|
|
51
54
|
asDouble: Schema.Number.pipe(Schema.optionalKey),
|
|
52
55
|
asInt: Schema.Union([Schema.String, Schema.Number]).pipe(Schema.optionalKey),
|
|
53
56
|
});
|
|
54
|
-
const
|
|
57
|
+
const NumberDataPoints = Schema.Struct({ dataPoints: Schema.Array(MetricDataPoint) });
|
|
58
|
+
const HistogramDataPoint = Schema.Struct({
|
|
59
|
+
attributes: Attributes,
|
|
60
|
+
count: Schema.Number,
|
|
61
|
+
sum: Schema.Number,
|
|
62
|
+
min: Schema.Number,
|
|
63
|
+
max: Schema.Number,
|
|
64
|
+
explicitBounds: Schema.Array(Schema.Number),
|
|
65
|
+
bucketCounts: Schema.Array(Schema.Number),
|
|
66
|
+
});
|
|
55
67
|
const ExportedMetric = Schema.Struct({
|
|
56
68
|
name: Schema.String,
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
description: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
|
70
|
+
unit: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed("1"))),
|
|
71
|
+
sum: Schema.Struct({
|
|
72
|
+
dataPoints: Schema.Array(MetricDataPoint),
|
|
73
|
+
isMonotonic: Schema.Boolean,
|
|
74
|
+
aggregationTemporality: Schema.Number,
|
|
75
|
+
}).pipe(Schema.optionalKey),
|
|
76
|
+
gauge: NumberDataPoints.pipe(Schema.optionalKey),
|
|
77
|
+
histogram: Schema.Struct({
|
|
78
|
+
dataPoints: Schema.Array(HistogramDataPoint),
|
|
79
|
+
aggregationTemporality: Schema.Number,
|
|
80
|
+
}).pipe(Schema.optionalKey),
|
|
81
|
+
exponentialHistogram: Schema.Struct({
|
|
82
|
+
dataPoints: Schema.Array(MetricDataPoint),
|
|
83
|
+
aggregationTemporality: Schema.Number,
|
|
84
|
+
}).pipe(Schema.optionalKey),
|
|
85
|
+
summary: NumberDataPoints.pipe(Schema.optionalKey),
|
|
59
86
|
});
|
|
60
87
|
const MetricExport = Schema.Struct({
|
|
61
88
|
resourceMetrics: Schema.Array(Schema.Struct({
|
|
@@ -85,6 +112,10 @@ const toAttributes = (attributes) => {
|
|
|
85
112
|
}
|
|
86
113
|
return converted;
|
|
87
114
|
};
|
|
115
|
+
const toCapturedMetricPoints = (dataPoints) => dataPoints.map((dataPoint) => ({
|
|
116
|
+
value: Option.fromNullishOr(dataPoint.asDouble ?? dataPoint.asInt).pipe(Option.map(Number)),
|
|
117
|
+
attributes: toAttributes(dataPoint.attributes),
|
|
118
|
+
}));
|
|
88
119
|
export const attribute = (attributes, key) => Option.fromNullishOr(attributes.get(key));
|
|
89
120
|
const captureClient = (store) => HttpClient.make((request, url) => Effect.gen(function* () {
|
|
90
121
|
const body = request.body;
|
|
@@ -115,9 +146,12 @@ const decodeCapturedTelemetry = Effect.fn("decodeCapturedTelemetry")(function* (
|
|
|
115
146
|
spanId: span.spanId,
|
|
116
147
|
parentSpanId: Option.fromNullishOr(span.parentSpanId),
|
|
117
148
|
name: span.name,
|
|
149
|
+
kind: span.kind,
|
|
118
150
|
statusCode: span.status.code,
|
|
119
151
|
statusMessage: Option.fromNullishOr(span.status.message),
|
|
120
152
|
attributes: toAttributes(span.attributes),
|
|
153
|
+
eventNames: span.events.map((event) => event.name),
|
|
154
|
+
linkedSpanIds: span.links.map((link) => link.spanId),
|
|
121
155
|
resourceAttributes,
|
|
122
156
|
});
|
|
123
157
|
}
|
|
@@ -148,15 +182,63 @@ const decodeCapturedTelemetry = Effect.fn("decodeCapturedTelemetry")(function* (
|
|
|
148
182
|
const resourceAttributes = toAttributes(resourceMetrics.resource.attributes);
|
|
149
183
|
for (const scopeMetrics of resourceMetrics.scopeMetrics) {
|
|
150
184
|
for (const metric of scopeMetrics.metrics) {
|
|
151
|
-
const
|
|
152
|
-
metrics.push({
|
|
185
|
+
const common = {
|
|
153
186
|
name: metric.name,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
attributes: toAttributes(dataPoint.attributes),
|
|
157
|
-
})),
|
|
187
|
+
description: metric.description,
|
|
188
|
+
unit: metric.unit,
|
|
158
189
|
resourceAttributes,
|
|
159
|
-
}
|
|
190
|
+
};
|
|
191
|
+
if (metric.sum !== undefined) {
|
|
192
|
+
metrics.push({
|
|
193
|
+
...common,
|
|
194
|
+
kind: "sum",
|
|
195
|
+
points: toCapturedMetricPoints(metric.sum.dataPoints),
|
|
196
|
+
isMonotonic: metric.sum.isMonotonic,
|
|
197
|
+
aggregationTemporality: metric.sum.aggregationTemporality,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
else if (metric.gauge !== undefined) {
|
|
201
|
+
metrics.push({
|
|
202
|
+
...common,
|
|
203
|
+
kind: "gauge",
|
|
204
|
+
points: toCapturedMetricPoints(metric.gauge.dataPoints),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
else if (metric.histogram !== undefined) {
|
|
208
|
+
metrics.push({
|
|
209
|
+
...common,
|
|
210
|
+
kind: "histogram",
|
|
211
|
+
points: metric.histogram.dataPoints.map((dataPoint) => ({
|
|
212
|
+
value: Option.none(),
|
|
213
|
+
attributes: toAttributes(dataPoint.attributes),
|
|
214
|
+
})),
|
|
215
|
+
aggregationTemporality: metric.histogram.aggregationTemporality,
|
|
216
|
+
histogramPoints: metric.histogram.dataPoints.map((dataPoint) => ({
|
|
217
|
+
attributes: toAttributes(dataPoint.attributes),
|
|
218
|
+
count: dataPoint.count,
|
|
219
|
+
sum: dataPoint.sum,
|
|
220
|
+
min: dataPoint.min,
|
|
221
|
+
max: dataPoint.max,
|
|
222
|
+
explicitBounds: dataPoint.explicitBounds,
|
|
223
|
+
bucketCounts: dataPoint.bucketCounts,
|
|
224
|
+
})),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else if (metric.exponentialHistogram !== undefined) {
|
|
228
|
+
metrics.push({
|
|
229
|
+
...common,
|
|
230
|
+
kind: "exponentialHistogram",
|
|
231
|
+
points: toCapturedMetricPoints(metric.exponentialHistogram.dataPoints),
|
|
232
|
+
aggregationTemporality: metric.exponentialHistogram.aggregationTemporality,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
else if (metric.summary !== undefined) {
|
|
236
|
+
metrics.push({
|
|
237
|
+
...common,
|
|
238
|
+
kind: "summary",
|
|
239
|
+
points: toCapturedMetricPoints(metric.summary.dataPoints),
|
|
240
|
+
});
|
|
241
|
+
}
|
|
160
242
|
}
|
|
161
243
|
}
|
|
162
244
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equipe-tech/observability",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Contrato OpenTelemetry da Equipe Tech: configuracao, layer OTLP e wide events sobre Effect",
|
|
5
|
+
"homepage": "https://github.com/equipe-tech/observability#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/equipe-tech/observability/issues"
|
|
8
|
+
},
|
|
5
9
|
"license": "Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/equipe-tech/observability.git",
|
|
13
|
+
"directory": "packages/telemetry"
|
|
14
|
+
},
|
|
6
15
|
"files": [
|
|
7
16
|
"dist"
|
|
8
17
|
],
|
|
@@ -12,6 +21,10 @@
|
|
|
12
21
|
"types": "./dist/index.d.ts",
|
|
13
22
|
"import": "./dist/index.js"
|
|
14
23
|
},
|
|
24
|
+
"./metrics": {
|
|
25
|
+
"types": "./dist/Metrics.d.ts",
|
|
26
|
+
"import": "./dist/Metrics.js"
|
|
27
|
+
},
|
|
15
28
|
"./node": {
|
|
16
29
|
"types": "./dist/node/index.d.ts",
|
|
17
30
|
"import": "./dist/node/index.js"
|
|
@@ -24,6 +37,10 @@
|
|
|
24
37
|
"types": "./dist/browser/index.d.ts",
|
|
25
38
|
"import": "./dist/browser/index.js"
|
|
26
39
|
},
|
|
40
|
+
"./browser/client": {
|
|
41
|
+
"types": "./dist/browser/client.d.ts",
|
|
42
|
+
"import": "./dist/browser/client.js"
|
|
43
|
+
},
|
|
27
44
|
"./testing": {
|
|
28
45
|
"types": "./dist/testing/index.d.ts",
|
|
29
46
|
"import": "./dist/testing/index.js"
|
|
@@ -40,17 +57,22 @@
|
|
|
40
57
|
"@nestjs/common": "^11.2.1",
|
|
41
58
|
"@nestjs/core": "^11.2.1",
|
|
42
59
|
"@nestjs/platform-express": "^11.2.1",
|
|
60
|
+
"evlog": "2.27.1",
|
|
43
61
|
"reflect-metadata": "^0.2.2",
|
|
44
62
|
"rxjs": "^7.8.2"
|
|
45
63
|
},
|
|
46
64
|
"peerDependencies": {
|
|
47
65
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
66
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
48
67
|
"rxjs": "^7.2.0"
|
|
49
68
|
},
|
|
50
69
|
"peerDependenciesMeta": {
|
|
51
70
|
"@nestjs/common": {
|
|
52
71
|
"optional": true
|
|
53
72
|
},
|
|
73
|
+
"@nestjs/core": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
54
76
|
"rxjs": {
|
|
55
77
|
"optional": true
|
|
56
78
|
}
|