Skip to content

Commit

Permalink
Merge branch 'main' into feat/WEB-820-docs-cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
carlagn authored Dec 11, 2024
2 parents 3e230f4 + cc28284 commit 502ac66
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,45 +284,52 @@ let statsd = new StatsD({
port: 8125,
})

let diffMetrics = (metrics: any) => {
return metrics.map((metric: any) => {
let prev = 0
let diffBuckets = metric.value.buckets.map((values: any) => {
let [bucket, value] = values
let diff = value - prev
prev = value
return [bucket, diff]
})
const diffMetrics = (metrics: Metric<MetricHistogram>[]) => {
return metrics.map((metric) => {
let prev = 0;

const diffBuckets = metric.value.buckets.map<MetricHistogramBucket>(
(values) => {
const [bucket, value] = values
const diff = value - prev
prev = value
return [bucket, diff]
}
)

metric.value.buckets = diffBuckets
return metric
})
}

let previousHistograms: any = null
let statsdSender = async () => {
let metrics = await prisma.$metrics.json()
let previousHistograms: Metric<MetricHistogram>[] = []


const statsdSender = async () => {
const metrics = await prisma.$metrics.json()

metrics.counters.forEach((counter: any) => {
statsd.gauge('prisma.' + counter.key, counter.value, (...res) => {})
})
});

metrics.gauges.forEach((counter: any) => {
statsd.gauge('prisma.' + counter.key, counter.value, (...res) => {})
})

if (previousHistograms === null) {
if (!previousHistograms.length) {
previousHistograms = diffMetrics(metrics.histograms)

return
}

let diffHistograms = diffMetrics(metrics.histograms)
const diffHistograms = diffMetrics(metrics.histograms);

diffHistograms.forEach((diffHistograms: any, histogramIndex: any) => {
diffHistograms.value.buckets.forEach((values: any, bucketIndex: any) => {
let [bucket, count] = values
let [_, prev] =
diffHistograms.forEach((diffHistogram, histogramIndex) => {
diffHistogram.value.buckets.forEach((values, bucketIndex) => {
const [bucket, count] = values
const [_, prev] =
previousHistograms[histogramIndex].value.buckets[bucketIndex]
let change = count - prev
const change = count - prev

for (let sendTimes = 0; sendTimes < change; sendTimes++) {
statsd.timing('prisma.' + diffHistograms.key, bucket)
Expand Down
30 changes: 28 additions & 2 deletions content/200-orm/500-reference/100-prisma-schema-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3150,7 +3150,7 @@ model User {

### `nanoid()`

Generated values based on the [Nano ID](https://github.com/ai/nanoid) spec.
Generated values based on the [Nano ID](https://github.com/ai/nanoid) spec. `nanoid()` accepts an integer value between 2 and 255 that specifies the _length_ of the generate ID value, e.g. `nanoid(16)` will generated ID with 16 characters. If you don't provide a value to the nanoid() function, the default value is 21.

:::info

Expand All @@ -3173,7 +3173,7 @@ There are two main differences between Nano ID and UUID v4:

#### Examples

##### Generate `nanoid()` values as IDs
##### Generate `nanoid()` values with 21 characters as IDs

<TabbedContent code>
<TabItem value="Relational databases">
Expand All @@ -3198,6 +3198,32 @@ model User {
</TabItem>
</TabbedContent>

##### Generate `nanoid()` values with 16 characters as IDs

<TabbedContent code>
<TabItem value="Relational databases">

```prisma
model User {
id String @id @default(nanoid(16))
name String
}
```

</TabItem>
<TabItem value="MongoDB">

```prisma
model User {
id String @id @default(nanoid(16)) @map("_id")
name String
}
```

</TabItem>
</TabbedContent>




### `now()`
Expand Down
8 changes: 7 additions & 1 deletion content/400-pulse/600-faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,10 @@ A large WAL backlog indicates that Pulse is unable to connect to the publication

### Can users manually set up replication slots for Prisma Pulse?

Yes, users can manually create and manage replication slots. However, Pulse does not maintain self-managed slots. For optimal performance, we recommend using the slots configured by Pulse during the initial setup.
Yes, users can manually create and manage replication slots. However, Pulse does not maintain self-managed slots. For optimal performance, we recommend using the slots configured by Pulse during the initial setup.

### Can there be problems if I manually configure the `walsender_timeout`?

The `walsender_timeout` configuration parameter is a timeout setting that determines the maximum amount of time a WAL sender process (used in replication) will wait for a response from a WAL receiver before disconnecting. It usually defaults to 60 seconds.

Setting a value smaller than 10 seconds may cause connection issues with Pulse.

0 comments on commit 502ac66

Please sign in to comment.