Skip to content

Commit

Permalink
Remove template literals
Browse files Browse the repository at this point in the history
  • Loading branch information
iunanua committed Nov 22, 2024
1 parent ba91347 commit f130f4c
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ dc.subscribe(CHANNEL, (payload) => {
try {
hooks[payload.package]()
} catch (err) {
log.error(`esbuild-wrapped ${payload.package} missing in list of hooks`)
log.error('esbuild-wrapped %s missing in list of hooks', payload.package)
throw err
}

if (!instrumentations[payload.package]) {
log.error(`esbuild-wrapped ${payload.package} missing in list of instrumentations`)
log.error('esbuild-wrapped %s missing in list of instrumentations', payload.package)
return
}

Expand Down
3 changes: 1 addition & 2 deletions packages/datadog-instrumentations/src/helpers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ for (const packageName of names) {
try {
version = version || getVersion(moduleBaseDir)
} catch (e) {
log.error(`Error getting version for "${name}": ${e.message}`)
log.error(e)
log.error('Error getting version for "%s": %s', name, e.message, e)
continue
}
if (typeof namesAndSuccesses[`${name}@${version}`] === 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-plugin-grpc/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = {
}

if (config.hasOwnProperty(filter)) {
log.error(`Expected '${filter}' to be an array or function.`)
log.error('Expected \'%s\' to be an array or function.', filter)
}

return () => ({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class CiVisibilityExporter extends AgentInfoExporter {
repositoryUrl,
(err) => {
if (err) {
log.error(`Error uploading git metadata: ${err.message}`)
log.error('Error uploading git metadata: %s', err.message)
} else {
log.debug('Successfully uploaded git metadata')
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dd-trace/src/debugger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function start (config, rc) {
const ack = rcAckCallbacks.get(ackId)
if (ack === undefined) {
// This should never happen, but just in case something changes in the future, we should guard against it
log.error(`Received an unknown ackId: ${ackId}`)
if (error) log.error(error)
log.error('Received an unknown ackId: %s', ackId)
if (error) log.error('Error starting Dynamic Instrumentation client', error)
return
}
ack(error)
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/exporters/common/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function request (data, options, callback) {
if (isGzip) {
zlib.gunzip(buffer, (err, result) => {
if (err) {
log.error(`Could not gunzip response: ${err.message}`)
log.error('Could not gunzip response: %s', err.message)
callback(null, '', res.statusCode)
} else {
callback(null, result.toString(), res.statusCode)
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/opentracing/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class DatadogSpan {

if (DD_TRACE_EXPERIMENTAL_STATE_TRACKING === 'true') {
if (!this._spanContext._tags['service.name']) {
log.error(`Finishing invalid span: ${this}`)
log.error('Finishing invalid span: %s', this)
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/dd-trace/src/plugins/ci_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = class CiPlugin extends Plugin {
}
this.tracer._exporter.getLibraryConfiguration(this.testConfiguration, (err, libraryConfig) => {
if (err) {
log.error(`Library configuration could not be fetched. ${err.message}`)
log.error('Library configuration could not be fetched. %s', err.message)
} else {
this.libraryConfig = libraryConfig
}
Expand All @@ -61,7 +61,7 @@ module.exports = class CiPlugin extends Plugin {
}
this.tracer._exporter.getSkippableSuites(this.testConfiguration, (err, skippableSuites, itrCorrelationId) => {
if (err) {
log.error(`Skippable suites could not be fetched. ${err.message}`)
log.error('Skippable suites could not be fetched. %s', err.message)
} else {
this.itrCorrelationId = itrCorrelationId
}
Expand Down Expand Up @@ -150,7 +150,7 @@ module.exports = class CiPlugin extends Plugin {
}
this.tracer._exporter.getKnownTests(this.testConfiguration, (err, knownTests) => {
if (err) {
log.error(`Known tests could not be fetched. ${err.message}`)
log.error('Known tests could not be fetched. %s', err.message)
this.libraryConfig.isEarlyFlakeDetectionEnabled = false
}
onDone({ err, knownTests })
Expand Down
4 changes: 2 additions & 2 deletions packages/dd-trace/src/plugins/util/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function getLatestCommits () {
distributionMetric(TELEMETRY_GIT_COMMAND_MS, { command: 'get_local_commits' }, Date.now() - startTime)
return result
} catch (err) {
log.error(`Get latest commits failed: ${err.message}`)
log.error('Get latest commits failed: %s', err.message)
incrementCountMetric(
TELEMETRY_GIT_COMMAND_ERRORS,
{ command: 'get_local_commits', errorType: err.status }
Expand Down Expand Up @@ -229,7 +229,7 @@ function getCommitsRevList (commitsToExclude, commitsToInclude) {
.split('\n')
.filter(commit => commit)
} catch (err) {
log.error(`Get commits to upload failed: ${err.message}`)
log.error('Get commits to upload failed: %s', err.message)
incrementCountMetric(
TELEMETRY_GIT_COMMAND_ERRORS,
{ command: 'get_objects', errorType: err.code, exitCode: err.status || err.errno } // err.status might be null
Expand Down
4 changes: 2 additions & 2 deletions packages/dd-trace/src/plugins/util/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ function removeInvalidMetadata (metadata) {
return Object.keys(metadata).reduce((filteredTags, tag) => {
if (tag === GIT_REPOSITORY_URL) {
if (!validateGitRepositoryUrl(metadata[GIT_REPOSITORY_URL])) {
log.error(`Repository URL is not a valid repository URL: ${metadata[GIT_REPOSITORY_URL]}.`)
log.error('Repository URL is not a valid repository URL: %s.', metadata[GIT_REPOSITORY_URL])
return filteredTags
}
}
if (tag === GIT_COMMIT_SHA) {
if (!validateGitCommitSha(metadata[GIT_COMMIT_SHA])) {
log.error(`Git commit SHA must be a full-length git SHA: ${metadata[GIT_COMMIT_SHA]}.`)
log.error('Git commit SHA must be a full-length git SHA: %s.', metadata[GIT_COMMIT_SHA])
return filteredTags
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function maybeStartServerlessMiniAgent (config) {
try {
require('child_process').spawn(rustBinaryPath, { stdio: 'inherit' })
} catch (err) {
log.error(`Error spawning mini agent process: ${err}`)
log.error('Error spawning mini agent process: %s', err.message)
}
}

Expand Down
20 changes: 10 additions & 10 deletions packages/dd-trace/src/span_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,22 @@ class SpanProcessor {
const id = context.toSpanId()

if (finished.has(span)) {
log.error(`Span was already finished in the same trace: ${span}`)
log.error('Span was already finished in the same trace: %s', span)
} else {
finished.add(span)

if (finishedIds.has(id)) {
log.error(`Another span with the same ID was already finished in the same trace: ${span}`)
log.error('Another span with the same ID was already finished in the same trace: %s', span)
} else {
finishedIds.add(id)
}

if (context._trace !== trace) {
log.error(`A span was finished in the wrong trace: ${span}.`)
log.error('A span was finished in the wrong trace: %s', span)
}

if (finishedSpans.has(span)) {
log.error(`Span was already finished in a different trace: ${span}`)
log.error('Span was already finished in a different trace: %s', span)
} else {
finishedSpans.add(span)
}
Expand All @@ -114,35 +114,35 @@ class SpanProcessor {
const id = context.toSpanId()

if (started.has(span)) {
log.error(`Span was already started in the same trace: ${span}`)
log.error('Span was already started in the same trace: %s', span)
} else {
started.add(span)

if (startedIds.has(id)) {
log.error(`Another span with the same ID was already started in the same trace: ${span}`)
log.error('Another span with the same ID was already started in the same trace: %s', span)
} else {
startedIds.add(id)
}

if (context._trace !== trace) {
log.error(`A span was started in the wrong trace: ${span}.`)
log.error('A span was started in the wrong trace: %s', span)
}

if (startedSpans.has(span)) {
log.error(`Span was already started in a different trace: ${span}`)
log.error('Span was already started in a different trace: %s', span)
} else {
startedSpans.add(span)
}
}

if (!finished.has(span)) {
log.error(`Span started in one trace but was finished in another trace: ${span}`)
log.error('Span started in one trace but was finished in another trace: %s', span)
}
}

for (const span of trace.finished) {
if (!started.has(span)) {
log.error(`Span finished in one trace but was started in another trace: ${span}`)
log.error('Span finished in one trace but was started in another trace: %s', span)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/src/telemetry/init-telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function sendTelemetry (name, tags = []) {
})
proc.on('exit', (code) => {
if (code !== 0) {
log.error(`Telemetry forwarder exited with code ${code}`)
log.error('Telemetry forwarder exited with code %d', code)
}
})
proc.stdin.on('error', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/exporters/common/request.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ describe('request', function () {
'accept-encoding': 'gzip'
}
}, (err, res) => {
expect(log.error).to.have.been.calledWith('Could not gunzip response: unexpected end of file')
expect(log.error).to.have.been.calledWith('Could not gunzip response: %s', 'unexpected end of file')
expect(res).to.equal('')
done(err)
})
Expand Down

0 comments on commit f130f4c

Please sign in to comment.