Skip to content

Commit

Permalink
refactor(publish-metrics): rearrange function order for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
InesNi committed Feb 15, 2024
1 parent c9ce3c8 commit c22c38e
Showing 1 changed file with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,27 @@ function attributeListToObject(attributeList, reporterType) {
return attributes;
}

// ADOT collector translation
//////// ADOT COLLECTOR HANDLING

const ADOTSupportedTraceReporters = ['datadog'];
const ADOTSupportedMetricReporters = [];

// Getting the relevant configurations for ADOT from the full list of reporter configurations

function getADOTRelevantReporterConfigs(configList) {
const configs = configList.filter(
(reporterConfig) =>
(ADOTSupportedTraceReporters.includes(reporterConfig.type) &&
reporterConfig.traces) ||
(ADOTSupportedMetricReporters.includes(reporterConfig.type) &&
reporterConfig.metrics)
);

return configs.length > 0 ? configs : null;
}

// Handling relevant environment variables

function getADOTEnvVars(adotRelevantconfigs, dotenv) {
const envVars = {};
try {
Expand Down Expand Up @@ -145,25 +161,7 @@ const vendorSpecificEnvVarsForCollector = {
}
};

const collectorConfigTemplate = {
receivers: {
otlp: {
protocols: {
http: {
endpoint: '0.0.0.0:4318'
},
grpc: {
endpoint: '0.0.0.0:4317'
}
}
}
},
processors: {},
exporters: {},
service: {
pipelines: {}
}
};
// Assembling the configuration for ADOT (in OTel Collector format)

// Different vendors can be used for metrics and tracing so we need to merge all the parts of the config from each vendor into one collector config
function assembleCollectorConfig(adotRelevantConfigs) {
Expand Down Expand Up @@ -191,6 +189,26 @@ function assembleCollectorConfig(adotRelevantConfigs) {
return collectorConfig;
}

const collectorConfigTemplate = {
receivers: {
otlp: {
protocols: {
http: {
endpoint: '0.0.0.0:4318'
},
grpc: {
endpoint: '0.0.0.0:4317'
}
}
}
},
processors: {},
exporters: {},
service: {
pipelines: {}
}
};

// Map of functions that translate vendor-specific configuration to OpenTelemetry Collector configuration to be used by ADOT
const vendorToCollectorConfigTranslators = {
datadog: (config) => {
Expand Down Expand Up @@ -219,19 +237,6 @@ const vendorToCollectorConfigTranslators = {
}
};

// Parses the full list of reporter configurations and returns a list of only the relevant ones for ADOT
function getADOTRelevantReporterConfigs(configList) {
const configs = configList.filter(
(reporterConfig) =>
(ADOTSupportedTraceReporters.includes(reporterConfig.type) &&
reporterConfig.traces) ||
(ADOTSupportedMetricReporters.includes(reporterConfig.type) &&
reporterConfig.metrics)
);

return configs.length > 0 ? configs : null;
}

// Resolve the configuration settings for ADOT

function resolveADOTConfigSettings(options) {
Expand Down

0 comments on commit c22c38e

Please sign in to comment.