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

fix: sampling messages should be at debug level #449

Merged
merged 2 commits into from
Jul 28, 2024
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
11 changes: 6 additions & 5 deletions src/samplers/lumigoSampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SamplingDecision,
} from '@opentelemetry/sdk-trace-base';
import { Context, Link, Attributes, SpanKind } from '@opentelemetry/api';
import { logger } from '../logging';

export class LumigoSampler implements Sampler {
/* eslint-disable @typescript-eslint/no-unused-vars */
Expand All @@ -20,7 +21,7 @@ export class LumigoSampler implements Sampler {
const endpoint = extractEndpoint(attributes, spanKind);
if (endpoint) {
if (spanKind === SpanKind.CLIENT && doesMatchClientSpanFilteringRegexes(endpoint)) {
console.debug(
logger.debug(
`Dropping trace for endpoint '${endpoint} because it matches the filter regex specified by 'LUMIGO_FILTER_HTTP_ENDPOINTS_REGEX_CLIENT'`
);
decision = SamplingDecision.NOT_RECORD;
Expand All @@ -30,7 +31,7 @@ export class LumigoSampler implements Sampler {
spanKind === SpanKind.SERVER &&
doesMatchServerSpanFilteringRegexes(endpoint)
) {
console.debug(
logger.debug(
`Dropping trace for endpoint '${endpoint} because it matches the filter regex specified by 'LUMIGO_FILTER_HTTP_ENDPOINTS_REGEX_SERVER'`
);
decision = SamplingDecision.NOT_RECORD;
Expand All @@ -39,7 +40,7 @@ export class LumigoSampler implements Sampler {
decision !== SamplingDecision.NOT_RECORD &&
doesMatchGeneralSpanFilteringRegexes(endpoint)
) {
console.debug(
logger.debug(
`Dropping trace for endpoint '${endpoint} because it matches the filter regex specified by 'LUMIGO_FILTER_HTTP_ENDPOINTS_REGEX'`
);
decision = SamplingDecision.NOT_RECORD;
Expand Down Expand Up @@ -111,7 +112,7 @@ export const doesEndpointMatchRegexes = (endpoint: string, regexes: string[]): b
return true;
}
} catch (err) {
console.error(`Invalid regex: '${rawRegex}', skipping it.`);
logger.error(`Invalid regex: '${rawRegex}', skipping it.`);
}
}

Expand All @@ -127,7 +128,7 @@ export const parseStringToArray = (rawArray: string): string[] => {
/* eslint-disable no-empty */
} catch (err) {}

console.error(`Not valid JSON format for an array of strings: '${rawArray}'`);
logger.error(`Not valid JSON format for an array of strings: '${rawArray}'`);
return [];
};

Expand Down
Loading