Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make openTelemetryClient more abstract #24

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/goodmetrics/metricsSetups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ interface ConfigureBatchedPreaggregatedLightstepSinkProps {
}

interface PrivateOtelClientProps {
lightstepToken: string;
lightstepUrl: string;
lightstepPort: number;
headers: Header[];
ingestUrl: string;
ingestPort: number;
metricDimensions: Map<string, Dimension>;
resourceDimensions: Map<string, Dimension>;
}
Expand Down Expand Up @@ -125,9 +125,11 @@ export class MetricsSetups {
metricDimensions: props.metricDimensions ?? new Map<string, Dimension>(),
resourceDimensions:
props.resourceDimensions ?? new Map<string, Dimension>(),
lightstepToken: props.lightstepAccessToken,
lightstepPort: props.lightstepPort ?? 443,
lightstepUrl: props.lightstepUrl ?? 'ingest.lightstep.com',
ingestPort: props.lightstepPort ?? 443,
ingestUrl: props.lightstepUrl ?? 'ingest.lightstep.com',
headers: [
new Header('lightstep-access-token', props.lightstepAccessToken),
],
});

const unarySink = this.configureBatchedUnaryLightstepSink({
Expand Down Expand Up @@ -267,15 +269,13 @@ export class MetricsSetups {
return sink;
}

private static opentelemetryClient(
static opentelemetryClient(
props: PrivateOtelClientProps
): OpenTelemetryClient {
const headers = [
new Header('lightstep-access-token', props.lightstepToken),
];
const headers = props.headers;
return OpenTelemetryClient.connect({
sillyOtlpHostname: props.lightstepUrl ?? 'ingest.lightstep.com',
port: props.lightstepPort ?? 443,
sillyOtlpHostname: props.ingestUrl,
port: props.ingestPort,
metricDimensions: props.metricDimensions ?? new Map<string, Dimension>(),
resourceDimensions:
props.resourceDimensions ?? new Map<string, Dimension>(),
Expand Down
Loading