@lorekit/cli 1.23.0 → 1.24.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 +1 -1
- package/src/telemetry.mjs +17 -6
package/package.json
CHANGED
package/src/telemetry.mjs
CHANGED
|
@@ -32,7 +32,9 @@ import { readLorekitJson } from './config.mjs';
|
|
|
32
32
|
// (empty in the source tree, so default export stays off until built/injected).
|
|
33
33
|
const DEFAULT_ENDPOINT = 'https://ingress.europe-west4.gcp.dash0-dev.com';
|
|
34
34
|
const DEFAULT_TOKEN = TELEMETRY_TOKEN; // injected from LOREKIT_TELEMETRY_TOKEN at publish
|
|
35
|
-
|
|
35
|
+
// Ship to the `default` Dash0 dataset unless `DASH0_DATASET` overrides it, so
|
|
36
|
+
// CLI telemetry lands alongside every other LoreKit component (all `default`).
|
|
37
|
+
const DEFAULT_DATASET = 'default';
|
|
36
38
|
|
|
37
39
|
// Flags worth counting (e.g. how many installs are --global). Bounded on
|
|
38
40
|
// purpose: only these booleans are ever attached, never free-form values.
|
|
@@ -125,8 +127,17 @@ export function resolveTelemetryConfig(env = process.env, repoConfig) {
|
|
|
125
127
|
return { enabled: false };
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
// Dataset routing, highest precedence first: an explicit `Dash0-Dataset`
|
|
131
|
+
// already parsed from OTEL_EXPORTER_OTLP_HEADERS wins and is never clobbered;
|
|
132
|
+
// otherwise DASH0_DATASET; otherwise the baked-in DEFAULT_DATASET (`default`).
|
|
133
|
+
// HTTP header names are case-insensitive, so match any casing the caller used
|
|
134
|
+
// (e.g. `dash0-dataset`) rather than only the canonical spelling — otherwise a
|
|
135
|
+
// second, conflicting header would be appended.
|
|
136
|
+
const hasDataset = Object.keys(headers).some((k) => k.toLowerCase() === 'dash0-dataset');
|
|
137
|
+
if (!hasDataset) {
|
|
138
|
+
const dataset = env.DASH0_DATASET || DEFAULT_DATASET;
|
|
139
|
+
if (dataset) headers['Dash0-Dataset'] = dataset;
|
|
140
|
+
}
|
|
130
141
|
|
|
131
142
|
return { enabled: true, endpoint, headers };
|
|
132
143
|
}
|
|
@@ -156,7 +167,7 @@ function toOtlpAttributes(attributes) {
|
|
|
156
167
|
|
|
157
168
|
function resourceAttributes(version) {
|
|
158
169
|
return [
|
|
159
|
-
{ key: 'service.name', value: { stringValue: '
|
|
170
|
+
{ key: 'service.name', value: { stringValue: 'cli' } },
|
|
160
171
|
{ key: 'service.namespace', value: { stringValue: 'lorekit' } },
|
|
161
172
|
{ key: 'service.version', value: { stringValue: String(version) } },
|
|
162
173
|
{ key: 'process.runtime.name', value: { stringValue: 'nodejs' } },
|
|
@@ -189,7 +200,7 @@ export function buildTracePayload({ version, name, attributes, startMs, endMs, s
|
|
|
189
200
|
resource: { attributes: resourceAttributes(version) },
|
|
190
201
|
scopeSpans: [
|
|
191
202
|
{
|
|
192
|
-
scope: { name: '
|
|
203
|
+
scope: { name: 'cli', version: String(version) },
|
|
193
204
|
spans: [
|
|
194
205
|
{
|
|
195
206
|
traceId: traceId ?? randHex(16),
|
|
@@ -219,7 +230,7 @@ export function buildMetricsPayload({ version, attributes, startMs, endMs }) {
|
|
|
219
230
|
resource: { attributes: resourceAttributes(version) },
|
|
220
231
|
scopeMetrics: [
|
|
221
232
|
{
|
|
222
|
-
scope: { name: '
|
|
233
|
+
scope: { name: 'cli', version: String(version) },
|
|
223
234
|
metrics: [
|
|
224
235
|
{
|
|
225
236
|
name: 'lorekit.cli.invocations',
|