Skip to content

Commit 4b44d71

Browse files
committed
Avoids activation event delay
1 parent 66d3c41 commit 4b44d71

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

src/extension.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
177177
void setContext(ContextKeys.Debugging, true);
178178
}
179179

180+
// TODO@eamodio do we want to capture any vscode settings that are relevant to GitLens?
181+
const flatCfg = flatten(configuration.getAll(true), { prefix: 'config', stringify: 'all' });
182+
180183
container.telemetry.setGlobalAttributes({
181184
debugging: container.debugging,
182185
insiders: insiders,
@@ -199,22 +202,18 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
199202
}`,
200203
});
201204

202-
setTimeout(() => {
203-
// TODO@eamodio do we want to capture any vscode settings that are relevant to GitLens?
204-
const config = flatten(configuration.getAll(true), { prefix: 'config', stringify: 'all' });
205-
container.telemetry.sendEvent(
206-
'activate',
207-
{
208-
'activation.elapsed': elapsed,
209-
'activation.mode': mode?.name,
210-
...config,
211-
},
212-
startTime,
213-
endTime,
214-
);
205+
container.telemetry.sendEvent(
206+
'activate',
207+
{
208+
'activation.elapsed': elapsed,
209+
'activation.mode': mode?.name,
210+
...flatCfg,
211+
},
212+
startTime,
213+
endTime,
214+
);
215215

216-
setTimeout(() => uninstallDeprecatedAuthentication(), 25000);
217-
}, 5000);
216+
setTimeout(() => uninstallDeprecatedAuthentication(), 25000);
218217

219218
return Promise.resolve(api);
220219
}

src/telemetry/openTelemetryProvider.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AttributeValue, Span, TimeInput, Tracer } from '@opentelemetry/api';
2+
import { SpanKind } from '@opentelemetry/api';
23
// import { diag, DiagConsoleLogger } from '@opentelemetry/api';
34
// import { DiagLogLevel } from '@opentelemetry/api/build/src/diag/types';
45
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
@@ -63,17 +64,23 @@ export class OpenTelemetryProvider implements TelemetryProvider {
6364
}
6465

6566
sendEvent(name: string, data?: Record<string, AttributeValue>, startTime?: TimeInput, endTime?: TimeInput): void {
66-
const span = this.tracer.startSpan(name, { startTime: startTime ?? Date.now() });
67-
span.setAttributes(this._globalAttributes);
67+
const span = this.tracer.startSpan(name, {
68+
attributes: this._globalAttributes,
69+
kind: SpanKind.INTERNAL,
70+
startTime: startTime ?? Date.now(),
71+
});
6872
if (data != null) {
6973
span.setAttributes(data);
7074
}
7175
span.end(endTime);
7276
}
7377

7478
startEvent(name: string, data?: Record<string, AttributeValue>, startTime?: TimeInput): Span {
75-
const span = this.tracer.startSpan(name, { startTime: startTime ?? Date.now() });
76-
span.setAttributes(this._globalAttributes);
79+
const span = this.tracer.startSpan(name, {
80+
attributes: this._globalAttributes,
81+
kind: SpanKind.INTERNAL,
82+
startTime: startTime ?? Date.now(),
83+
});
7784
if (data != null) {
7885
span.setAttributes(data);
7986
}

0 commit comments

Comments
 (0)