@dynatrace/opentelemetry-azure-functions
Version:
Dynatrace OpenTelemetry package for Azure Functions
59 lines (56 loc) • 2.17 kB
JavaScript
;
/*
Copyright 2022 Dynatrace LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHttpOutBindingName = exports.getTriggerType = void 0;
const opentelemetry_core_1 = require("@dynatrace/opentelemetry-core");
// ============================================================================
/**
* Detect function trigger type.
*
* @note currently only HTTP trigger is supported
*
* @param context the azure function context
* @param args the arguments passed to the function
* @returns the trigger type
*/
function getTriggerType(context) {
if (Array.isArray(context.bindingDefinitions)) {
for (const binding of context.bindingDefinitions) {
if (binding.type === "httpTrigger") {
return opentelemetry_core_1.SemConvTrace.FaasTriggerValues.HTTP;
}
}
}
return opentelemetry_core_1.SemConvTrace.FaasTriggerValues.OTHER;
}
exports.getTriggerType = getTriggerType;
// ----------------------------------------------------------------------------
/**
* Returns the name of the HTTP out binding
*
* @param context the azure function context
* @returns name of the out binding or undefined
*/
function getHttpOutBindingName(context) {
if (Array.isArray(context.bindingDefinitions)) {
for (const binding of context.bindingDefinitions) {
if (binding.type === "http" && binding.direction === "out") {
return binding.name;
}
}
}
return undefined;
}
exports.getHttpOutBindingName = getHttpOutBindingName;
//# sourceMappingURL=Bindings.js.map