@ossy/observability 1.6.0 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/observability",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Structured logger with pluggable backends for the Ossy platform",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,5 +28,5 @@
28
28
  "src",
29
29
  "README.md"
30
30
  ],
31
- "gitHead": "abc435125ddf56e01b61353d49d2a18d2ab55be8"
31
+ "gitHead": "b9708c9c3f368bb642fc3bb76912a68107db24b9"
32
32
  }
@@ -12,10 +12,9 @@
12
12
  */
13
13
 
14
14
  export const id = 'logger-grafana-loki'
15
+ // Only the push URL is required; user/key are optional (not needed for local Loki).
15
16
  export const credentials = [
16
17
  'GRAFANA_LOKI_URL',
17
- 'GRAFANA_LOKI_USER',
18
- 'GRAFANA_LOKI_API_KEY',
19
18
  ]
20
19
 
21
20
  /**
@@ -26,7 +25,9 @@ export async function connect ({ env }) {
26
25
  const url = env.GRAFANA_LOKI_URL
27
26
  const user = env.GRAFANA_LOKI_USER
28
27
  const key = env.GRAFANA_LOKI_API_KEY
29
- const auth = 'Basic ' + Buffer.from(`${user}:${key}`).toString('base64')
28
+ const authHeader = (user && key)
29
+ ? { Authorization: 'Basic ' + Buffer.from(`${user}:${key}`).toString('base64') }
30
+ : {}
30
31
 
31
32
  function push (level, ns, msg, ctx, err) {
32
33
  const entry = {
@@ -53,7 +54,7 @@ export async function connect ({ env }) {
53
54
  method: 'POST',
54
55
  headers: {
55
56
  'Content-Type': 'application/json',
56
- Authorization: auth,
57
+ ...authHeader,
57
58
  },
58
59
  body,
59
60
  }).catch(() => {})
@@ -16,10 +16,9 @@
16
16
  */
17
17
 
18
18
  export const id = 'metrics-grafana'
19
+ // Only the push URL is required; user/key are optional (not needed for local Pushgateway).
19
20
  export const credentials = [
20
21
  'GRAFANA_METRICS_URL',
21
- 'GRAFANA_METRICS_USER',
22
- 'GRAFANA_METRICS_API_KEY',
23
22
  ]
24
23
 
25
24
  /**
@@ -90,7 +89,9 @@ export async function connect ({ env }) {
90
89
  const url = env.GRAFANA_METRICS_URL
91
90
  const user = env.GRAFANA_METRICS_USER
92
91
  const key = env.GRAFANA_METRICS_API_KEY
93
- const auth = 'Basic ' + Buffer.from(`${user}:${key}`).toString('base64')
92
+ const authHeader = (user && key)
93
+ ? { Authorization: 'Basic ' + Buffer.from(`${user}:${key}`).toString('base64') }
94
+ : {}
94
95
 
95
96
  // In-memory accumulators — all values are cumulative (Prometheus semantics).
96
97
  /** @type {Map<string, { name: string, labels: Record<string,string>|undefined, value: number }>} */
@@ -171,7 +172,7 @@ export async function connect ({ env }) {
171
172
  method: 'POST',
172
173
  headers: {
173
174
  'Content-Type': 'text/plain',
174
- Authorization: auth,
175
+ ...authHeader,
175
176
  },
176
177
  body,
177
178
  })