Fix withContext and allow pass options

This commit is contained in:
Andrey Sobolev
2025-10-27 22:24:52 +07:00
parent 1558385596
commit 5bf9334e74
9 changed files with 51 additions and 9 deletions
+2 -2
View File
@@ -468,7 +468,7 @@ importers:
specifier: workspace:^0.7.17
version: link:../analytics
'@hcengineering/measurements':
specifier: workspace:^0.7.17
specifier: workspace:^0.7.18
version: link:../measurements
'@hcengineering/platform':
specifier: workspace:^0.7.17
@@ -626,7 +626,7 @@ importers:
../../packages/measurements-otlp:
dependencies:
'@hcengineering/measurements':
specifier: workspace:^0.7.17
specifier: workspace:^0.7.18
version: link:../measurements
'@opentelemetry/api':
specifier: ^1.9.0
+1 -1
View File
@@ -47,7 +47,7 @@
"dependencies": {
"@hcengineering/platform": "workspace:^0.7.17",
"@hcengineering/analytics": "workspace:^0.7.17",
"@hcengineering/measurements": "workspace:^0.7.17",
"@hcengineering/measurements": "workspace:^0.7.18",
"fast-equals": "^5.2.2"
},
"repository": "https://github.com/hcengineering/huly.core",
+12
View File
@@ -1,6 +1,18 @@
{
"name": "@hcengineering/measurements-otlp",
"entries": [
{
"version": "0.7.17",
"tag": "@hcengineering/measurements-otlp_v0.7.17",
"date": "Mon, 27 Oct 2025 15:24:19 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@hcengineering/measurements\" from `^0.7.17` to `0.7.18`"
}
]
}
},
{
"version": "0.7.13",
"tag": "@hcengineering/measurements-otlp_v0.7.13",
+6 -1
View File
@@ -1,6 +1,11 @@
# Change Log - @hcengineering/measurements-otlp
This log was last generated on Mon, 27 Oct 2025 04:08:57 GMT and should not be manually modified.
This log was last generated on Mon, 27 Oct 2025 15:24:19 GMT and should not be manually modified.
## 0.7.17
Mon, 27 Oct 2025 15:24:19 GMT
_Version update only_
## 0.7.13
Mon, 27 Oct 2025 04:08:57 GMT
+1 -1
View File
@@ -41,7 +41,7 @@
"eslint-plugin-n": "^15.4.0"
},
"dependencies": {
"@hcengineering/measurements": "workspace:^0.7.17",
"@hcengineering/measurements": "workspace:^0.7.18",
"@opentelemetry/sdk-node": "^0.203.0",
"@opentelemetry/sdk-logs": "^0.203.0",
"@opentelemetry/auto-instrumentations-node": "^0.62.0",
+12
View File
@@ -1,6 +1,18 @@
{
"name": "@hcengineering/measurements",
"entries": [
{
"version": "0.7.18",
"tag": "@hcengineering/measurements_v0.7.18",
"date": "Mon, 27 Oct 2025 15:24:19 GMT",
"comments": {
"patch": [
{
"comment": "Fix withContext to use options"
}
]
}
},
{
"version": "0.7.14",
"tag": "@hcengineering/measurements_v0.7.14",
+8 -1
View File
@@ -1,6 +1,13 @@
# Change Log - @hcengineering/measurements
This log was last generated on Mon, 27 Oct 2025 04:08:57 GMT and should not be manually modified.
This log was last generated on Mon, 27 Oct 2025 15:24:19 GMT and should not be manually modified.
## 0.7.18
Mon, 27 Oct 2025 15:24:19 GMT
### Patches
- Fix withContext to use options
## 0.7.14
Mon, 27 Oct 2025 04:08:57 GMT
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hcengineering/measurements",
"version": "0.7.17",
"version": "0.7.18",
"main": "lib/index.js",
"svelte": "src/index.ts",
"types": "types/index.d.ts",
+8 -2
View File
@@ -276,12 +276,18 @@ export class NoMetricsContext implements MeasureContext {
/**
* Allow to use decorator for context enabled functions
*/
export function withContext (name: string, params: ParamsType = {}): any {
export function withContext (name: string, params: ParamsType = {}, options?: WithOptions): any {
return (target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor => {
const originalMethod = descriptor.value
descriptor.value = function (...args: any[]): Promise<any> {
const ctx = args[0] as MeasureContext
return ctx.with(name, params, (ctx) => originalMethod.apply(this, [ctx, ...args.slice(1)]) as Promise<any>)
return ctx.with(
name,
params,
(ctx) => originalMethod.apply(this, [ctx, ...args.slice(1)]) as Promise<any>,
{},
options
)
}
return descriptor
}