@pagopa/azure-tracing 0.5.1 → 0.5.2

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.
Files changed (2) hide show
  1. package/README.md +33 -0
  2. package/package.json +23 -2
package/README.md CHANGED
@@ -143,6 +143,15 @@ The connection string (`APPLICATIONINSIGHTS_CONNECTION_STRING`) is still require
143
143
 
144
144
  The managed identity (or other principal) must have the **Monitoring Metrics Publisher** role on the Application Insights resource.
145
145
 
146
+ ## Testing
147
+
148
+ - `pnpm nx test @pagopa/azure-tracing` runs the default unit test suite.
149
+ - `pnpm nx run @pagopa/azure-tracing:integration` runs the opt-in integration suite.
150
+
151
+ > [!IMPORTANT]
152
+ > Pre-condition for the integration suite: Docker must be installed and running locally so Testcontainers can start the required services.
153
+ > The suite already uses the committed PEM fixtures in `src/azure/functions/__tests__/fixtures/`, so no extra certificate-generation step is required.
154
+
146
155
  ## Dependency Constraints
147
156
 
148
157
  ### `import-in-the-middle` version must match `@azure/monitor-opentelemetry`
@@ -186,3 +195,27 @@ npm view @opentelemetry/instrumentation@<version> dependencies | grep 'import-in
186
195
  ```
187
196
 
188
197
  Set `import-in-the-middle` in `package.json` to the same major range as the result.
198
+
199
+ ## Running Integration Tests Locally
200
+
201
+ Integration tests use [Testcontainers](https://node.testcontainers.org/) and require a working container runtime.
202
+
203
+ ```bash
204
+ pnpm nx run @pagopa/azure-tracing:integration
205
+ ```
206
+
207
+ > [!NOTE]
208
+ > Inside the devcontainer, tests work out of the box since Docker is available at the standard socket path.
209
+
210
+ ### Rancher Desktop
211
+
212
+ If you use Rancher Desktop on macOS outside a Linux devcontainer, you need to export two environment variables so that Testcontainers can locate the Docker socket and correctly mount it inside helper containers:
213
+
214
+ ```bash
215
+ export DOCKER_HOST="unix://$HOME/.rd/docker.sock"
216
+ export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
217
+ ```
218
+
219
+ `DOCKER_HOST` tells Testcontainers where the socket is on the host. `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE` tells it which path to bind-mount inside containers (the path inside the Rancher Desktop VM).
220
+
221
+ Add these to your shell profile (`~/.zshrc` or `~/.bashrc`) to avoid setting them every time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/azure-tracing",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "description": "A package that contains some utilities to enable Azure tracing on Node.js applications.",
6
6
  "repository": {
@@ -8,6 +8,21 @@
8
8
  "url": "git+https://github.com/pagopa/dx.git",
9
9
  "directory": "packages/azure-tracing"
10
10
  },
11
+ "nx": {
12
+ "targets": {
13
+ "integration": {
14
+ "executor": "nx:run-commands",
15
+ "cache": false,
16
+ "dependsOn": [
17
+ "^build"
18
+ ],
19
+ "options": {
20
+ "command": "pnpm run integration",
21
+ "cwd": "packages/azure-tracing"
22
+ }
23
+ }
24
+ }
25
+ },
11
26
  "keywords": [
12
27
  "azure",
13
28
  "azuremonitor",
@@ -77,19 +92,25 @@
77
92
  "zod": "^4.4.2"
78
93
  },
79
94
  "devDependencies": {
95
+ "@azure/cosmos": "^4.9.3",
80
96
  "@azure/functions": "^4.11.2",
97
+ "@azure/storage-blob": "^12.31.0",
81
98
  "@tsconfig/node24": "24.0.4",
82
99
  "@types/node": "^22.19.17",
83
100
  "@vitest/coverage-v8": "^3.2.4",
84
101
  "eslint": "^10.3.0",
102
+ "redis": "^5.12.1",
103
+ "testcontainers": "^12.0.0",
85
104
  "tsup": "^8.5.1",
105
+ "tsx": "^4.21.0",
86
106
  "typescript": "~5.9.3",
87
107
  "vitest": "^3.2.4",
88
108
  "@pagopa/eslint-config": "^6.0.4"
89
109
  },
90
110
  "scripts": {
91
111
  "build": "tsup",
92
- "test": "vitest",
112
+ "integration": "vitest run --config vitest.integration.config.js",
113
+ "test": "vitest run",
93
114
  "typecheck": "tsc --noEmit"
94
115
  }
95
116
  }