Skip to content

Commit

Permalink
Merge pull request #479 from solarwinds/NH-94960
Browse files Browse the repository at this point in the history
Add back c-ares name collision mitigation
  • Loading branch information
raphael-theriault-swi authored Oct 30, 2024
2 parents c0587bf + 35fc7a7 commit 3119fae
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .yarn/versions/2b13196a.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
releases:
solarwinds-apm: patch
1 change: 1 addition & 0 deletions packages/solarwinds-apm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@solarwinds-apm/sampling": "workspace:^",
"json-stringify-safe": "^5.0.1",
"node-releases": "^2.0.18",
"semver": "^7.6.3",
"zod": "^3.23.8"
},
"peerDependencies": {
Expand Down
9 changes: 6 additions & 3 deletions packages/solarwinds-apm/src/appoptics/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { oboe } from "@solarwinds-apm/bindings"

import { type Configuration } from "../config.js"
import { componentLogger } from "../logger.js"
import { modules } from "../metadata.js"
import { modules, VERSIONS } from "../metadata.js"
import { VERSION } from "../version.js"
import certificate from "./certificate.js"

Expand All @@ -43,7 +43,9 @@ export async function reporter(
const reporter = new oboe.Reporter({
service_key: `${config.serviceKey?.token}:${config.service}`,
host: config.collector,
certificates: config.trustedpath ?? certificate,
certificates:
config.trustedpath ??
(config.collector.includes("appoptics.com") ? certificate : ""),
grpc_proxy: config.proxy ?? "",
reporter: "ssl",
metric_format: 1,
Expand All @@ -67,7 +69,7 @@ export async function reporter(
token_bucket_rate: oboe.SETTINGS_UNSET,
})

const logger = componentLogger({ name: "oboe" })
const logger = componentLogger({ name: "liboboe.so" })
oboe.debug_log_add((level, sourceName, sourceLine, message) => {
const log = oboeLevelToOtelLogger(level, logger)

Expand Down Expand Up @@ -98,6 +100,7 @@ export async function init(
): Promise<[string, string | number | boolean | null][]> {
return Object.entries<Attributes>({
...(await modules()),
...VERSIONS,
...resource.attributes,

__Init: true,
Expand Down
16 changes: 16 additions & 0 deletions packages/solarwinds-apm/src/commonjs/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ try {
}
}

if (process.versions.ares) {
if (
process.versions.ares &&
process.env.GRPC_DNS_RESOLVER &&
process.env.GRPC_DNS_RESOLVER.toLowerCase() === "ares"
) {
var message =
"The current Node.js version is incompatible with the c-ares gRPC DNS resolver, " +
"which this application explicitly specifies.";

throw message;
} else {
process.env.GRPC_DNS_RESOLVER = "native";
}
}

module.exports = true;
} catch (error) {
console.warn(error);
Expand Down
2 changes: 0 additions & 2 deletions packages/solarwinds-apm/src/exporters/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export class MetricExporter extends OTLPMetricExporter {
instrumentType: InstrumentType,
): AggregationTemporality {
switch (instrumentType) {
case InstrumentType.COUNTER:
case InstrumentType.OBSERVABLE_COUNTER:
case InstrumentType.HISTOGRAM: {
return AggregationTemporality.DELTA
}
Expand Down
4 changes: 2 additions & 2 deletions packages/solarwinds-apm/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import semver from "semver"
export const VERSIONS: Attributes = Object.fromEntries(
Object.entries(process.versions)
.filter(([name]) => name !== "node")
.map(([name, version]) => [`node.${name}.version`, version]),
.map(([name, version]) => [`nodejs.${name}.version`, version]),
)

/**
Expand All @@ -36,7 +36,7 @@ export async function modules(): Promise<Attributes> {
const modules = await dependencies()
return Object.fromEntries(
[...modules].map(([name, versions]) => [
`node.${name}.versions`,
`node_modules.${name}.versions`,
[...versions].sort(semver.compare),
]),
)
Expand Down
13 changes: 12 additions & 1 deletion scripts/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,21 @@ if (image === "collector") {
} else if (process.argv[3] === "build") {
exec(`docker compose -f docker/docker-compose.yml build ${image}`)
} else {
require("./env.js")
const env = Object.entries(process.env)
.filter(
([key]) =>
key.startsWith("SW_APM_") ||
key.startsWith("OTEL_") ||
key.startsWith("AWS_LAMBDA_"),
)
.map(([k, v]) => `-e ${k}=${v}`)
.join(" ")

// first run yarn install in the context of the container so that platform specific modules get installed
// then start a shell session with `|| true` so that if the last ran command in the shell errors node doesn't throw
// finally run yarn install back on the host to reset the platform specific modules
exec(
`docker compose -f docker/docker-compose.yml run --rm ${image} '(yarn install) && (${shell} || true)'; yarn install`,
`docker compose -f docker/docker-compose.yml run ${env} --rm ${image} '(yarn install) && (${shell} || true)'; yarn install`,
)
}
1 change: 1 addition & 0 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3119fae

Please sign in to comment.