Skip to content

Commit

Permalink
update effect (#385)
Browse files Browse the repository at this point in the history
gcanti authored Dec 6, 2023

Verified

This commit was signed with the committer’s verified signature.
bitwarden-devops-bot Bitwarden DevOps
1 parent 2cb065e commit 32ad2fc
Showing 6 changed files with 59 additions and 71 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
},
"devDependencies": {
"@effect/language-service": "^0.0.21",
"@effect/opentelemetry": "^0.23.0",
"@effect/opentelemetry": "^0.26.0",
"@mdx-js/mdx": "^2.3.0",
"@opentelemetry/exporter-trace-otlp-http": "0.43.0",
"@opentelemetry/sdk-trace-base": "^1.17.1",
@@ -34,7 +34,7 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"autoprefixer": "^10.4.14",
"effect": "2.0.0-next.58",
"effect": "2.0.0-next.59",
"eslint": "^8.38.0",
"eslint-config-next": "^13.3.0",
"eslint-config-prettier": "^8.8.0",
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions src/guide/observability/otel/metrics/frequency/example.ts
Original file line number Diff line number Diff line change
@@ -12,19 +12,16 @@ Effect.runPromise(
/*
Output:
FrequencyState {
occurrences: {
_id: 'HashMap',
values: [
[ 'Error-9', 20 ],
[ 'Error-8', 7 ],
[ 'Error-3', 15 ],
[ 'Error-2', 7 ],
[ 'Error-1', 11 ],
[ 'Error-7', 7 ],
[ 'Error-6', 5 ],
[ 'Error-5', 12 ],
[ 'Error-4', 16 ]
]
occurrences: Map(9) {
'Error-7' => 12,
'Error-2' => 12,
'Error-4' => 14,
'Error-1' => 14,
'Error-9' => 8,
'Error-6' => 11,
'Error-5' => 9,
'Error-3' => 14,
'Error-8' => 6
},
...
}
31 changes: 14 additions & 17 deletions src/guide/observability/otel/metrics/histogram/linear.ts
Original file line number Diff line number Diff line change
@@ -16,23 +16,20 @@ Effect.runPromise(
/*
Output:
HistogramState {
buckets: {
_id: 'Chunk',
values: [
[ 0, 0 ],
[ 10, 7 ],
[ 20, 11 ],
[ 30, 20 ],
[ 40, 27 ],
[ 50, 38 ],
[ 60, 53 ],
[ 70, 64 ],
[ 80, 73 ],
[ 90, 84 ],
[ Infinity, 100 ],
[length]: 11
]
},
buckets: [
[ 0, 0 ],
[ 10, 7 ],
[ 20, 11 ],
[ 30, 20 ],
[ 40, 27 ],
[ 50, 38 ],
[ 60, 53 ],
[ 70, 64 ],
[ 80, 73 ],
[ 90, 84 ],
[ Infinity, 100 ],
[length]: 11
],
count: 100,
min: 1,
max: 119,
35 changes: 16 additions & 19 deletions src/guide/observability/otel/metrics/histogram/timer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Metric, Chunk, Random, Effect } from "effect"
import { Metric, ReadonlyArray, Random, Effect } from "effect"

// Metric<Histogram, Duration, Histogram>
const timer = Metric.timerWithBoundaries("timer", Chunk.range(1, 10))
const timer = Metric.timerWithBoundaries("timer", ReadonlyArray.range(1, 10))

const program = Random.nextIntBetween(1, 10).pipe(
Effect.flatMap((n) => Effect.sleep(`${n} millis`)),
@@ -15,23 +15,20 @@ Effect.runPromise(program.pipe(Effect.flatMap(() => Metric.value(timer)))).then(
/*
Output:
HistogramState {
buckets: {
_id: 'Chunk',
values: [
[ 1, 3 ],
[ 2, 13 ],
[ 3, 17 ],
[ 4, 26 ],
[ 5, 35 ],
[ 6, 43 ],
[ 7, 53 ],
[ 8, 56 ],
[ 9, 65 ],
[ 10, 72 ],
[ Infinity, 100 ],
[length]: 11
]
},
buckets: [
[ 1, 3 ],
[ 2, 13 ],
[ 3, 17 ],
[ 4, 26 ],
[ 5, 35 ],
[ 6, 43 ],
[ 7, 53 ],
[ 8, 56 ],
[ 9, 65 ],
[ 10, 72 ],
[ Infinity, 100 ],
[length]: 11
],
count: 100,
min: 0.25797,
max: 12.25421,
17 changes: 7 additions & 10 deletions src/guide/observability/otel/metrics/summary/example.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Metric, Chunk, Random, Effect } from "effect"
import { Metric, Random, Effect } from "effect"

const responseTimeSummary = Metric.summary({
name: "response_time_summary",
maxAge: "1 days",
maxSize: 100,
error: 0.03,
quantiles: Chunk.make(0.1, 0.5, 0.9)
quantiles: [0.1, 0.5, 0.9]
})

const program = responseTimeSummary(Random.nextIntBetween(1, 120)).pipe(
@@ -19,14 +19,11 @@ Effect.runPromise(
Output:
SummaryState {
error: 0.03,
quantiles: {
_id: 'Chunk',
values: [
[ 0.1, { _id: 'Option', _tag: 'Some', value: 17 } ],
[ 0.5, { _id: 'Option', _tag: 'Some', value: 62 } ],
[ 0.9, { _id: 'Option', _tag: 'Some', value: 109 } ]
]
},
quantiles: [
[ 0.1, { _id: 'Option', _tag: 'Some', value: 17 } ],
[ 0.5, { _id: 'Option', _tag: 'Some', value: 62 } ],
[ 0.9, { _id: 'Option', _tag: 'Some', value: 109 } ]
],
count: 100,
min: 4,
max: 119,

0 comments on commit 32ad2fc

Please sign in to comment.